Skill v1.0.2
currentAutomated scan100/100+2 new
version: "1.0.2" name: cc-add-rule allowed-tools: Read, Write, Glob, Bash(ls:), Bash(mkdir:) argument-hint: "[pattern] rule content..." description: Create a global Claude Code rule in ~/.claude/rules
Arguments
$ARGUMENTS = [{path-pattern}] {rule content...}
Parse the arguments:
- Path pattern: Optional glob pattern - first token only, if it starts with
*or contains/or{ - Rule content: Everything else (no quotes needed)
Target Directory
~/.claude/rules/
Workflow
- Parse - Extract rule content and optional path-pattern from arguments
- Analyze - Determine appropriate category and filename based on rule content:
- Categories: existing ones include
tools/,git/,rust/,ts/,i18n/,claude/; create a new category when none fit - Filename: kebab-case, descriptive,
.mdextension
- Draft - Create the rule file content:
- If path-pattern provided: Add frontmatter with a
pathsfield - Write clear, concise rule in Markdown format
- Confirm - Show the proposed file path and content
- STOP - Wait for user approval (use AskUserQuestion)
- Create - Only after approval, create the rule file
Rule Format
Without path-pattern
# Rule TitleRule content here.
With path-pattern
---paths: "{ path-pattern }"---# Rule TitleRule content here.
Examples
Input: /cc-add-rule Use descriptive variable names Output: ~/.claude/rules/code/descriptive-variables.md
Input: /cc-add-rule *.py Always use type annotations Output: ~/.claude/rules/python/type-annotations.md with paths: "**/*.py"
Input: /cc-add-rule src/**/*.ts Use strict null checks Output: ~/.claude/rules/ts/strict-null-checks.md with paths: "src/**/*.ts"
Content Guidelines
Analyze the {rule content} to understand the intended purpose, then write the rule file content:
- In English, optimized for AI comprehension
- Use clear, imperative language
- Focus on actionable instructions rather than verbose explanations
Begin
Parse $ARGUMENTS and create the appropriate rule file. Ask for user approval before writing.