aiblueprint-cli 1.4.11 → 1.4.13
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.
- package/claude-code-config/scripts/.claude/commands/fix-on-my-computer.md +87 -0
- package/claude-code-config/scripts/command-validator/CLAUDE.md +112 -0
- package/claude-code-config/scripts/command-validator/src/__tests__/validator.test.ts +62 -111
- package/claude-code-config/scripts/command-validator/src/cli.ts +5 -3
- package/claude-code-config/scripts/command-validator/src/lib/security-rules.ts +3 -4
- package/claude-code-config/scripts/command-validator/src/lib/types.ts +1 -0
- package/claude-code-config/scripts/command-validator/src/lib/validator.ts +47 -317
- package/claude-code-config/scripts/statusline/CLAUDE.md +29 -7
- package/claude-code-config/scripts/statusline/README.md +89 -1
- package/claude-code-config/scripts/statusline/defaults.json +75 -0
- package/claude-code-config/scripts/statusline/src/index.ts +101 -24
- package/claude-code-config/scripts/statusline/src/lib/config-types.ts +100 -0
- package/claude-code-config/scripts/statusline/src/lib/config.ts +21 -0
- package/claude-code-config/scripts/statusline/src/lib/context.ts +32 -11
- package/claude-code-config/scripts/statusline/src/lib/formatters.ts +360 -22
- package/claude-code-config/scripts/statusline/src/lib/git.ts +100 -0
- package/claude-code-config/scripts/statusline/src/lib/render-pure.ts +177 -0
- package/claude-code-config/scripts/statusline/src/lib/types.ts +11 -0
- package/claude-code-config/scripts/statusline/statusline.config.json +93 -0
- package/claude-code-config/skills/claude-memory/SKILL.md +689 -0
- package/claude-code-config/skills/claude-memory/references/comprehensive-example.md +175 -0
- package/claude-code-config/skills/claude-memory/references/project-patterns.md +334 -0
- package/claude-code-config/skills/claude-memory/references/prompting-techniques.md +411 -0
- package/claude-code-config/skills/claude-memory/references/section-templates.md +347 -0
- package/claude-code-config/skills/create-slash-commands/SKILL.md +1110 -0
- package/claude-code-config/skills/create-slash-commands/references/arguments.md +273 -0
- package/claude-code-config/skills/create-slash-commands/references/patterns.md +947 -0
- package/claude-code-config/skills/create-slash-commands/references/prompt-examples.md +656 -0
- package/claude-code-config/skills/create-slash-commands/references/tool-restrictions.md +389 -0
- package/claude-code-config/skills/create-subagents/SKILL.md +425 -0
- package/claude-code-config/skills/create-subagents/references/context-management.md +567 -0
- package/claude-code-config/skills/create-subagents/references/debugging-agents.md +714 -0
- package/claude-code-config/skills/create-subagents/references/error-handling-and-recovery.md +502 -0
- package/claude-code-config/skills/create-subagents/references/evaluation-and-testing.md +374 -0
- package/claude-code-config/skills/create-subagents/references/orchestration-patterns.md +591 -0
- package/claude-code-config/skills/create-subagents/references/subagents.md +599 -0
- package/claude-code-config/skills/create-subagents/references/writing-subagent-prompts.md +513 -0
- package/dist/cli.js +20 -3
- package/package.json +1 -1
- package/claude-code-config/commands/apex.md +0 -109
- package/claude-code-config/commands/tasks/run-task.md +0 -220
- package/claude-code-config/commands/utils/watch-ci.md +0 -47
- package/claude-code-config/scripts/command-validator/biome.json +0 -29
- package/claude-code-config/scripts/command-validator/bun.lockb +0 -0
- package/claude-code-config/scripts/command-validator/package.json +0 -27
- package/claude-code-config/scripts/command-validator/vitest.config.ts +0 -7
- package/claude-code-config/scripts/hook-post-file.ts +0 -162
- package/claude-code-config/scripts/statusline/biome.json +0 -34
- package/claude-code-config/scripts/statusline/bun.lockb +0 -0
- package/claude-code-config/scripts/statusline/fixtures/test-input.json +0 -25
- package/claude-code-config/scripts/statusline/package.json +0 -19
- package/claude-code-config/scripts/statusline/statusline.config.ts +0 -25
- package/claude-code-config/scripts/statusline/test.ts +0 -20
- package/claude-code-config/scripts/validate-command.js +0 -712
- package/claude-code-config/scripts/validate-command.readme.md +0 -283
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-memory
|
|
3
|
+
description: Create and optimize CLAUDE.md memory files or .claude/rules/ modular rules for Claude Code projects. Comprehensive guidance on file hierarchy, content structure, path-scoped rules, best practices, and anti-patterns. Use when working with CLAUDE.md files, .claude/rules directories, setting up new projects, or improving Claude Code's context awareness.
|
|
4
|
+
argument-hint: [task description]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Master the creation of effective Claude Code memory systems using either CLAUDE.md files or the modular `.claude/rules/` directory. This skill covers file hierarchy, content structure, path-scoped rules, formatting, emphasis techniques, and common anti-patterns to avoid.
|
|
9
|
+
|
|
10
|
+
Memory files are automatically loaded at session startup, consuming tokens from your 200k context window. Every instruction competes with Claude Code's ~50 built-in instructions, leaving ~100-150 effective instruction slots for your customizations.
|
|
11
|
+
|
|
12
|
+
**Two approaches available:**
|
|
13
|
+
|
|
14
|
+
- **CLAUDE.md** - Single file, simpler, best for small projects
|
|
15
|
+
- **.claude/rules/** - Modular files with optional path-scoping, best for large projects
|
|
16
|
+
</objective>
|
|
17
|
+
|
|
18
|
+
<quick_start>
|
|
19
|
+
<bootstrap_new_project>
|
|
20
|
+
Run `/init` in Claude Code to auto-generate a CLAUDE.md with project structure.
|
|
21
|
+
|
|
22
|
+
Or create manually at project root:
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
# Project Name
|
|
26
|
+
|
|
27
|
+
## Tech Stack
|
|
28
|
+
|
|
29
|
+
- [Primary language/framework]
|
|
30
|
+
- [Key libraries]
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
- `npm run dev` - Start development
|
|
35
|
+
- `npm test` - Run tests
|
|
36
|
+
- `npm run build` - Build for production
|
|
37
|
+
|
|
38
|
+
## Code Conventions
|
|
39
|
+
|
|
40
|
+
- [2-3 critical conventions]
|
|
41
|
+
|
|
42
|
+
## Important Context
|
|
43
|
+
|
|
44
|
+
- [1-2 architectural decisions worth knowing]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
</bootstrap_new_project>
|
|
48
|
+
|
|
49
|
+
<quick_add_memory>
|
|
50
|
+
Press `#` during a Claude Code session to quickly add new memory items without editing the file directly.
|
|
51
|
+
</quick_add_memory>
|
|
52
|
+
|
|
53
|
+
<edit_memory>
|
|
54
|
+
Use `/memory` command to open CLAUDE.md in your system editor.
|
|
55
|
+
</edit_memory>
|
|
56
|
+
</quick_start>
|
|
57
|
+
|
|
58
|
+
<file_hierarchy>
|
|
59
|
+
Claude Code loads CLAUDE.md files in a specific order. Higher priority files are loaded first and take precedence.
|
|
60
|
+
|
|
61
|
+
<loading_order>
|
|
62
|
+
| Priority | Location | Purpose | Scope |
|
|
63
|
+
|----------|----------|---------|-------|
|
|
64
|
+
| 1 (Highest) | `/Library/Application Support/ClaudeCode/CLAUDE.md` (macOS) | Enterprise policy (managed by IT) | All org users |
|
|
65
|
+
| 2 | `./CLAUDE.md` or `./.claude/CLAUDE.md` | Project memory (git-tracked) | Team via git |
|
|
66
|
+
| 2 | `./.claude/rules/*.md` | Modular rules (git-tracked) | Team via git |
|
|
67
|
+
| 3 | `~/.claude/CLAUDE.md` | User preferences (global) | All your projects |
|
|
68
|
+
| 3 | `~/.claude/rules/*.md` | Personal modular rules (global) | All your projects |
|
|
69
|
+
| 4 (Lowest) | `./CLAUDE.local.md` | Personal project prefs (auto-gitignored) | Just you |
|
|
70
|
+
</loading_order>
|
|
71
|
+
|
|
72
|
+
<recursive_loading>
|
|
73
|
+
Claude recurses UP from current directory to root, loading all CLAUDE.md files found.
|
|
74
|
+
|
|
75
|
+
Running Claude in `foo/bar/` loads:
|
|
76
|
+
|
|
77
|
+
1. `foo/bar/CLAUDE.md`
|
|
78
|
+
2. `foo/CLAUDE.md`
|
|
79
|
+
3. Root-level files
|
|
80
|
+
|
|
81
|
+
Claude also discovers CLAUDE.md in SUBTREES when reading files in those directories.
|
|
82
|
+
</recursive_loading>
|
|
83
|
+
|
|
84
|
+
<monorepo_strategy>
|
|
85
|
+
For monorepos, use layered approach:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
root/
|
|
89
|
+
├── CLAUDE.md # Universal: tech stack, git workflow
|
|
90
|
+
├── apps/
|
|
91
|
+
│ ├── web/CLAUDE.md # Frontend-specific patterns
|
|
92
|
+
│ └── api/CLAUDE.md # Backend-specific patterns
|
|
93
|
+
└── packages/
|
|
94
|
+
└── shared/CLAUDE.md # Shared library conventions
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Root file defines WHEN to use patterns; subtree files define HOW.
|
|
98
|
+
</monorepo_strategy>
|
|
99
|
+
</file_hierarchy>
|
|
100
|
+
|
|
101
|
+
<rules_directory>
|
|
102
|
+
The `.claude/rules/` directory provides a **modular alternative** to monolithic CLAUDE.md files. Instead of one large file, you organize instructions into multiple focused markdown files.
|
|
103
|
+
|
|
104
|
+
<when_to_use_rules>
|
|
105
|
+
**Use `.claude/rules/` when:**
|
|
106
|
+
|
|
107
|
+
- Project has many distinct concerns (testing, security, API, frontend)
|
|
108
|
+
- Different rules apply to different file types
|
|
109
|
+
- Team members maintain different areas
|
|
110
|
+
- You want to update one concern without touching others
|
|
111
|
+
|
|
112
|
+
**Use CLAUDE.md when:**
|
|
113
|
+
|
|
114
|
+
- Project is small/simple
|
|
115
|
+
- All rules are universal
|
|
116
|
+
- You prefer a single source of truth
|
|
117
|
+
</when_to_use_rules>
|
|
118
|
+
|
|
119
|
+
<rules_structure>
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
.claude/rules/
|
|
123
|
+
├── code-style.md # Formatting and conventions
|
|
124
|
+
├── testing.md # Test requirements
|
|
125
|
+
├── security.md # Security checklist
|
|
126
|
+
├── frontend/
|
|
127
|
+
│ ├── react.md # React-specific patterns
|
|
128
|
+
│ └── styles.md # CSS conventions
|
|
129
|
+
└── backend/
|
|
130
|
+
├── api.md # API development rules
|
|
131
|
+
└── database.md # Database conventions
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Key points:**
|
|
135
|
+
|
|
136
|
+
- All `.md` files are discovered recursively
|
|
137
|
+
- No imports or configuration needed
|
|
138
|
+
- Same priority as CLAUDE.md
|
|
139
|
+
- Supports symlinks for sharing rules across projects
|
|
140
|
+
</rules_structure>
|
|
141
|
+
|
|
142
|
+
<path_scoped_rules>
|
|
143
|
+
Rules can be scoped to specific files using YAML frontmatter:
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
---
|
|
147
|
+
paths: src/api/**/*.ts
|
|
148
|
+
---
|
|
149
|
+
# API Development Rules
|
|
150
|
+
|
|
151
|
+
- All API endpoints must include input validation
|
|
152
|
+
- Use the standard error response format
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Path patterns supported:**
|
|
156
|
+
|
|
157
|
+
| Pattern | Matches |
|
|
158
|
+
| ---------------------- | ------------------------------------------ |
|
|
159
|
+
| `**/*.ts` | All TypeScript files in any directory |
|
|
160
|
+
| `src/**/*` | All files under `src/` directory |
|
|
161
|
+
| `src/components/*.tsx` | React components in specific directory |
|
|
162
|
+
| `src/**/*.{ts,tsx}` | TypeScript and TSX files (brace expansion) |
|
|
163
|
+
| `{src,lib}/**/*.ts` | Files in multiple directories |
|
|
164
|
+
|
|
165
|
+
**Rules without `paths` frontmatter** load unconditionally for all files.
|
|
166
|
+
</path_scoped_rules>
|
|
167
|
+
|
|
168
|
+
<user_level_rules>
|
|
169
|
+
Create personal rules that apply to all your projects:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
~/.claude/rules/
|
|
173
|
+
├── preferences.md # Your coding preferences
|
|
174
|
+
├── workflows.md # Your preferred workflows
|
|
175
|
+
└── git.md # Your git conventions
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
User-level rules load before project rules, giving project rules higher priority for overrides.
|
|
179
|
+
</user_level_rules>
|
|
180
|
+
|
|
181
|
+
<symlinks_support>
|
|
182
|
+
Share common rules across multiple projects using symlinks:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Symlink a shared rules directory
|
|
186
|
+
ln -s ~/shared-claude-rules .claude/rules/shared
|
|
187
|
+
|
|
188
|
+
# Symlink individual rule files
|
|
189
|
+
ln -s ~/company-standards/security.md .claude/rules/security.md
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Circular symlinks are detected and handled gracefully.
|
|
193
|
+
</symlinks_support>
|
|
194
|
+
</rules_directory>
|
|
195
|
+
|
|
196
|
+
<content_framework>
|
|
197
|
+
Structure your CLAUDE.md using the WHAT-WHY-HOW framework:
|
|
198
|
+
|
|
199
|
+
**WHAT** - Project Context: Tech stack, directory structure, architecture
|
|
200
|
+
**WHY** - Purpose: Architectural decisions, why patterns exist
|
|
201
|
+
**HOW** - Workflow: Commands, testing, git workflow, verification steps
|
|
202
|
+
|
|
203
|
+
```markdown
|
|
204
|
+
## Tech Stack
|
|
205
|
+
|
|
206
|
+
- Next.js 15 with App Router
|
|
207
|
+
- PostgreSQL via Prisma ORM
|
|
208
|
+
|
|
209
|
+
## Architecture Decisions
|
|
210
|
+
|
|
211
|
+
- Server Components for data fetching
|
|
212
|
+
- All forms use TanStack Form
|
|
213
|
+
|
|
214
|
+
## Commands
|
|
215
|
+
|
|
216
|
+
- `pnpm dev` - Start dev server
|
|
217
|
+
- `pnpm test:ci` - Run tests
|
|
218
|
+
- `pnpm build` - Production build
|
|
219
|
+
|
|
220
|
+
## Git Workflow
|
|
221
|
+
|
|
222
|
+
- Branch: `feature/name` or `fix/name`
|
|
223
|
+
- Run tests before committing
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
See [references/section-templates.md](references/section-templates.md) for complete templates.
|
|
227
|
+
</content_framework>
|
|
228
|
+
|
|
229
|
+
<emphasis_techniques>
|
|
230
|
+
Claude follows emphasized instructions more reliably. Use these techniques strategically for critical rules.
|
|
231
|
+
|
|
232
|
+
<keyword_hierarchy>
|
|
233
|
+
Use emphasis keywords in order of severity:
|
|
234
|
+
|
|
235
|
+
| Keyword | Use For | Example |
|
|
236
|
+
| ------------- | --------------------- | -------------------------------------------- |
|
|
237
|
+
| **CRITICAL** | Non-negotiable rules | `**CRITICAL**: Never commit secrets` |
|
|
238
|
+
| **NEVER** | Absolute prohibitions | `NEVER: Push directly to main` |
|
|
239
|
+
| **ALWAYS** | Mandatory behaviors | `ALWAYS: Run tests before pushing` |
|
|
240
|
+
| **IMPORTANT** | Significant guidance | `IMPORTANT: Keep components under 300 lines` |
|
|
241
|
+
| **YOU MUST** | Explicit requirements | `YOU MUST: Use TanStack Form for forms` |
|
|
242
|
+
|
|
243
|
+
</keyword_hierarchy>
|
|
244
|
+
|
|
245
|
+
<formatting_patterns>
|
|
246
|
+
**Bold + CRITICAL keyword:**
|
|
247
|
+
|
|
248
|
+
```markdown
|
|
249
|
+
**CRITICAL**: Always run tests before pushing code
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Capitalized emphasis:**
|
|
253
|
+
|
|
254
|
+
```markdown
|
|
255
|
+
IMPORTANT: Do not commit environment variables
|
|
256
|
+
YOU MUST: Follow the git workflow outlined below
|
|
257
|
+
NEVER: Include API keys in code
|
|
258
|
+
ALWAYS: Use TypeScript strict mode
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Strikethrough for forbidden options:**
|
|
262
|
+
|
|
263
|
+
```markdown
|
|
264
|
+
- `pnpm test:ci` - Run tests (use this)
|
|
265
|
+
- ~~`pnpm test`~~ - NEVER use (interactive mode)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Visual markers (use sparingly):**
|
|
269
|
+
|
|
270
|
+
```markdown
|
|
271
|
+
⚠️ WARNING: This affects production data
|
|
272
|
+
🔒 SECURITY: Never commit secrets to git
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
</formatting_patterns>
|
|
276
|
+
|
|
277
|
+
<placement_strategy>
|
|
278
|
+
Order matters. Claude pays more attention to:
|
|
279
|
+
|
|
280
|
+
1. **First items** in each section (put critical rules first)
|
|
281
|
+
2. **Repeated items** across sections (repeat critical rules in context)
|
|
282
|
+
3. **Emphasized items** with CRITICAL/NEVER/ALWAYS keywords
|
|
283
|
+
|
|
284
|
+
Structure your file with critical rules first:
|
|
285
|
+
|
|
286
|
+
```markdown
|
|
287
|
+
## Code Conventions
|
|
288
|
+
|
|
289
|
+
### Critical Rules
|
|
290
|
+
|
|
291
|
+
- **NEVER** commit .env files
|
|
292
|
+
- **ALWAYS** run tests before pushing
|
|
293
|
+
- **CRITICAL**: Use TanStack Form for ALL forms
|
|
294
|
+
|
|
295
|
+
### General Guidelines
|
|
296
|
+
|
|
297
|
+
- Prefer Server Components
|
|
298
|
+
- Keep components under 300 lines
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
</placement_strategy>
|
|
302
|
+
|
|
303
|
+
<repetition_for_emphasis>
|
|
304
|
+
For extremely important rules, repeat in multiple relevant contexts:
|
|
305
|
+
|
|
306
|
+
```markdown
|
|
307
|
+
## Forms
|
|
308
|
+
|
|
309
|
+
**CRITICAL**: Use TanStack Form for ALL forms
|
|
310
|
+
|
|
311
|
+
## Before Editing
|
|
312
|
+
|
|
313
|
+
- **CRITICAL**: Use TanStack Form for forms
|
|
314
|
+
|
|
315
|
+
## Code Review Checklist
|
|
316
|
+
|
|
317
|
+
- [ ] Forms use TanStack Form (**CRITICAL**)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
</repetition_for_emphasis>
|
|
321
|
+
</emphasis_techniques>
|
|
322
|
+
|
|
323
|
+
<writing_effective_instructions>
|
|
324
|
+
<golden_rule>
|
|
325
|
+
Show your CLAUDE.md to someone with minimal project context. If they're confused, Claude will be too.
|
|
326
|
+
</golden_rule>
|
|
327
|
+
|
|
328
|
+
<be_specific>
|
|
329
|
+
Vague instructions cause inconsistent behavior:
|
|
330
|
+
|
|
331
|
+
```markdown
|
|
332
|
+
❌ VAGUE:
|
|
333
|
+
|
|
334
|
+
- Format code properly
|
|
335
|
+
- Write good tests
|
|
336
|
+
- Follow best practices
|
|
337
|
+
|
|
338
|
+
✅ SPECIFIC:
|
|
339
|
+
|
|
340
|
+
- Run `pnpm lint` before committing (Prettier configured)
|
|
341
|
+
- Write tests in `__tests__/` using Vitest
|
|
342
|
+
- Use TanStack Form for all forms (see `src/features/form/`)
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
</be_specific>
|
|
346
|
+
|
|
347
|
+
<show_dont_tell>
|
|
348
|
+
When format matters, show examples:
|
|
349
|
+
|
|
350
|
+
```markdown
|
|
351
|
+
❌ TELLING:
|
|
352
|
+
Use conventional commits with type and description.
|
|
353
|
+
|
|
354
|
+
✅ SHOWING:
|
|
355
|
+
|
|
356
|
+
## Commit Format
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
feat(auth): implement JWT authentication
|
|
360
|
+
|
|
361
|
+
Add login endpoint and token validation
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
Types: feat, fix, refactor, docs, test, chore
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
</show_dont_tell>
|
|
368
|
+
|
|
369
|
+
<eliminate_ambiguity>
|
|
370
|
+
Replace vague phrases with clear directives:
|
|
371
|
+
|
|
372
|
+
| Ambiguous | Clear Alternative |
|
|
373
|
+
| -------------------- | ----------------------------------- |
|
|
374
|
+
| "Try to..." | "Always..." or "Never..." |
|
|
375
|
+
| "Should probably..." | "Must..." or "May optionally..." |
|
|
376
|
+
| "Generally..." | "Always... except when [condition]" |
|
|
377
|
+
| "Consider..." | "If [condition], then [action]" |
|
|
378
|
+
|
|
379
|
+
</eliminate_ambiguity>
|
|
380
|
+
|
|
381
|
+
<define_edge_cases>
|
|
382
|
+
Anticipate questions and answer them:
|
|
383
|
+
|
|
384
|
+
```markdown
|
|
385
|
+
❌ INCOMPLETE:
|
|
386
|
+
Run tests before pushing.
|
|
387
|
+
|
|
388
|
+
✅ COMPLETE:
|
|
389
|
+
|
|
390
|
+
## Testing
|
|
391
|
+
|
|
392
|
+
- Run `pnpm test:ci` before pushing
|
|
393
|
+
- If tests fail, fix before committing
|
|
394
|
+
- New features require tests in `__tests__/`
|
|
395
|
+
- Minimum 80% coverage for new code
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
</define_edge_cases>
|
|
399
|
+
|
|
400
|
+
<provide_decision_criteria>
|
|
401
|
+
When Claude must make choices, give criteria:
|
|
402
|
+
|
|
403
|
+
```markdown
|
|
404
|
+
## Component Choice
|
|
405
|
+
|
|
406
|
+
**Use Server Component when:**
|
|
407
|
+
|
|
408
|
+
- Data fetching only
|
|
409
|
+
- No user interaction needed
|
|
410
|
+
|
|
411
|
+
**Use Client Component when:**
|
|
412
|
+
|
|
413
|
+
- User interaction required
|
|
414
|
+
- Browser APIs needed (localStorage, window)
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
</provide_decision_criteria>
|
|
418
|
+
|
|
419
|
+
<separate_obligation_levels>
|
|
420
|
+
Clearly distinguish requirements from suggestions:
|
|
421
|
+
|
|
422
|
+
```markdown
|
|
423
|
+
## API Development
|
|
424
|
+
|
|
425
|
+
### Must Have
|
|
426
|
+
|
|
427
|
+
- Input validation with Zod
|
|
428
|
+
- Error handling for all endpoints
|
|
429
|
+
|
|
430
|
+
### Nice to Have
|
|
431
|
+
|
|
432
|
+
- Pagination for list endpoints
|
|
433
|
+
- Caching headers
|
|
434
|
+
|
|
435
|
+
### Must Not
|
|
436
|
+
|
|
437
|
+
- Expose internal errors to clients
|
|
438
|
+
- Log sensitive data
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
</separate_obligation_levels>
|
|
442
|
+
</writing_effective_instructions>
|
|
443
|
+
|
|
444
|
+
<size_constraints>
|
|
445
|
+
<limits>
|
|
446
|
+
|
|
447
|
+
- **Ideal**: 100-200 lines maximum
|
|
448
|
+
- **Practical max**: 300 lines before splitting
|
|
449
|
+
- **Universal items**: Under 60 lines
|
|
450
|
+
|
|
451
|
+
**Why these limits matter:**
|
|
452
|
+
|
|
453
|
+
- Claude reliably follows ~150-200 total instructions
|
|
454
|
+
- Claude Code's system prompt uses ~50 instructions
|
|
455
|
+
- Leaves ~100-150 slots for YOUR instructions
|
|
456
|
+
- Irrelevant content degrades instruction-following
|
|
457
|
+
</limits>
|
|
458
|
+
|
|
459
|
+
<scaling_strategy>
|
|
460
|
+
When exceeding limits:
|
|
461
|
+
|
|
462
|
+
1. Move task-specific details to separate files
|
|
463
|
+
2. Link from CLAUDE.md with descriptions
|
|
464
|
+
3. Use progressive disclosure pattern
|
|
465
|
+
|
|
466
|
+
```markdown
|
|
467
|
+
## Detailed Guides
|
|
468
|
+
|
|
469
|
+
- **API Routes**: See [docs/api-patterns.md](docs/api-patterns.md)
|
|
470
|
+
- **Testing**: See [docs/testing-guide.md](docs/testing-guide.md)
|
|
471
|
+
- **Deployment**: See [docs/deployment.md](docs/deployment.md)
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
</scaling_strategy>
|
|
475
|
+
</size_constraints>
|
|
476
|
+
|
|
477
|
+
<imports_feature>
|
|
478
|
+
CLAUDE.md supports importing other markdown files:
|
|
479
|
+
|
|
480
|
+
```markdown
|
|
481
|
+
## External References
|
|
482
|
+
|
|
483
|
+
@docs/coding-standards.md
|
|
484
|
+
@~/.claude/my-global-preferences.md
|
|
485
|
+
@./team-conventions.md
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
<import_rules>
|
|
489
|
+
|
|
490
|
+
- Supports relative and absolute paths
|
|
491
|
+
- Home directory expansion with `~`
|
|
492
|
+
- Recursive imports up to 5 levels deep
|
|
493
|
+
- NOT evaluated inside code blocks or backticks
|
|
494
|
+
</import_rules>
|
|
495
|
+
</imports_feature>
|
|
496
|
+
|
|
497
|
+
<anti_patterns>
|
|
498
|
+
<never_include>
|
|
499
|
+
**Code Style Rules** - Use linters instead (LLMs are expensive, linters are free)
|
|
500
|
+
|
|
501
|
+
**Secrets** - NEVER include API keys, database URLs, tokens, credentials
|
|
502
|
+
|
|
503
|
+
**Too Much Content** - Link to docs instead of embedding 500+ lines
|
|
504
|
+
|
|
505
|
+
**Extensive Code** - Reference files instead (code examples become outdated)
|
|
506
|
+
|
|
507
|
+
**Vague Instructions** - Be specific (see `<writing_effective_instructions>`)
|
|
508
|
+
</never_include>
|
|
509
|
+
|
|
510
|
+
<examples_what_to_avoid>
|
|
511
|
+
|
|
512
|
+
```markdown
|
|
513
|
+
❌ BAD:
|
|
514
|
+
|
|
515
|
+
- Use 2-space indentation (use Prettier instead)
|
|
516
|
+
- DATABASE_URL=postgresql://... (never include secrets)
|
|
517
|
+
- [500 lines of API docs] (link to external file)
|
|
518
|
+
- Format code properly (too vague)
|
|
519
|
+
|
|
520
|
+
✅ GOOD:
|
|
521
|
+
|
|
522
|
+
- ESLint/Prettier configured (see .eslintrc)
|
|
523
|
+
- Credentials in `.env` (never committed)
|
|
524
|
+
- API guide: See [docs/api.md](docs/api.md)
|
|
525
|
+
- Run `pnpm lint` before committing
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
</examples_what_to_avoid>
|
|
529
|
+
</anti_patterns>
|
|
530
|
+
|
|
531
|
+
<examples>
|
|
532
|
+
For complete examples, see reference files:
|
|
533
|
+
|
|
534
|
+
- **Minimal example**: [references/section-templates.md](references/section-templates.md) (templates section)
|
|
535
|
+
- **Comprehensive SaaS**: [references/comprehensive-example.md](references/comprehensive-example.md)
|
|
536
|
+
- **Project-specific**: [references/project-patterns.md](references/project-patterns.md) (Next.js, Express, Python, Monorepo)
|
|
537
|
+
</examples>
|
|
538
|
+
|
|
539
|
+
<workflow>
|
|
540
|
+
<decision_point>
|
|
541
|
+
**ALWAYS ASK FIRST: Storage Strategy**
|
|
542
|
+
|
|
543
|
+
Before creating or updating memory files, ask the user:
|
|
544
|
+
|
|
545
|
+
> Do you want to use a single CLAUDE.md file or split into separate `.claude/rules/` files?
|
|
546
|
+
>
|
|
547
|
+
> **Option 1: Single CLAUDE.md** - All instructions in one file (simpler, best for small projects)
|
|
548
|
+
> **Option 2: Modular .claude/rules/** - Split by concern with optional path-scoping (better for large projects)
|
|
549
|
+
|
|
550
|
+
Use AskUserQuestion to present these options before proceeding.
|
|
551
|
+
|
|
552
|
+
**Decision guide:**
|
|
553
|
+
|
|
554
|
+
- **Choose CLAUDE.md** if: < 100 lines of instructions, simple project, universal rules
|
|
555
|
+
- **Choose .claude/rules/** if: 100+ lines, multiple file types with different rules, team maintains different areas
|
|
556
|
+
</decision_point>
|
|
557
|
+
|
|
558
|
+
<creating_new>
|
|
559
|
+
**Creating New Memory (CLAUDE.md approach)**
|
|
560
|
+
|
|
561
|
+
1. Start with `/init` or minimal template
|
|
562
|
+
2. Add tech stack and commands first
|
|
563
|
+
3. Add conventions as you encounter friction
|
|
564
|
+
4. Test with real tasks
|
|
565
|
+
5. Iterate based on Claude's behavior
|
|
566
|
+
</creating_new>
|
|
567
|
+
|
|
568
|
+
<creating_rules>
|
|
569
|
+
**Creating New Memory (.claude/rules/ approach)**
|
|
570
|
+
|
|
571
|
+
1. Create `.claude/rules/` directory
|
|
572
|
+
2. Start with one file per major concern:
|
|
573
|
+
- `general.md` - Universal project rules
|
|
574
|
+
- `testing.md` - Testing conventions
|
|
575
|
+
- `code-style.md` - Code conventions
|
|
576
|
+
3. Add path-scoped rules as needed:
|
|
577
|
+
```yaml
|
|
578
|
+
---
|
|
579
|
+
paths: src/api/**/*.ts
|
|
580
|
+
---
|
|
581
|
+
# API rules here
|
|
582
|
+
```
|
|
583
|
+
4. Test with real tasks in different file contexts
|
|
584
|
+
5. Split or merge files based on usage patterns
|
|
585
|
+
</creating_rules>
|
|
586
|
+
|
|
587
|
+
<maintaining>
|
|
588
|
+
**Maintaining Memory Files**
|
|
589
|
+
|
|
590
|
+
1. Review quarterly (or when project changes significantly)
|
|
591
|
+
2. Remove outdated instructions
|
|
592
|
+
3. Add patterns that required repeated explanation
|
|
593
|
+
4. Keep CLAUDE.md under 200 lines (or split to .claude/rules/)
|
|
594
|
+
5. Use `#` for quick additions during work
|
|
595
|
+
</maintaining>
|
|
596
|
+
|
|
597
|
+
<migrating_to_rules>
|
|
598
|
+
**Migrating from CLAUDE.md to .claude/rules/**
|
|
599
|
+
|
|
600
|
+
When CLAUDE.md exceeds 200 lines:
|
|
601
|
+
|
|
602
|
+
1. Identify distinct sections (testing, API, frontend, etc.)
|
|
603
|
+
2. Create `.claude/rules/` directory
|
|
604
|
+
3. Move each section to its own file
|
|
605
|
+
4. Add `paths` frontmatter where rules are file-type specific
|
|
606
|
+
5. Keep only universal essentials in CLAUDE.md (or delete it)
|
|
607
|
+
6. Test to ensure rules load correctly
|
|
608
|
+
</migrating_to_rules>
|
|
609
|
+
|
|
610
|
+
<troubleshooting>
|
|
611
|
+
**Common Issues**
|
|
612
|
+
|
|
613
|
+
| Problem | Solution |
|
|
614
|
+
| --------------------------- | ------------------------------------------------ |
|
|
615
|
+
| Claude ignores instructions | Reduce file size, add emphasis (CRITICAL, NEVER) |
|
|
616
|
+
| Context overflow | Use `/clear`, split into .claude/rules/ files |
|
|
617
|
+
| Outdated information | Review quarterly, remove stale content |
|
|
618
|
+
| Instructions conflict | Consolidate, use hierarchy (root vs subtree) |
|
|
619
|
+
| Rules not loading | Check file is `.md`, in correct directory |
|
|
620
|
+
| Path rules not applying | Verify glob pattern matches target files |
|
|
621
|
+
|
|
622
|
+
</troubleshooting>
|
|
623
|
+
</workflow>
|
|
624
|
+
|
|
625
|
+
<advanced_features>
|
|
626
|
+
<local_overrides>
|
|
627
|
+
Use `CLAUDE.local.md` for personal preferences (auto-gitignored):
|
|
628
|
+
|
|
629
|
+
- Personal shortcuts and aliases
|
|
630
|
+
- Editor-specific settings
|
|
631
|
+
- Local testing commands
|
|
632
|
+
</local_overrides>
|
|
633
|
+
|
|
634
|
+
<settings_integration>
|
|
635
|
+
CLAUDE.md works alongside `settings.json`:
|
|
636
|
+
|
|
637
|
+
- `settings.json`: Permissions, allowed tools, environment variables
|
|
638
|
+
- `CLAUDE.md`: Context, conventions, workflow instructions
|
|
639
|
+
</settings_integration>
|
|
640
|
+
|
|
641
|
+
<progressive_disclosure>
|
|
642
|
+
For complex projects, link to detailed docs. Claude only loads when relevant:
|
|
643
|
+
|
|
644
|
+
```markdown
|
|
645
|
+
## References
|
|
646
|
+
|
|
647
|
+
- **Database**: See [docs/database.md](docs/database.md)
|
|
648
|
+
- **API**: See [docs/api.md](docs/api.md)
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
</progressive_disclosure>
|
|
652
|
+
</advanced_features>
|
|
653
|
+
|
|
654
|
+
<success_criteria>
|
|
655
|
+
A well-crafted Claude memory system:
|
|
656
|
+
|
|
657
|
+
**For CLAUDE.md approach:**
|
|
658
|
+
|
|
659
|
+
- Loads in under 200 lines
|
|
660
|
+
- Contains only project-specific context (not general knowledge)
|
|
661
|
+
- Uses emphasis for critical rules (CRITICAL, NEVER, ALWAYS)
|
|
662
|
+
- Avoids code style rules (use linters)
|
|
663
|
+
- Contains NO secrets or credentials
|
|
664
|
+
- Provides clear commands for common tasks
|
|
665
|
+
- Follows WHAT-WHY-HOW structure
|
|
666
|
+
|
|
667
|
+
**For .claude/rules/ approach:**
|
|
668
|
+
|
|
669
|
+
- Each file focused on one concern (testing, API, security, etc.)
|
|
670
|
+
- Path-scoped rules use accurate glob patterns
|
|
671
|
+
- No duplicate rules across files
|
|
672
|
+
- Files organized in logical subdirectories
|
|
673
|
+
- Symlinks used for shared rules across projects
|
|
674
|
+
|
|
675
|
+
**Both approaches:**
|
|
676
|
+
|
|
677
|
+
- Gets updated as project evolves
|
|
678
|
+
- Improves Claude's first-try accuracy on tasks
|
|
679
|
+
- User was asked which approach they prefer before implementation
|
|
680
|
+
</success_criteria>
|
|
681
|
+
|
|
682
|
+
<reference_guides>
|
|
683
|
+
For deeper topics:
|
|
684
|
+
|
|
685
|
+
- **Prompting techniques**: [references/prompting-techniques.md](references/prompting-techniques.md) - Master guide for writing effective instructions, emphasis strategies, clarity techniques
|
|
686
|
+
- **Comprehensive example**: [references/comprehensive-example.md](references/comprehensive-example.md) - Full production SaaS CLAUDE.md
|
|
687
|
+
- **Section templates**: [references/section-templates.md](references/section-templates.md) - Copy-paste templates for each section
|
|
688
|
+
- **Common patterns by project type**: [references/project-patterns.md](references/project-patterns.md) - Next.js, Express, Python, Monorepo patterns
|
|
689
|
+
</reference_guides>
|