← スキル一覧に戻る

writing-rules
by jasonkuhrt
Tool configurations
⭐ 1🍴 0📅 2026年1月22日
SKILL.md
name: writing-rules description: Use when creating project rules, adding .claude/rules/*.md files, or scoping rules to specific files with globs for token efficiency.
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
.claude/rules/*.mdfiles - Scoping rules to specific files with globs
- Setting up doc-sync reminders (update X when Y changes)
Rule File Locations
| Location | Scope | Loaded When |
|---|---|---|
.claude/CLAUDE.md | Project-wide | Always |
.claude/rules/*.md | File-specific | When globs match |
~/.claude/CLAUDE.md | User global | Always (all projects) |
~/.claude/rules/*.md | User file-specific | When globs match |
Workflow
1. Choose Scope
- Project-wide (commits, general info) →
.claude/CLAUDE.md - File-specific (component rules, doc sync) →
.claude/rules/*.mdwith globs
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
スコア
総合スコア
55/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です



