Claude-skill-registry writing-rules
Use when creating project rules, adding .claude/rules/*.md files, or scoping rules to specific files with globs for token efficiency.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/cc-writing-rules" ~/.claude/skills/majiayu000-claude-skill-registry-writing-rules && rm -rf "$T"
manifest:
skills/data/cc-writing-rules/SKILL.mdsource content
Writing Project Rules
Overview
Project rules provide context-specific instructions to Claude. This skill covers creating file-scoped rules that minimize token usage by only loading when relevant files are touched.
When to Use
- Creating new project rules
- Adding
files.claude/rules/*.md - Scoping rules to specific files with globs
- Setting up doc-sync reminders (update X when Y changes)
Rule File Locations
| Location | Scope | Loaded When |
|---|---|---|
| Project-wide | Always |
| File-specific | When globs match |
| User global | Always (all projects) |
| User file-specific | When globs match |
Workflow
1. Choose Scope
- Project-wide (commits, general info) →
.claude/CLAUDE.md - File-specific (component rules, doc sync) →
with globs.claude/rules/*.md
2. Create File-Scoped Rule
--- globs: src/api/**/*.ts --- # API Rules - Use Result types for errors - Validate inputs at boundaries
3. Use Appropriate Glob Patterns
*.ts # All .ts files anywhere src/**/*.ts # All .ts in src tree fish/config.fish # Exact file match {src,lib}/**/*.ts # Multiple directories
Multiple globs:
--- globs: - src/api/**/*.ts - src/services/**/*.ts ---
Example: Doc Sync Rule
When modifying a file should trigger doc updates:
--- globs: fish/config.fish --- # Git Dashboard When modifying `_git_*` functions: - Update `fish/GIT_DASHBOARD_DESIGN.md` after visible changes
Rules vs Skills
Consider a skill instead of a rule when:
- Content applies to operations (git push, running tests) not file edits
- Guidance is on-demand rather than always needed
- The glob pattern doesn't match when the rule would actually help
Gotcha: A rule with
globs: ".github/**" containing "never push to main" won't load during git push - it only loads when editing .github files. Use a skill or hook instead.
Key Principles
- Prefer globs over project-wide - reduces token usage
- Keep rules concise - they consume context tokens
- One concern per rule file - easier to maintain
- Multiple rules can match - all matching rules apply
- Match globs to trigger - ensure glob fires when rule is needed