# rule-create > Creates a new Claude Code rule file. Use when: creating project guidelines, coding standards, or path-specific rules in .claude/rules/. - Author: Edison - Repository: soilmass/claudeutils - Version: 20260127023329 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/soilmass/claudeutils - Web: https://mule.run/skillshub/@@soilmass/claudeutils~rule-create:20260127023329 --- --- name: rule-create description: >- Creates a new Claude Code rule file. Use when: creating project guidelines, coding standards, or path-specific rules in .claude/rules/. license: MIT metadata: author: claudeutils version: "1.0.0" allowed-tools: Read Write Glob disable-model-invocation: true user-invocable: true argument-hint: " [--paths pattern] [--always]" --- ## Task Create a new rule file that complies with Claude Code rule conventions. ## Input - `$0`: Rule name (lowercase, hyphens, 1-64 chars) - `--paths`: Optional glob pattern for path-specific rules - `--always`: If present, apply rule to all files (alwaysApply: true) ## Instructions 1. **Validate input** - Name must be 1-64 characters - Name must be lowercase letters, numbers, and hyphens only - Name must not start or end with hyphen - Name must not contain consecutive hyphens (`--`) 2. **Determine location** - Rules go in `.claude/rules/` directory - Create directory if it doesn't exist 3. **Handle subdirectories** - If name contains `/`, treat as subdirectory path (e.g., `frontend/react`) - Create subdirectory structure if needed 4. **Create rule file** at `.claude/rules/{name}.md` with: - Optional YAML frontmatter (if --paths or --always specified): ```yaml --- alwaysApply: true # or paths list --- ``` - Rule heading with name - Sections: Overview, Requirements, Patterns (Do/Don't), Exceptions ## Output ### Success ``` Created: .claude/rules/{name}.md Rule: {name} Location: .claude/rules/{name}.md Scope: {all files | paths matching pattern} Next steps: 1. Edit the rule file to add your requirements 2. Rules are automatically loaded for matching paths ``` ### Error ``` ERROR: INPUT what: Invalid rule name where: $0 = "{provided_name}" why: {specific_reason} fix: Use lowercase letters, numbers, and hyphens (1-64 chars) ``` ## Template ```markdown # {Rule Name} ## Overview Brief description of what this rule enforces. ## Requirements - Requirement 1 - Requirement 2 - Requirement 3 ## Patterns ### Do - Pattern to follow - Another good pattern ### Don't - Anti-pattern to avoid - Another bad pattern ## Exceptions Cases where this rule may not apply: - Exception 1 - Exception 2 ```