aiblueprint-cli 1.4.22 → 1.4.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/claude-code-config/skills/git-commit/SKILL.md +42 -0
  2. package/claude-code-config/{commands/git/create-pr.md → skills/git-create-pr/SKILL.md} +12 -18
  3. package/claude-code-config/skills/git-fix-pr-comments/SKILL.md +51 -0
  4. package/claude-code-config/skills/git-merge/SKILL.md +68 -0
  5. package/claude-code-config/skills/{claude-memory → meta-claude-memory}/SKILL.md +7 -2
  6. package/claude-code-config/skills/meta-claude-memory/references/rules-directory-guide.md +298 -0
  7. package/claude-code-config/skills/meta-prompt-creator/SKILL.md +285 -0
  8. package/claude-code-config/skills/meta-prompt-creator/references/anthropic-best-practices.md +126 -0
  9. package/claude-code-config/skills/meta-prompt-creator/references/anti-patterns.md +57 -0
  10. package/claude-code-config/skills/meta-prompt-creator/references/clarity-principles.md +54 -0
  11. package/claude-code-config/skills/meta-prompt-creator/references/context-management.md +389 -0
  12. package/claude-code-config/skills/meta-prompt-creator/references/few-shot-patterns.md +47 -0
  13. package/claude-code-config/skills/meta-prompt-creator/references/openai-best-practices.md +50 -0
  14. package/claude-code-config/skills/meta-prompt-creator/references/prompt-templates.md +110 -0
  15. package/claude-code-config/skills/meta-prompt-creator/references/reasoning-techniques.md +52 -0
  16. package/claude-code-config/skills/meta-prompt-creator/references/system-prompt-patterns.md +48 -0
  17. package/claude-code-config/skills/meta-prompt-creator/references/xml-structure.md +36 -0
  18. package/claude-code-config/skills/meta-skill-creator/LICENSE.txt +202 -0
  19. package/claude-code-config/skills/meta-skill-creator/SKILL.md +421 -0
  20. package/claude-code-config/skills/meta-skill-creator/package.json +5 -0
  21. package/claude-code-config/skills/meta-skill-creator/references/output-patterns.md +82 -0
  22. package/claude-code-config/skills/meta-skill-creator/references/progressive-disclosure-patterns.md +374 -0
  23. package/claude-code-config/skills/meta-skill-creator/references/prompting-integration.md +363 -0
  24. package/claude-code-config/skills/meta-skill-creator/references/real-world-examples.md +513 -0
  25. package/claude-code-config/skills/meta-skill-creator/references/script-patterns.md +385 -0
  26. package/claude-code-config/skills/meta-skill-creator/references/workflows.md +28 -0
  27. package/claude-code-config/skills/meta-skill-creator/references/xml-tag-guide.md +606 -0
  28. package/claude-code-config/skills/meta-skill-creator/scripts/init-skill.ts +214 -0
  29. package/claude-code-config/skills/meta-skill-creator/scripts/package-skill.ts +146 -0
  30. package/claude-code-config/skills/meta-skill-creator/scripts/validate.ts +138 -0
  31. package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/SKILL.md +41 -15
  32. package/claude-code-config/skills/{setup-ralph → ralph-loop}/steps/step-00-init.md +2 -3
  33. package/claude-code-config/skills/utils-fix-errors/SKILL.md +61 -0
  34. package/claude-code-config/skills/utils-fix-grammar/SKILL.md +59 -0
  35. package/claude-code-config/skills/utils-oneshot/SKILL.md +56 -0
  36. package/claude-code-config/skills/workflow-apex/SKILL.md +303 -0
  37. package/claude-code-config/skills/workflow-apex/scripts/setup-templates.sh +134 -0
  38. package/claude-code-config/skills/workflow-apex/scripts/update-progress.sh +80 -0
  39. package/claude-code-config/skills/workflow-apex/steps/step-00-init.md +288 -0
  40. package/claude-code-config/skills/workflow-apex/steps/step-00b-branch.md +126 -0
  41. package/claude-code-config/skills/workflow-apex/steps/step-00b-economy.md +244 -0
  42. package/claude-code-config/skills/workflow-apex/steps/step-00b-interactive.md +153 -0
  43. package/claude-code-config/skills/workflow-apex/steps/step-01-analyze.md +361 -0
  44. package/claude-code-config/skills/workflow-apex/steps/step-02-plan.md +264 -0
  45. package/claude-code-config/skills/workflow-apex/steps/step-03-execute.md +239 -0
  46. package/claude-code-config/skills/workflow-apex/steps/step-04-validate.md +264 -0
  47. package/claude-code-config/skills/workflow-apex/steps/step-05-examine.md +294 -0
  48. package/claude-code-config/skills/workflow-apex/steps/step-06-resolve.md +237 -0
  49. package/claude-code-config/skills/workflow-apex/steps/step-07-tests.md +250 -0
  50. package/claude-code-config/skills/workflow-apex/steps/step-08-run-tests.md +308 -0
  51. package/claude-code-config/skills/workflow-apex/steps/step-09-finish.md +193 -0
  52. package/claude-code-config/skills/workflow-apex/templates/00-context.md +51 -0
  53. package/claude-code-config/skills/workflow-apex/templates/01-analyze.md +10 -0
  54. package/claude-code-config/skills/workflow-apex/templates/02-plan.md +10 -0
  55. package/claude-code-config/skills/workflow-apex/templates/03-execute.md +10 -0
  56. package/claude-code-config/skills/workflow-apex/templates/04-validate.md +10 -0
  57. package/claude-code-config/skills/workflow-apex/templates/05-examine.md +10 -0
  58. package/claude-code-config/skills/workflow-apex/templates/06-resolve.md +10 -0
  59. package/claude-code-config/skills/workflow-apex/templates/07-tests.md +10 -0
  60. package/claude-code-config/skills/workflow-apex/templates/08-run-tests.md +10 -0
  61. package/claude-code-config/skills/workflow-apex/templates/09-finish.md +10 -0
  62. package/claude-code-config/skills/workflow-apex/templates/README.md +195 -0
  63. package/claude-code-config/skills/workflow-apex/templates/step-complete.md +7 -0
  64. package/dist/cli.js +46 -3
  65. package/package.json +1 -1
  66. package/claude-code-config/commands/explore.md +0 -90
  67. package/claude-code-config/commands/git/commit.md +0 -60
  68. package/claude-code-config/commands/git/fix-pr-comments.md +0 -59
  69. package/claude-code-config/commands/oneshot.md +0 -57
  70. package/claude-code-config/skills/create-slash-commands/SKILL.md +0 -1110
  71. package/claude-code-config/skills/create-slash-commands/references/arguments.md +0 -273
  72. package/claude-code-config/skills/create-slash-commands/references/patterns.md +0 -947
  73. package/claude-code-config/skills/create-slash-commands/references/prompt-examples.md +0 -656
  74. package/claude-code-config/skills/create-slash-commands/references/tool-restrictions.md +0 -389
  75. /package/claude-code-config/skills/{claude-memory → meta-claude-memory}/references/comprehensive-example.md +0 -0
  76. /package/claude-code-config/skills/{claude-memory → meta-claude-memory}/references/project-patterns.md +0 -0
  77. /package/claude-code-config/skills/{claude-memory → meta-claude-memory}/references/prompting-techniques.md +0 -0
  78. /package/claude-code-config/skills/{claude-memory → meta-claude-memory}/references/section-templates.md +0 -0
  79. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/context-management.md +0 -0
  80. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/debugging-agents.md +0 -0
  81. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/error-handling-and-recovery.md +0 -0
  82. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/evaluation-and-testing.md +0 -0
  83. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/orchestration-patterns.md +0 -0
  84. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/subagents.md +0 -0
  85. /package/claude-code-config/skills/{create-subagents → meta-subagent-creator}/references/writing-subagent-prompts.md +0 -0
  86. /package/claude-code-config/skills/{setup-ralph → ralph-loop}/SKILL.md +0 -0
  87. /package/claude-code-config/skills/{setup-ralph → ralph-loop}/scripts/setup.sh +0 -0
  88. /package/claude-code-config/skills/{setup-ralph → ralph-loop}/steps/step-01-interactive-prd.md +0 -0
  89. /package/claude-code-config/skills/{setup-ralph → ralph-loop}/steps/step-02-create-stories.md +0 -0
  90. /package/claude-code-config/skills/{setup-ralph → ralph-loop}/steps/step-03-finish.md +0 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: commit
3
+ description: Quick commit and push with minimal, clean messages
4
+ model: haiku
5
+ allowed-tools: Bash(git :*), Bash(npm :*), Bash(pnpm :*)
6
+ ---
7
+
8
+ # Commit
9
+
10
+ Quick commit with conventional message format, then push.
11
+
12
+ ## Context
13
+
14
+ - Git state: !`git status`
15
+ - Staged changes: !`git diff --cached --stat`
16
+ - Unstaged changes: !`git diff --stat`
17
+ - Recent commits: !`git log --oneline -5`
18
+ - Current branch: !`git branch --show-current`
19
+
20
+ ## Workflow
21
+
22
+ 1. **Analyze**: Review git status
23
+ - Nothing staged but unstaged changes exist: `git add .`
24
+ - Nothing to commit: inform user and exit
25
+
26
+ 2. **Generate commit message**:
27
+ - Format: `type(scope): brief description`
28
+ - Types: `feat`, `fix`, `update`, `docs`, `chore`, `refactor`, `test`, `perf`, `revert`
29
+ - Under 72 chars, imperative mood, lowercase after colon
30
+ - Example: `update(statusline): refresh spend data`
31
+
32
+ 3. **Commit**: `git commit -m "message"`
33
+
34
+ 4. **Push**: `git push`
35
+
36
+ ## Rules
37
+
38
+ - SPEED OVER PERFECTION: Generate one good message and commit
39
+ - NO INTERACTION: Never ask questions - analyze and commit
40
+ - AUTO-STAGE: If nothing staged, stage everything
41
+ - AUTO-PUSH: Always push after committing
42
+ - IMPERATIVE MOOD: "add", "update", "fix" not past tense
@@ -1,10 +1,13 @@
1
1
  ---
2
- allowed-tools: Bash(git :*), Bash(gh :*)
2
+ name: create-pr
3
3
  description: Create and push PR with auto-generated title and description
4
4
  model: haiku
5
+ allowed-tools: Bash(git :*), Bash(gh :*)
5
6
  ---
6
7
 
7
- You are a PR automation tool. Create pull requests with concise, meaningful descriptions.
8
+ # Create PR
9
+
10
+ Create pull request with concise, meaningful description.
8
11
 
9
12
  ## Context
10
13
 
@@ -15,14 +18,11 @@ You are a PR automation tool. Create pull requests with concise, meaningful desc
15
18
 
16
19
  ## Workflow
17
20
 
18
- 1. **Verify**: `git status` and `git branch --show-current` to check state
19
- 2. **Branch Safety**: **CRITICAL** - Ensure not on main/master branch
20
- - If on `main` or `master`: Create descriptive branch from changes
21
- - Analyze staged files to generate meaningful branch name
22
- - **NEVER** commit directly to protected branches
23
- 3. **Push**: `git push -u origin HEAD` to ensure remote tracking
24
- 4. **Analyze**: `git diff origin/main...HEAD --stat` to understand changes
25
- 5. **Generate**: Create PR with:
21
+ 1. **Verify**: Check `git status` and current branch
22
+ 2. **Branch Safety**: **CRITICAL** - If on main/master, create descriptive branch from changes
23
+ 3. **Push**: `git push -u origin HEAD`
24
+ 4. **Analyze**: `git diff origin/main...HEAD --stat`
25
+ 5. **Generate PR**:
26
26
  - Title: One-line summary (max 72 chars)
27
27
  - Body: Bullet points of key changes
28
28
  6. **Submit**: `gh pr create --title "..." --body "..."`
@@ -42,7 +42,7 @@ You are a PR automation tool. Create pull requests with concise, meaningful desc
42
42
  [feat/fix/refactor/docs/chore]
43
43
  ```
44
44
 
45
- ## Execution Rules
45
+ ## Rules
46
46
 
47
47
  - NO verbose descriptions
48
48
  - NO "Generated with" signatures
@@ -50,10 +50,4 @@ You are a PR automation tool. Create pull requests with concise, meaningful desc
50
50
  - Use HEREDOC for multi-line body
51
51
  - If PR exists, return existing URL
52
52
 
53
- ## Priority
54
-
55
- Clarity > Completeness. Keep PRs scannable and actionable.
56
-
57
- ---
58
-
59
- User: #$ARGUMENTS
53
+ User: $ARGUMENTS
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: fix-pr-comments
3
+ description: Fetch PR review comments and implement all requested changes
4
+ allowed-tools: Bash(gh :*), Bash(git :*), Read, Edit, MultiEdit
5
+ ---
6
+
7
+ # Fix PR Comments
8
+
9
+ Systematically address ALL unresolved review comments until PR is approved.
10
+
11
+ ## Context
12
+
13
+ - Current branch: !`git branch --show-current`
14
+ - Working tree status: !`git status --short`
15
+ - Recent commits: !`git log --oneline -3`
16
+
17
+ ## Workflow
18
+
19
+ 1. **FETCH COMMENTS**:
20
+ - Identify PR: `gh pr status --json number,headRefName`
21
+ - Get reviews: `gh pr review list --state CHANGES_REQUESTED`
22
+ - Get inline: `gh api repos/{owner}/{repo}/pulls/{number}/comments`
23
+ - Capture BOTH review comments AND inline code comments
24
+ - STOP if no PR found - ask user for PR number
25
+
26
+ 2. **ANALYZE & PLAN**:
27
+ - Extract exact file:line references
28
+ - Group by file for MultiEdit efficiency
29
+ - STAY IN SCOPE: NEVER fix unrelated issues
30
+ - Create checklist: one item per comment
31
+
32
+ 3. **IMPLEMENT FIXES**:
33
+ - BEFORE editing: ALWAYS `Read` target file first
34
+ - Batch changes with `MultiEdit` for same-file modifications
35
+ - Make EXACTLY what reviewer requested
36
+ - Check off each resolved comment
37
+
38
+ 4. **COMMIT & PUSH**:
39
+ - Stage: `git add -A`
40
+ - Commit: `fix: address PR review comments`
41
+ - Push: `git push`
42
+ - NEVER include co-author tags
43
+
44
+ ## Rules
45
+
46
+ - Every unresolved comment MUST be addressed
47
+ - Read files BEFORE any edits - no exceptions
48
+ - FORBIDDEN: Style changes beyond reviewer requests
49
+ - On failure: Return to ANALYZE phase, never skip comments
50
+
51
+ User: $ARGUMENTS
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: merge
3
+ description: Intelligently merge branches with context-aware conflict resolution
4
+ allowed-tools: Bash(git :*), Bash(gh :*), Read, Edit, MultiEdit, Task
5
+ argument-hint: <branch-name>
6
+ ---
7
+
8
+ # Merge
9
+
10
+ Merge branches intelligently by understanding feature context and resolving conflicts efficiently.
11
+
12
+ ## Context
13
+
14
+ - Current branch: !`git branch --show-current`
15
+ - Working tree status: !`git status --short`
16
+ - Target branch: $1
17
+ - Recent commits: !`git log --oneline -5`
18
+
19
+ ## Workflow
20
+
21
+ 1. **CONTEXT GATHERING**:
22
+ - `git branch --show-current` to identify current branch
23
+ - `git status` to ensure clean working tree
24
+ - **CRITICAL**: Abort if uncommitted changes exist
25
+
26
+ 2. **FEATURE ANALYSIS**:
27
+ - Search PR with `gh pr list --head <branch-name>`
28
+ - Get PR details with `gh pr view <number> --json title,body,files`
29
+ - Use Task agents to gather context from PR/issue descriptions
30
+
31
+ 3. **MERGE ATTEMPT**:
32
+ - `git fetch origin <branch-name>`
33
+ - `git merge origin/<branch-name> --no-commit`
34
+ - Check status with `git status --porcelain`
35
+
36
+ 4. **CONFLICT DETECTION**:
37
+ - Clean merge: `git commit` with descriptive message
38
+ - Conflicts: Parse `git diff --name-only --diff-filter=U`
39
+
40
+ 5. **SMART RESOLUTION**: For each conflicted file:
41
+ - Read file to understand conflict markers
42
+ - Apply resolution based on context:
43
+ - **Feature additions**: Keep both if non-overlapping
44
+ - **Bug fixes**: Prefer incoming if fixing known issue
45
+ - **Refactors**: Analyze intent and merge carefully
46
+ - Use MultiEdit to resolve all conflicts
47
+ - **STOP**: If >10 files conflicted, ask user
48
+
49
+ 6. **VERIFICATION**:
50
+ - `git diff --cached` to review changes
51
+ - Check no conflict markers remain: `grep -r "<<<<<<< HEAD"`
52
+ - `git add -A` and commit
53
+
54
+ ## Conflict Resolution by Type
55
+
56
+ - **package.json**: Merge dependencies, prefer higher versions
57
+ - **Config files**: Combine settings unless mutually exclusive
58
+ - **Source code**: Use PR/issue context to understand intent
59
+ - **Tests**: Keep all tests unless duplicates
60
+ - **Imports**: Merge all, deduplicate
61
+
62
+ ## Rules
63
+
64
+ - ALWAYS gather context before merging
65
+ - NEVER blindly accept theirs/ours without analysis
66
+ - ABORT if conflicts exceed 10 files
67
+ - Max 3 resolution attempts per file
68
+ - If stuck: `git merge --abort` and report blockers
@@ -144,7 +144,8 @@ Rules can be scoped to specific files using YAML frontmatter:
144
144
 
145
145
  ```yaml
146
146
  ---
147
- paths: src/api/**/*.ts
147
+ paths:
148
+ - "src/api/**/*.ts"
148
149
  ---
149
150
  # API Development Rules
150
151
 
@@ -162,6 +163,8 @@ paths: src/api/**/*.ts
162
163
  | `src/**/*.{ts,tsx}` | TypeScript and TSX files (brace expansion) |
163
164
  | `{src,lib}/**/*.ts` | Files in multiple directories |
164
165
 
166
+ **Syntax note:** The `paths` field must be a YAML array (list format with `-` prefix and quoted strings).
167
+
165
168
  **Rules without `paths` frontmatter** load unconditionally for all files.
166
169
  </path_scoped_rules>
167
170
 
@@ -576,7 +579,8 @@ Use AskUserQuestion to present these options before proceeding.
576
579
  3. Add path-scoped rules as needed:
577
580
  ```yaml
578
581
  ---
579
- paths: src/api/**/*.ts
582
+ paths:
583
+ - "src/api/**/*.ts"
580
584
  ---
581
585
  # API rules here
582
586
  ```
@@ -682,6 +686,7 @@ A well-crafted Claude memory system:
682
686
  <reference_guides>
683
687
  For deeper topics:
684
688
 
689
+ - **Rules directory guide**: [references/rules-directory-guide.md](references/rules-directory-guide.md) - Complete guide to .claude/rules/ with official documentation, path-scoping, YAML syntax, and examples
685
690
  - **Prompting techniques**: [references/prompting-techniques.md](references/prompting-techniques.md) - Master guide for writing effective instructions, emphasis strategies, clarity techniques
686
691
  - **Comprehensive example**: [references/comprehensive-example.md](references/comprehensive-example.md) - Full production SaaS CLAUDE.md
687
692
  - **Section templates**: [references/section-templates.md](references/section-templates.md) - Copy-paste templates for each section
@@ -0,0 +1,298 @@
1
+ # .claude/rules/ Directory - Official Guide
2
+
3
+ Complete guide to using modular rules with `.claude/rules/` directory, based on official Claude Code documentation.
4
+
5
+ ## Overview
6
+
7
+ For larger projects, organize instructions into multiple files using the `.claude/rules/` directory. This allows teams to maintain focused, well-organized rule files instead of one large CLAUDE.md.
8
+
9
+ ## Basic Structure
10
+
11
+ Place markdown files in your project's `.claude/rules/` directory:
12
+
13
+ ```
14
+ your-project/
15
+ ├── .claude/
16
+ │ ├── CLAUDE.md # Main project instructions
17
+ │ └── rules/
18
+ │ ├── code-style.md # Code style guidelines
19
+ │ ├── testing.md # Testing conventions
20
+ │ └── security.md # Security requirements
21
+ ```
22
+
23
+ **Key points:**
24
+ - All `.md` files in `.claude/rules/` are automatically loaded as project memory
25
+ - Same priority as `.claude/CLAUDE.md`
26
+ - No imports or configuration needed
27
+
28
+ ## Path-Specific Rules
29
+
30
+ Rules can be scoped to specific files using YAML frontmatter with the `paths` field. These conditional rules only apply when Claude is working with files matching the specified patterns.
31
+
32
+ ### Syntax
33
+
34
+ ```yaml
35
+ ---
36
+ paths:
37
+ - "src/api/**/*.ts"
38
+ ---
39
+
40
+ # API Development Rules
41
+
42
+ - All API endpoints must include input validation
43
+ - Use the standard error response format
44
+ - Include OpenAPI documentation comments
45
+ ```
46
+
47
+ **Important:**
48
+ - `paths` must be a YAML array (list format with `-` prefix)
49
+ - Rules **without** a `paths` field are loaded unconditionally
50
+ - Conditional rules only load when working with matching files
51
+
52
+ ### Glob Patterns
53
+
54
+ The `paths` field supports standard glob patterns:
55
+
56
+ | Pattern | Matches |
57
+ | ---------------------- | ---------------------------------------- |
58
+ | `**/*.ts` | All TypeScript files in any directory |
59
+ | `src/**/*` | All files under `src/` directory |
60
+ | `*.md` | Markdown files in the project root |
61
+ | `src/components/*.tsx` | React components in a specific directory |
62
+
63
+ ### Multiple Patterns
64
+
65
+ Specify multiple patterns in the array:
66
+
67
+ ```yaml
68
+ ---
69
+ paths:
70
+ - "src/**/*.ts"
71
+ - "lib/**/*.ts"
72
+ - "tests/**/*.test.ts"
73
+ ---
74
+ ```
75
+
76
+ ### Brace Expansion
77
+
78
+ Use brace expansion for matching multiple extensions or directories:
79
+
80
+ ```yaml
81
+ ---
82
+ paths:
83
+ - "src/**/*.{ts,tsx}"
84
+ - "{src,lib}/**/*.ts"
85
+ ---
86
+
87
+ # TypeScript/React Rules
88
+ ```
89
+
90
+ This expands `src/**/*.{ts,tsx}` to match both `.ts` and `.tsx` files.
91
+
92
+ ## Subdirectories
93
+
94
+ Rules can be organized into subdirectories for better structure:
95
+
96
+ ```
97
+ .claude/rules/
98
+ ├── frontend/
99
+ │ ├── react.md
100
+ │ └── styles.md
101
+ ├── backend/
102
+ │ ├── api.md
103
+ │ └── database.md
104
+ └── general.md
105
+ ```
106
+
107
+ All `.md` files are discovered recursively in any subdirectory depth.
108
+
109
+ ## Symlinks
110
+
111
+ The `.claude/rules/` directory supports symlinks, allowing you to share common rules across multiple projects:
112
+
113
+ ```bash
114
+ # Symlink a shared rules directory
115
+ ln -s ~/shared-claude-rules .claude/rules/shared
116
+
117
+ # Symlink individual rule files
118
+ ln -s ~/company-standards/security.md .claude/rules/security.md
119
+ ```
120
+
121
+ **Behavior:**
122
+ - Symlinks are resolved and their contents are loaded normally
123
+ - Circular symlinks are detected and handled gracefully
124
+ - Great for sharing company standards across projects
125
+
126
+ ## User-Level Rules
127
+
128
+ Create personal rules that apply to all your projects in `~/.claude/rules/`:
129
+
130
+ ```
131
+ ~/.claude/rules/
132
+ ├── preferences.md # Your personal coding preferences
133
+ └── workflows.md # Your preferred workflows
134
+ ```
135
+
136
+ **Priority:**
137
+ - User-level rules load before project rules
138
+ - Project rules take higher priority (can override user rules)
139
+ - User rules typically **don't** need `paths` frontmatter (apply globally)
140
+
141
+ ## Examples
142
+
143
+ ### Unconditional Project Rule
144
+
145
+ File: `.claude/rules/testing.md`
146
+
147
+ ```markdown
148
+ # Testing Conventions
149
+
150
+ - Write tests in `__tests__/` directories
151
+ - Use Vitest for unit tests
152
+ - Minimum 80% coverage for new code
153
+ - Run `pnpm test` before committing
154
+ ```
155
+
156
+ No frontmatter needed - applies to entire project.
157
+
158
+ ### Path-Specific Rule
159
+
160
+ File: `.claude/rules/api-standards.md`
161
+
162
+ ```yaml
163
+ ---
164
+ paths:
165
+ - "src/api/**/*.ts"
166
+ - "src/routes/**/*.ts"
167
+ ---
168
+
169
+ # API Development Standards
170
+
171
+ - All endpoints must validate input with Zod
172
+ - Use standard error response format
173
+ - Include rate limiting for public endpoints
174
+ - Document with OpenAPI comments
175
+ ```
176
+
177
+ Only loads when working with API-related TypeScript files.
178
+
179
+ ### Frontend-Specific Rules
180
+
181
+ File: `.claude/rules/frontend/react.md`
182
+
183
+ ```yaml
184
+ ---
185
+ paths:
186
+ - "src/components/**/*.{tsx,ts}"
187
+ - "src/app/**/*.tsx"
188
+ ---
189
+
190
+ # React Component Guidelines
191
+
192
+ - Prefer Server Components (Next.js App Router)
193
+ - Use `"use client"` only when needed for interactivity
194
+ - Keep components under 300 lines
195
+ - Extract hooks to separate files
196
+ ```
197
+
198
+ ### User-Level Global Rule
199
+
200
+ File: `~/.claude/rules/preferences.md`
201
+
202
+ ```markdown
203
+ # My Personal Coding Preferences
204
+
205
+ - I prefer concise variable names (no unnecessary verbosity)
206
+ - Always add error boundaries around async operations
207
+ - Use early returns to reduce nesting
208
+ ```
209
+
210
+ No frontmatter - applies to all projects globally.
211
+
212
+ ## Best Practices
213
+
214
+ ### Keep Rules Focused
215
+
216
+ Each file should cover one topic:
217
+ - ✅ `testing.md` - All testing conventions
218
+ - ✅ `api-design.md` - API-specific patterns
219
+ - ✅ `security.md` - Security requirements
220
+ - ❌ `everything.md` - Mixed concerns
221
+
222
+ ### Use Descriptive Filenames
223
+
224
+ The filename should indicate what the rules cover:
225
+ - ✅ `database-migrations.md`
226
+ - ✅ `error-handling.md`
227
+ - ❌ `stuff.md`
228
+ - ❌ `misc.md`
229
+
230
+ ### Use Conditional Rules Sparingly
231
+
232
+ Only add `paths` frontmatter when rules **truly** apply to specific file types:
233
+ - ✅ API validation rules → `paths: ["src/api/**/*.ts"]`
234
+ - ✅ React component rules → `paths: ["**/*.tsx"]`
235
+ - ❌ General project conventions → No paths needed
236
+
237
+ ### Organize with Subdirectories
238
+
239
+ Group related rules:
240
+
241
+ ```
242
+ .claude/rules/
243
+ ├── frontend/
244
+ │ ├── components.md
245
+ │ ├── styling.md
246
+ │ └── state-management.md
247
+ ├── backend/
248
+ │ ├── api.md
249
+ │ ├── database.md
250
+ │ └── auth.md
251
+ └── general.md
252
+ ```
253
+
254
+ ### Avoid Duplication
255
+
256
+ Don't repeat the same rules in multiple files. If a rule applies globally, put it in:
257
+ 1. Root-level rule file (e.g., `.claude/rules/general.md`)
258
+ 2. Or in `.claude/CLAUDE.md`
259
+
260
+ ## Troubleshooting
261
+
262
+ | Problem | Solution |
263
+ |---------|----------|
264
+ | Rules not loading | Ensure file extension is `.md` and in `.claude/rules/` |
265
+ | Path rules not applying | Verify glob pattern matches target files exactly |
266
+ | Rules conflicting | Check for duplicates across multiple files |
267
+ | Too many rules loading | Use `paths` frontmatter to scope appropriately |
268
+
269
+ ## When to Use .claude/rules/ vs CLAUDE.md
270
+
271
+ **Use `.claude/rules/` when:**
272
+ - Project has many distinct concerns (testing, security, API, frontend)
273
+ - Different rules apply to different file types
274
+ - Team members maintain different areas
275
+ - You want to update one concern without touching others
276
+ - CLAUDE.md exceeds 200 lines
277
+
278
+ **Use CLAUDE.md when:**
279
+ - Project is small/simple (< 100 lines of instructions)
280
+ - All rules are universal across the project
281
+ - You prefer a single source of truth
282
+ - Quick setup is priority
283
+
284
+ ## Migration Path
285
+
286
+ When CLAUDE.md grows too large (200+ lines):
287
+
288
+ 1. **Identify sections**: testing, API, frontend, security, etc.
289
+ 2. **Create `.claude/rules/` directory**
290
+ 3. **Move each section** to its own file
291
+ 4. **Add `paths` frontmatter** where rules are file-type specific
292
+ 5. **Keep universal essentials** in CLAUDE.md (or remove it entirely)
293
+ 6. **Test** to ensure rules load correctly
294
+
295
+ ## Reference
296
+
297
+ Based on official Claude Code documentation:
298
+ https://code.claude.com/docs/mcp/claude-md#modular-rules-with-clauderules