aiblueprint-cli 1.4.38 → 1.4.40
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/README.md +32 -0
- package/claude-code-config/skills/meta-claude-memory/SKILL.md +142 -601
- package/claude-code-config/skills/meta-claude-memory/references/optimize-guide.md +300 -0
- package/claude-code-config/skills/meta-subagent-creator/SKILL.md +1 -1
- package/claude-code-config/skills/ralph-loop/SKILL.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,6 +136,38 @@ npx aiblueprint-cli@latest claude-code symlink
|
|
|
136
136
|
- `cc` - Claude Code with permissions skipped
|
|
137
137
|
- `ccc` - Claude Code with continue mode
|
|
138
138
|
|
|
139
|
+
### Skills
|
|
140
|
+
|
|
141
|
+
Install individual skills directly into `~/.claude/skills/`:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Install a single skill
|
|
145
|
+
npx skills add Melvynx/aiblueprint --skill ultrathink
|
|
146
|
+
|
|
147
|
+
# Install multiple skills
|
|
148
|
+
npx skills add Melvynx/aiblueprint --skill claude-memory
|
|
149
|
+
npx skills add Melvynx/aiblueprint --skill fix-errors
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Available skills:**
|
|
153
|
+
|
|
154
|
+
| Skill | Description |
|
|
155
|
+
|-------|-------------|
|
|
156
|
+
| `commit` | Quick commit and push with clean messages |
|
|
157
|
+
| `create-pr` | Auto-generated pull requests |
|
|
158
|
+
| `fix-pr-comments` | Resolve PR review comments |
|
|
159
|
+
| `merge` | Context-aware branch merging |
|
|
160
|
+
| `claude-memory` | CLAUDE.md and .claude/rules management |
|
|
161
|
+
| `prompt-creator` | Expert prompt engineering |
|
|
162
|
+
| `skill-creator` | Guide for creating Claude Code skills |
|
|
163
|
+
| `subagent-creator` | Guide for building subagents |
|
|
164
|
+
| `ralph-loop` | Autonomous AI coding loop |
|
|
165
|
+
| `fix-errors` | Fix ESLint and TypeScript errors |
|
|
166
|
+
| `fix-grammar` | Fix grammar and spelling |
|
|
167
|
+
| `oneshot` | Ultra-fast feature implementation |
|
|
168
|
+
| `ultrathink` | Deep thinking mode for elegant solutions |
|
|
169
|
+
| `apex-free` | APEX methodology (Analyze-Plan-Execute-eXamine) |
|
|
170
|
+
|
|
139
171
|
## 💎 Premium
|
|
140
172
|
|
|
141
173
|
Unlock advanced features at [mlv.sh/claude-cli](https://mlv.sh/claude-cli)
|
|
@@ -1,694 +1,235 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: claude-memory
|
|
3
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]
|
|
4
|
+
argument-hint: [task description or "optimize"]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
<
|
|
8
|
-
|
|
7
|
+
<core_principle>
|
|
8
|
+
Memory files consume tokens from the context window. ~100-150 instruction slots available for your customizations. Keep files minimal — only include what the agent cannot discover on its own.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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>
|
|
10
|
+
**Two approaches:**
|
|
11
|
+
- **CLAUDE.md** — Single file, best for small projects (< 100 lines)
|
|
12
|
+
- **.claude/rules/** — Modular files with optional path-scoping, best for large projects
|
|
13
|
+
</core_principle>
|
|
17
14
|
|
|
18
15
|
<quick_start>
|
|
19
|
-
|
|
20
|
-
Run `/init` in Claude Code to auto-generate a CLAUDE.md with project structure.
|
|
21
|
-
|
|
22
|
-
Or create manually at project root:
|
|
16
|
+
Run `/init` to auto-generate a CLAUDE.md. Or create manually:
|
|
23
17
|
|
|
24
18
|
```markdown
|
|
25
19
|
# Project Name
|
|
26
20
|
|
|
27
21
|
## Tech Stack
|
|
28
|
-
|
|
29
|
-
- [
|
|
30
|
-
- [Key libraries]
|
|
22
|
+
- [Primary framework]
|
|
23
|
+
- [Key non-obvious libraries]
|
|
31
24
|
|
|
32
25
|
## Commands
|
|
33
|
-
|
|
34
|
-
- `npm run dev` - Start development
|
|
26
|
+
- `npm run dev` - Dev server
|
|
35
27
|
- `npm test` - Run tests
|
|
36
|
-
- `npm run build` - Build
|
|
37
|
-
|
|
38
|
-
## Code Conventions
|
|
28
|
+
- `npm run build` - Build
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## Important Context
|
|
43
|
-
|
|
44
|
-
- [1-2 architectural decisions worth knowing]
|
|
30
|
+
## Rules
|
|
31
|
+
- [2-3 critical project-specific rules]
|
|
45
32
|
```
|
|
46
33
|
|
|
47
|
-
|
|
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>
|
|
34
|
+
- Press `#` during a session to add memory items quickly
|
|
35
|
+
- Use `/memory` to open CLAUDE.md in your editor
|
|
56
36
|
</quick_start>
|
|
57
37
|
|
|
58
38
|
<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
39
|
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
| Priority | Location | Scope |
|
|
41
|
+
|----------|----------|-------|
|
|
42
|
+
| 1 (Highest) | Enterprise policy (managed by IT) | All org users |
|
|
43
|
+
| 2 | `./CLAUDE.md` or `./.claude/CLAUDE.md` | Team via git |
|
|
44
|
+
| 2 | `./.claude/rules/*.md` | Team via git |
|
|
45
|
+
| 3 | `~/.claude/CLAUDE.md` | All your projects |
|
|
46
|
+
| 3 | `~/.claude/rules/*.md` | All your projects |
|
|
47
|
+
| 4 (Lowest) | `./CLAUDE.local.md` (auto-gitignored) | Just you |
|
|
74
48
|
|
|
75
|
-
|
|
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:
|
|
49
|
+
Claude recurses UP from current directory, loading all CLAUDE.md files found. Also discovers CLAUDE.md in subtrees when reading files in those directories.
|
|
86
50
|
|
|
51
|
+
**Monorepo strategy:** Root file defines WHEN; subtree files define HOW.
|
|
87
52
|
```
|
|
88
|
-
root/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
│ ├── web/CLAUDE.md # Frontend-specific patterns
|
|
92
|
-
│ └── api/CLAUDE.md # Backend-specific patterns
|
|
93
|
-
└── packages/
|
|
94
|
-
└── shared/CLAUDE.md # Shared library conventions
|
|
53
|
+
root/CLAUDE.md # Universal: tech stack, git workflow
|
|
54
|
+
apps/web/CLAUDE.md # Frontend-specific
|
|
55
|
+
apps/api/CLAUDE.md # Backend-specific
|
|
95
56
|
```
|
|
96
|
-
|
|
97
|
-
Root file defines WHEN to use patterns; subtree files define HOW.
|
|
98
|
-
</monorepo_strategy>
|
|
99
57
|
</file_hierarchy>
|
|
100
58
|
|
|
101
59
|
<rules_directory>
|
|
102
|
-
The `.claude/rules/` directory
|
|
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
|
|
60
|
+
The `.claude/rules/` directory splits instructions into focused markdown files.
|
|
111
61
|
|
|
112
|
-
**Use
|
|
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:
|
|
62
|
+
**Use `.claude/rules/` when:** many concerns, different rules for different file types, team maintains different areas.
|
|
63
|
+
**Use CLAUDE.md when:** small project, universal rules, single source of truth.
|
|
144
64
|
|
|
65
|
+
Path-scoped rules use YAML frontmatter:
|
|
145
66
|
```yaml
|
|
146
67
|
---
|
|
147
68
|
paths:
|
|
148
69
|
- "src/api/**/*.ts"
|
|
149
70
|
---
|
|
150
|
-
# API
|
|
151
|
-
|
|
152
|
-
- All API endpoints must include input validation
|
|
153
|
-
- Use the standard error response format
|
|
71
|
+
# API Rules
|
|
72
|
+
- All endpoints must include input validation
|
|
154
73
|
```
|
|
155
74
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
| Pattern | Matches |
|
|
159
|
-
| ---------------------- | ------------------------------------------ |
|
|
160
|
-
| `**/*.ts` | All TypeScript files in any directory |
|
|
161
|
-
| `src/**/*` | All files under `src/` directory |
|
|
162
|
-
| `src/components/*.tsx` | React components in specific directory |
|
|
163
|
-
| `src/**/*.{ts,tsx}` | TypeScript and TSX files (brace expansion) |
|
|
164
|
-
| `{src,lib}/**/*.ts` | Files in multiple directories |
|
|
165
|
-
|
|
166
|
-
**Syntax note:** The `paths` field must be a YAML array (list format with `-` prefix and quoted strings).
|
|
167
|
-
|
|
168
|
-
**Rules without `paths` frontmatter** load unconditionally for all files.
|
|
169
|
-
</path_scoped_rules>
|
|
170
|
-
|
|
171
|
-
<user_level_rules>
|
|
172
|
-
Create personal rules that apply to all your projects:
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
~/.claude/rules/
|
|
176
|
-
├── preferences.md # Your coding preferences
|
|
177
|
-
├── workflows.md # Your preferred workflows
|
|
178
|
-
└── git.md # Your git conventions
|
|
179
|
-
```
|
|
75
|
+
Supported patterns: `**/*.ts`, `src/**/*`, `src/**/*.{ts,tsx}`, `{src,lib}/**/*.ts`
|
|
180
76
|
|
|
181
|
-
|
|
182
|
-
</user_level_rules>
|
|
77
|
+
Rules without `paths` frontmatter load unconditionally.
|
|
183
78
|
|
|
184
|
-
|
|
185
|
-
Share common rules across multiple projects using symlinks:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
# Symlink a shared rules directory
|
|
189
|
-
ln -s ~/shared-claude-rules .claude/rules/shared
|
|
190
|
-
|
|
191
|
-
# Symlink individual rule files
|
|
192
|
-
ln -s ~/company-standards/security.md .claude/rules/security.md
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
Circular symlinks are detected and handled gracefully.
|
|
196
|
-
</symlinks_support>
|
|
79
|
+
See [references/rules-directory-guide.md](references/rules-directory-guide.md) for complete guide including symlinks, user-level rules, and migration.
|
|
197
80
|
</rules_directory>
|
|
198
81
|
|
|
199
|
-
<
|
|
200
|
-
Structure
|
|
201
|
-
|
|
202
|
-
**WHAT** - Project Context: Tech stack, directory structure, architecture
|
|
203
|
-
**WHY** - Purpose: Architectural decisions, why patterns exist
|
|
204
|
-
**HOW** - Workflow: Commands, testing, git workflow, verification steps
|
|
205
|
-
|
|
206
|
-
```markdown
|
|
207
|
-
## Tech Stack
|
|
208
|
-
|
|
209
|
-
- Next.js 15 with App Router
|
|
210
|
-
- PostgreSQL via Prisma ORM
|
|
211
|
-
|
|
212
|
-
## Architecture Decisions
|
|
213
|
-
|
|
214
|
-
- Server Components for data fetching
|
|
215
|
-
- All forms use TanStack Form
|
|
216
|
-
|
|
217
|
-
## Commands
|
|
218
|
-
|
|
219
|
-
- `pnpm dev` - Start dev server
|
|
220
|
-
- `pnpm test:ci` - Run tests
|
|
221
|
-
- `pnpm build` - Production build
|
|
222
|
-
|
|
223
|
-
## Git Workflow
|
|
224
|
-
|
|
225
|
-
- Branch: `feature/name` or `fix/name`
|
|
226
|
-
- Run tests before committing
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
See [references/section-templates.md](references/section-templates.md) for complete templates.
|
|
230
|
-
</content_framework>
|
|
231
|
-
|
|
232
|
-
<emphasis_techniques>
|
|
233
|
-
Claude follows emphasized instructions more reliably. Use these techniques strategically for critical rules.
|
|
234
|
-
|
|
235
|
-
<keyword_hierarchy>
|
|
236
|
-
Use emphasis keywords in order of severity:
|
|
237
|
-
|
|
238
|
-
| Keyword | Use For | Example |
|
|
239
|
-
| ------------- | --------------------- | -------------------------------------------- |
|
|
240
|
-
| **CRITICAL** | Non-negotiable rules | `**CRITICAL**: Never commit secrets` |
|
|
241
|
-
| **NEVER** | Absolute prohibitions | `NEVER: Push directly to main` |
|
|
242
|
-
| **ALWAYS** | Mandatory behaviors | `ALWAYS: Run tests before pushing` |
|
|
243
|
-
| **IMPORTANT** | Significant guidance | `IMPORTANT: Keep components under 300 lines` |
|
|
244
|
-
| **YOU MUST** | Explicit requirements | `YOU MUST: Use TanStack Form for forms` |
|
|
245
|
-
|
|
246
|
-
</keyword_hierarchy>
|
|
247
|
-
|
|
248
|
-
<formatting_patterns>
|
|
249
|
-
**Bold + CRITICAL keyword:**
|
|
250
|
-
|
|
251
|
-
```markdown
|
|
252
|
-
**CRITICAL**: Always run tests before pushing code
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
**Capitalized emphasis:**
|
|
256
|
-
|
|
257
|
-
```markdown
|
|
258
|
-
IMPORTANT: Do not commit environment variables
|
|
259
|
-
YOU MUST: Follow the git workflow outlined below
|
|
260
|
-
NEVER: Include API keys in code
|
|
261
|
-
ALWAYS: Use TypeScript strict mode
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
**Strikethrough for forbidden options:**
|
|
265
|
-
|
|
266
|
-
```markdown
|
|
267
|
-
- `pnpm test:ci` - Run tests (use this)
|
|
268
|
-
- ~~`pnpm test`~~ - NEVER use (interactive mode)
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
**Visual markers (use sparingly):**
|
|
272
|
-
|
|
273
|
-
```markdown
|
|
274
|
-
⚠️ WARNING: This affects production data
|
|
275
|
-
🔒 SECURITY: Never commit secrets to git
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
</formatting_patterns>
|
|
279
|
-
|
|
280
|
-
<placement_strategy>
|
|
281
|
-
Order matters. Claude pays more attention to:
|
|
282
|
-
|
|
283
|
-
1. **First items** in each section (put critical rules first)
|
|
284
|
-
2. **Repeated items** across sections (repeat critical rules in context)
|
|
285
|
-
3. **Emphasized items** with CRITICAL/NEVER/ALWAYS keywords
|
|
286
|
-
|
|
287
|
-
Structure your file with critical rules first:
|
|
288
|
-
|
|
289
|
-
```markdown
|
|
290
|
-
## Code Conventions
|
|
291
|
-
|
|
292
|
-
### Critical Rules
|
|
293
|
-
|
|
294
|
-
- **NEVER** commit .env files
|
|
295
|
-
- **ALWAYS** run tests before pushing
|
|
296
|
-
- **CRITICAL**: Use TanStack Form for ALL forms
|
|
297
|
-
|
|
298
|
-
### General Guidelines
|
|
299
|
-
|
|
300
|
-
- Prefer Server Components
|
|
301
|
-
- Keep components under 300 lines
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
</placement_strategy>
|
|
305
|
-
|
|
306
|
-
<repetition_for_emphasis>
|
|
307
|
-
For extremely important rules, repeat in multiple relevant contexts:
|
|
308
|
-
|
|
309
|
-
```markdown
|
|
310
|
-
## Forms
|
|
311
|
-
|
|
312
|
-
**CRITICAL**: Use TanStack Form for ALL forms
|
|
313
|
-
|
|
314
|
-
## Before Editing
|
|
315
|
-
|
|
316
|
-
- **CRITICAL**: Use TanStack Form for forms
|
|
317
|
-
|
|
318
|
-
## Code Review Checklist
|
|
319
|
-
|
|
320
|
-
- [ ] Forms use TanStack Form (**CRITICAL**)
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
</repetition_for_emphasis>
|
|
324
|
-
</emphasis_techniques>
|
|
325
|
-
|
|
326
|
-
<writing_effective_instructions>
|
|
327
|
-
<golden_rule>
|
|
328
|
-
Show your CLAUDE.md to someone with minimal project context. If they're confused, Claude will be too.
|
|
329
|
-
</golden_rule>
|
|
330
|
-
|
|
331
|
-
<be_specific>
|
|
332
|
-
Vague instructions cause inconsistent behavior:
|
|
333
|
-
|
|
334
|
-
```markdown
|
|
335
|
-
❌ VAGUE:
|
|
336
|
-
|
|
337
|
-
- Format code properly
|
|
338
|
-
- Write good tests
|
|
339
|
-
- Follow best practices
|
|
340
|
-
|
|
341
|
-
✅ SPECIFIC:
|
|
342
|
-
|
|
343
|
-
- Run `pnpm lint` before committing (Prettier configured)
|
|
344
|
-
- Write tests in `__tests__/` using Vitest
|
|
345
|
-
- Use TanStack Form for all forms (see `src/features/form/`)
|
|
346
|
-
```
|
|
82
|
+
<content_structure>
|
|
83
|
+
Structure CLAUDE.md with only these sections:
|
|
347
84
|
|
|
348
|
-
|
|
85
|
+
1. **Project purpose** (1-3 lines) — What the project is
|
|
86
|
+
2. **Tech stack** (compact) — Only non-obvious technologies
|
|
87
|
+
3. **Commands** — Non-obvious dev, build, and test commands
|
|
88
|
+
4. **Important files** — Architecture-critical, non-obvious files only
|
|
89
|
+
5. **Rules** — Prohibitions and constraints that prevent mistakes (highest-value lines)
|
|
90
|
+
6. **Workflow** (optional) — Only if non-standard
|
|
349
91
|
|
|
350
|
-
|
|
351
|
-
|
|
92
|
+
**Do NOT include:**
|
|
93
|
+
- Repository overviews (agent discovers structure itself)
|
|
94
|
+
- Code style rules (linters enforce these)
|
|
95
|
+
- Generic best practices ("write clean code", "DRY", "SOLID")
|
|
96
|
+
- Redundant specs (copies of config files, env vars, schema descriptions)
|
|
97
|
+
- Marketing/goals (vision statements, KPIs, roadmaps)
|
|
98
|
+
- Verbose explanations (paragraphs where one line suffices)
|
|
352
99
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
100
|
+
See [references/section-templates.md](references/section-templates.md) for ready-to-use templates.
|
|
101
|
+
See [references/project-patterns.md](references/project-patterns.md) for framework-specific patterns.
|
|
102
|
+
</content_structure>
|
|
356
103
|
|
|
357
|
-
|
|
104
|
+
<writing_rules>
|
|
105
|
+
**Golden rule:** If someone with zero project context reads your CLAUDE.md and gets confused, Claude will too.
|
|
358
106
|
|
|
359
|
-
|
|
107
|
+
**Be specific, never vague:**
|
|
360
108
|
```
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
Add login endpoint and token validation
|
|
365
|
-
|
|
366
|
-
```
|
|
367
|
-
Types: feat, fix, refactor, docs, test, chore
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
</show_dont_tell>
|
|
371
|
-
|
|
372
|
-
<eliminate_ambiguity>
|
|
373
|
-
Replace vague phrases with clear directives:
|
|
374
|
-
|
|
375
|
-
| Ambiguous | Clear Alternative |
|
|
376
|
-
| -------------------- | ----------------------------------- |
|
|
377
|
-
| "Try to..." | "Always..." or "Never..." |
|
|
378
|
-
| "Should probably..." | "Must..." or "May optionally..." |
|
|
379
|
-
| "Generally..." | "Always... except when [condition]" |
|
|
380
|
-
| "Consider..." | "If [condition], then [action]" |
|
|
381
|
-
|
|
382
|
-
</eliminate_ambiguity>
|
|
383
|
-
|
|
384
|
-
<define_edge_cases>
|
|
385
|
-
Anticipate questions and answer them:
|
|
386
|
-
|
|
387
|
-
```markdown
|
|
388
|
-
❌ INCOMPLETE:
|
|
389
|
-
Run tests before pushing.
|
|
390
|
-
|
|
391
|
-
✅ COMPLETE:
|
|
392
|
-
|
|
393
|
-
## Testing
|
|
394
|
-
|
|
395
|
-
- Run `pnpm test:ci` before pushing
|
|
396
|
-
- If tests fail, fix before committing
|
|
397
|
-
- New features require tests in `__tests__/`
|
|
398
|
-
- Minimum 80% coverage for new code
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
</define_edge_cases>
|
|
402
|
-
|
|
403
|
-
<provide_decision_criteria>
|
|
404
|
-
When Claude must make choices, give criteria:
|
|
405
|
-
|
|
406
|
-
```markdown
|
|
407
|
-
## Component Choice
|
|
408
|
-
|
|
409
|
-
**Use Server Component when:**
|
|
410
|
-
|
|
411
|
-
- Data fetching only
|
|
412
|
-
- No user interaction needed
|
|
413
|
-
|
|
414
|
-
**Use Client Component when:**
|
|
415
|
-
|
|
416
|
-
- User interaction required
|
|
417
|
-
- Browser APIs needed (localStorage, window)
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
</provide_decision_criteria>
|
|
421
|
-
|
|
422
|
-
<separate_obligation_levels>
|
|
423
|
-
Clearly distinguish requirements from suggestions:
|
|
424
|
-
|
|
425
|
-
```markdown
|
|
426
|
-
## API Development
|
|
427
|
-
|
|
428
|
-
### Must Have
|
|
429
|
-
|
|
430
|
-
- Input validation with Zod
|
|
431
|
-
- Error handling for all endpoints
|
|
432
|
-
|
|
433
|
-
### Nice to Have
|
|
434
|
-
|
|
435
|
-
- Pagination for list endpoints
|
|
436
|
-
- Caching headers
|
|
437
|
-
|
|
438
|
-
### Must Not
|
|
439
|
-
|
|
440
|
-
- Expose internal errors to clients
|
|
441
|
-
- Log sensitive data
|
|
109
|
+
❌ "Format code properly" / "Write good tests" / "Follow best practices"
|
|
110
|
+
✅ "Run `pnpm lint` before committing" / "Tests in `__tests__/` using Vitest"
|
|
442
111
|
```
|
|
443
112
|
|
|
444
|
-
|
|
445
|
-
</writing_effective_instructions>
|
|
446
|
-
|
|
447
|
-
<size_constraints>
|
|
448
|
-
<limits>
|
|
449
|
-
|
|
450
|
-
- **Ideal**: 100-200 lines maximum
|
|
451
|
-
- **Practical max**: 300 lines before splitting
|
|
452
|
-
- **Universal items**: Under 60 lines
|
|
453
|
-
|
|
454
|
-
**Why these limits matter:**
|
|
455
|
-
|
|
456
|
-
- Claude reliably follows ~150-200 total instructions
|
|
457
|
-
- Claude Code's system prompt uses ~50 instructions
|
|
458
|
-
- Leaves ~100-150 slots for YOUR instructions
|
|
459
|
-
- Irrelevant content degrades instruction-following
|
|
460
|
-
</limits>
|
|
461
|
-
|
|
462
|
-
<scaling_strategy>
|
|
463
|
-
When exceeding limits:
|
|
464
|
-
|
|
465
|
-
1. Move task-specific details to separate files
|
|
466
|
-
2. Link from CLAUDE.md with descriptions
|
|
467
|
-
3. Use progressive disclosure pattern
|
|
468
|
-
|
|
469
|
-
```markdown
|
|
470
|
-
## Detailed Guides
|
|
471
|
-
|
|
472
|
-
- **API Routes**: See [docs/api-patterns.md](docs/api-patterns.md)
|
|
473
|
-
- **Testing**: See [docs/testing-guide.md](docs/testing-guide.md)
|
|
474
|
-
- **Deployment**: See [docs/deployment.md](docs/deployment.md)
|
|
113
|
+
**Prohibitions > positive guidance:**
|
|
475
114
|
```
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
</size_constraints>
|
|
479
|
-
|
|
480
|
-
<imports_feature>
|
|
481
|
-
CLAUDE.md supports importing other markdown files:
|
|
482
|
-
|
|
483
|
-
```markdown
|
|
484
|
-
## External References
|
|
485
|
-
|
|
486
|
-
@docs/coding-standards.md
|
|
487
|
-
@~/.claude/my-global-preferences.md
|
|
488
|
-
@./team-conventions.md
|
|
115
|
+
❌ "Try to use TanStack Form for forms"
|
|
116
|
+
✅ "NEVER use native form/useState for forms — ALWAYS use TanStack Form"
|
|
489
117
|
```
|
|
490
118
|
|
|
491
|
-
|
|
119
|
+
**Show, don't tell:** When format matters, show a concrete example (3-5 lines max).
|
|
492
120
|
|
|
493
|
-
|
|
494
|
-
-
|
|
495
|
-
-
|
|
496
|
-
- NOT evaluated inside code blocks or backticks
|
|
497
|
-
</import_rules>
|
|
498
|
-
</imports_feature>
|
|
121
|
+
**Emphasis hierarchy:** CRITICAL > NEVER > ALWAYS > IMPORTANT > YOU MUST
|
|
122
|
+
- Put critical rules **first** in each section
|
|
123
|
+
- Use **bold + keyword** for non-negotiable rules: `**CRITICAL**: Never commit secrets`
|
|
499
124
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
**Code Style Rules** - Use linters instead (LLMs are expensive, linters are free)
|
|
125
|
+
See [references/prompting-techniques.md](references/prompting-techniques.md) for advanced techniques.
|
|
126
|
+
</writing_rules>
|
|
503
127
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
**Extensive Code** - Reference files instead (code examples become outdated)
|
|
509
|
-
|
|
510
|
-
**Vague Instructions** - Be specific (see `<writing_effective_instructions>`)
|
|
511
|
-
</never_include>
|
|
512
|
-
|
|
513
|
-
<examples_what_to_avoid>
|
|
128
|
+
<size_limits>
|
|
129
|
+
- **Ideal:** < 100 lines
|
|
130
|
+
- **Maximum:** 150 lines before performance degrades
|
|
131
|
+
- **Over 200 lines:** directives start getting lost
|
|
514
132
|
|
|
133
|
+
When exceeding limits, split into `.claude/rules/` files or link to separate docs:
|
|
515
134
|
```markdown
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
- Use 2-space indentation (use Prettier instead)
|
|
519
|
-
- DATABASE_URL=postgresql://... (never include secrets)
|
|
520
|
-
- [500 lines of API docs] (link to external file)
|
|
521
|
-
- Format code properly (too vague)
|
|
522
|
-
|
|
523
|
-
✅ GOOD:
|
|
524
|
-
|
|
525
|
-
- ESLint/Prettier configured (see .eslintrc)
|
|
526
|
-
- Credentials in `.env` (never committed)
|
|
527
|
-
- API guide: See [docs/api.md](docs/api.md)
|
|
528
|
-
- Run `pnpm lint` before committing
|
|
135
|
+
- **API patterns**: See [docs/api-patterns.md](docs/api-patterns.md)
|
|
136
|
+
- **Testing guide**: See [docs/testing-guide.md](docs/testing-guide.md)
|
|
529
137
|
```
|
|
530
138
|
|
|
531
|
-
|
|
532
|
-
</
|
|
533
|
-
|
|
534
|
-
<examples>
|
|
535
|
-
For complete examples, see reference files:
|
|
536
|
-
|
|
537
|
-
- **Minimal example**: [references/section-templates.md](references/section-templates.md) (templates section)
|
|
538
|
-
- **Comprehensive SaaS**: [references/comprehensive-example.md](references/comprehensive-example.md)
|
|
539
|
-
- **Project-specific**: [references/project-patterns.md](references/project-patterns.md) (Next.js, Express, Python, Monorepo)
|
|
540
|
-
</examples>
|
|
139
|
+
CLAUDE.md supports importing: `@docs/coding-standards.md` (relative/absolute paths, `~` expansion, up to 5 levels deep, not evaluated inside code blocks).
|
|
140
|
+
</size_limits>
|
|
541
141
|
|
|
542
142
|
<workflow>
|
|
543
|
-
<decision_point>
|
|
544
143
|
**ALWAYS ASK FIRST: Storage Strategy**
|
|
545
144
|
|
|
546
|
-
Before creating or updating memory files,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
>
|
|
550
|
-
> **Option 1: Single CLAUDE.md** - All instructions in one file (simpler, best for small projects)
|
|
551
|
-
> **Option 2: Modular .claude/rules/** - Split by concern with optional path-scoping (better for large projects)
|
|
552
|
-
|
|
553
|
-
Use AskUserQuestion to present these options before proceeding.
|
|
554
|
-
|
|
555
|
-
**Decision guide:**
|
|
556
|
-
|
|
557
|
-
- **Choose CLAUDE.md** if: < 100 lines of instructions, simple project, universal rules
|
|
558
|
-
- **Choose .claude/rules/** if: 100+ lines, multiple file types with different rules, team maintains different areas
|
|
559
|
-
</decision_point>
|
|
560
|
-
|
|
561
|
-
<creating_new>
|
|
562
|
-
**Creating New Memory (CLAUDE.md approach)**
|
|
145
|
+
Before creating or updating memory files, use AskUserQuestion:
|
|
146
|
+
- **Option 1: Single CLAUDE.md** — < 100 lines, simple project, universal rules
|
|
147
|
+
- **Option 2: Modular .claude/rules/** — 100+ lines, different rules for different files
|
|
563
148
|
|
|
149
|
+
**Creating new memory:**
|
|
564
150
|
1. Start with `/init` or minimal template
|
|
565
151
|
2. Add tech stack and commands first
|
|
566
|
-
3. Add
|
|
567
|
-
4. Test with real tasks
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
<creating_rules>
|
|
572
|
-
**Creating New Memory (.claude/rules/ approach)**
|
|
573
|
-
|
|
574
|
-
1. Create `.claude/rules/` directory
|
|
575
|
-
2. Start with one file per major concern:
|
|
576
|
-
- `general.md` - Universal project rules
|
|
577
|
-
- `testing.md` - Testing conventions
|
|
578
|
-
- `code-style.md` - Code conventions
|
|
579
|
-
3. Add path-scoped rules as needed:
|
|
580
|
-
```yaml
|
|
581
|
-
---
|
|
582
|
-
paths:
|
|
583
|
-
- "src/api/**/*.ts"
|
|
584
|
-
---
|
|
585
|
-
# API rules here
|
|
586
|
-
```
|
|
587
|
-
4. Test with real tasks in different file contexts
|
|
588
|
-
5. Split or merge files based on usage patterns
|
|
589
|
-
</creating_rules>
|
|
590
|
-
|
|
591
|
-
<maintaining>
|
|
592
|
-
**Maintaining Memory Files**
|
|
593
|
-
|
|
594
|
-
1. Review quarterly (or when project changes significantly)
|
|
152
|
+
3. Add rules only as you encounter friction
|
|
153
|
+
4. Test with real tasks, iterate based on Claude's behavior
|
|
154
|
+
|
|
155
|
+
**Maintaining:**
|
|
156
|
+
1. Review quarterly or when project changes significantly
|
|
595
157
|
2. Remove outdated instructions
|
|
596
158
|
3. Add patterns that required repeated explanation
|
|
597
|
-
4.
|
|
598
|
-
5. Use `#` for quick additions during work
|
|
599
|
-
</maintaining>
|
|
159
|
+
4. Use `#` for quick additions during work
|
|
600
160
|
|
|
601
|
-
|
|
602
|
-
**Migrating from CLAUDE.md to .claude/rules/**
|
|
161
|
+
**Troubleshooting:**
|
|
603
162
|
|
|
604
|
-
|
|
163
|
+
| Problem | Solution |
|
|
164
|
+
|---------|----------|
|
|
165
|
+
| Claude ignores instructions | Reduce file size, add emphasis (CRITICAL, NEVER) |
|
|
166
|
+
| Context overflow | Use `/clear`, split into .claude/rules/ |
|
|
167
|
+
| Instructions conflict | Consolidate, use hierarchy (root vs subtree) |
|
|
168
|
+
| Path rules not applying | Verify glob pattern matches target files |
|
|
169
|
+
</workflow>
|
|
605
170
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
3. Move each section to its own file
|
|
609
|
-
4. Add `paths` frontmatter where rules are file-type specific
|
|
610
|
-
5. Keep only universal essentials in CLAUDE.md (or delete it)
|
|
611
|
-
6. Test to ensure rules load correctly
|
|
612
|
-
</migrating_to_rules>
|
|
171
|
+
<optimize_workflow>
|
|
172
|
+
## `/claude-memory optimize` — Deep CLAUDE.md Cleanup
|
|
613
173
|
|
|
614
|
-
|
|
615
|
-
**Common Issues**
|
|
174
|
+
When the user argument contains "optimize", execute this workflow.
|
|
616
175
|
|
|
617
|
-
|
|
618
|
-
| --------------------------- | ------------------------------------------------ |
|
|
619
|
-
| Claude ignores instructions | Reduce file size, add emphasis (CRITICAL, NEVER) |
|
|
620
|
-
| Context overflow | Use `/clear`, split into .claude/rules/ files |
|
|
621
|
-
| Outdated information | Review quarterly, remove stale content |
|
|
622
|
-
| Instructions conflict | Consolidate, use hierarchy (root vs subtree) |
|
|
623
|
-
| Rules not loading | Check file is `.md`, in correct directory |
|
|
624
|
-
| Path rules not applying | Verify glob pattern matches target files |
|
|
176
|
+
**CRITICAL — Step 0 is MANDATORY. Do NOT skip it. Do NOT start optimizing without reading the guide first.**
|
|
625
177
|
|
|
626
|
-
|
|
627
|
-
</workflow>
|
|
178
|
+
### Step 0: Read the optimization guide (REQUIRED FIRST)
|
|
628
179
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
Use `CLAUDE.local.md` for personal preferences (auto-gitignored):
|
|
180
|
+
YOU MUST use the Read tool on `{SKILL_PATH}/references/optimize-guide.md` BEFORE doing anything else.
|
|
181
|
+
This file contains the research data (ETH Zurich study), the 6 bloat categories with specific examples, target metrics, and before/after examples. Without reading it, you will miss removal criteria and produce a subpar optimization.
|
|
632
182
|
|
|
633
|
-
|
|
634
|
-
- Editor-specific settings
|
|
635
|
-
- Local testing commands
|
|
636
|
-
</local_overrides>
|
|
183
|
+
### Step 1: Inventory
|
|
637
184
|
|
|
638
|
-
|
|
639
|
-
CLAUDE.md works alongside `settings.json`:
|
|
185
|
+
Read every CLAUDE.md, CLAUDE.local.md, and `.claude/rules/*.md` in the project. Count total lines.
|
|
640
186
|
|
|
641
|
-
|
|
642
|
-
- `CLAUDE.md`: Context, conventions, workflow instructions
|
|
643
|
-
</settings_integration>
|
|
187
|
+
### Step 2: Read linter configs
|
|
644
188
|
|
|
645
|
-
|
|
646
|
-
For complex projects, link to detailed docs. Claude only loads when relevant:
|
|
189
|
+
Read ESLint/Biome/Prettier/TypeScript configs. Any CLAUDE.md line duplicating an enforced rule → delete.
|
|
647
190
|
|
|
648
|
-
|
|
649
|
-
## References
|
|
191
|
+
### Step 3: Apply the 6 bloat categories from the guide
|
|
650
192
|
|
|
651
|
-
|
|
652
|
-
- **API**: See [docs/api.md](docs/api.md)
|
|
653
|
-
```
|
|
193
|
+
For each line ask: "Can the agent discover this by reading the project, or does a linter enforce this?" If yes → delete.
|
|
654
194
|
|
|
655
|
-
|
|
656
|
-
|
|
195
|
+
Remove everything matching:
|
|
196
|
+
1. Linter-enforced rules (ESLint, Prettier, Biome, TypeScript strict)
|
|
197
|
+
2. Marketing / goals / vision (zero code value)
|
|
198
|
+
3. Obvious info the agent discovers itself (directory structure, framework defaults, deps from package.json)
|
|
199
|
+
4. Verbose explanations (paragraphs where 1 line suffices, tutorials, history)
|
|
200
|
+
5. Redundant specs (copies of config files, schema descriptions, env var lists)
|
|
201
|
+
6. Generic best practices ("write clean code", "DRY", "SOLID")
|
|
657
202
|
|
|
658
|
-
|
|
659
|
-
A well-crafted Claude memory system:
|
|
203
|
+
### Step 4: Keep only essentials
|
|
660
204
|
|
|
661
|
-
|
|
205
|
+
- Project purpose (1-3 lines)
|
|
206
|
+
- Tech stack (compact, non-obvious only)
|
|
207
|
+
- Core commands (non-obvious only)
|
|
208
|
+
- Testing commands
|
|
209
|
+
- Important files (non-obvious only)
|
|
210
|
+
- Project-specific rules (prohibitions + constraints)
|
|
211
|
+
- Workflow (only if non-standard)
|
|
662
212
|
|
|
663
|
-
|
|
664
|
-
- Contains only project-specific context (not general knowledge)
|
|
665
|
-
- Uses emphasis for critical rules (CRITICAL, NEVER, ALWAYS)
|
|
666
|
-
- Avoids code style rules (use linters)
|
|
667
|
-
- Contains NO secrets or credentials
|
|
668
|
-
- Provides clear commands for common tasks
|
|
669
|
-
- Follows WHAT-WHY-HOW structure
|
|
213
|
+
### Step 5: Compress
|
|
670
214
|
|
|
671
|
-
|
|
215
|
+
- Paragraphs → bullet points
|
|
216
|
+
- 3-line rules → 1-line rules
|
|
217
|
+
- Zero filler words ("In order to", "It's important to note that")
|
|
218
|
+
- Merge related items
|
|
672
219
|
|
|
673
|
-
|
|
674
|
-
- Path-scoped rules use accurate glob patterns
|
|
675
|
-
- No duplicate rules across files
|
|
676
|
-
- Files organized in logical subdirectories
|
|
677
|
-
- Symlinks used for shared rules across projects
|
|
220
|
+
### Step 6: Present diff
|
|
678
221
|
|
|
679
|
-
|
|
222
|
+
Show before/after with line counts. For each removal, cite which bloat category it falls under.
|
|
223
|
+
Let user approve before applying changes.
|
|
680
224
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
- User was asked which approach they prefer before implementation
|
|
684
|
-
</success_criteria>
|
|
225
|
+
**Target:** < 100 lines ideal, < 150 max.
|
|
226
|
+
</optimize_workflow>
|
|
685
227
|
|
|
686
228
|
<reference_guides>
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
- **
|
|
690
|
-
- **
|
|
691
|
-
- **Comprehensive example**: [references/comprehensive-example.md](references/comprehensive-example.md)
|
|
692
|
-
- **
|
|
693
|
-
|
|
694
|
-
</reference_guides>
|
|
229
|
+
- **Optimization guide**: [references/optimize-guide.md](references/optimize-guide.md) — Research-backed bloat checklist, 6 removal categories, before/after examples
|
|
230
|
+
- **Rules directory**: [references/rules-directory-guide.md](references/rules-directory-guide.md) — Complete .claude/rules/ guide with path-scoping, YAML syntax, symlinks, migration
|
|
231
|
+
- **Prompting techniques**: [references/prompting-techniques.md](references/prompting-techniques.md) — Emphasis strategies, clarity techniques, constraint patterns
|
|
232
|
+
- **Section templates**: [references/section-templates.md](references/section-templates.md) — Copy-paste templates for each section type
|
|
233
|
+
- **Comprehensive example**: [references/comprehensive-example.md](references/comprehensive-example.md) — Full production SaaS CLAUDE.md
|
|
234
|
+
- **Project patterns**: [references/project-patterns.md](references/project-patterns.md) — Next.js, Express, Python, Monorepo patterns
|
|
235
|
+
</reference_guides>
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# CLAUDE.md Optimization Guide
|
|
2
|
+
|
|
3
|
+
## Research Foundation
|
|
4
|
+
|
|
5
|
+
Based on "Evaluating AGENTS.md" (ETH Zurich, arXiv 2602.11988, Feb 2026) — the first rigorous study of repository context files for coding agents:
|
|
6
|
+
|
|
7
|
+
**Key findings:**
|
|
8
|
+
- Context files with unnecessary specs **reduce** task success rates vs no context at all
|
|
9
|
+
- LLM-generated context files reduced success by 0.5-2% and increased costs 20-23%
|
|
10
|
+
- Developer-written **minimal** files improved performance by 4%
|
|
11
|
+
- Repository overviews are useless — agents discover structure themselves
|
|
12
|
+
- Removing redundant documentation improved performance by 2.7%
|
|
13
|
+
- Instructions ARE reliably followed (mentioned tools used 1.6-2.5x more) — the problem is **what** you instruct, not **whether** it's followed
|
|
14
|
+
- Files averaging 641 words performed; files with unnecessary complexity degraded
|
|
15
|
+
|
|
16
|
+
**The paradox:** More instructions = worse performance. The agent follows your instructions faithfully, but unnecessary constraints make the task harder.
|
|
17
|
+
|
|
18
|
+
**Conclusion:** Write only what the agent cannot discover on its own. Everything else is noise that actively hurts.
|
|
19
|
+
|
|
20
|
+
## Additional Metrics (SFEIR Institute, Feb 2026)
|
|
21
|
+
|
|
22
|
+
- Files over 200 lines: 30% of directives silently lost
|
|
23
|
+
- Vague instructions: +45% manual corrections needed
|
|
24
|
+
- Explicit prohibitions: more effective than positive guidance
|
|
25
|
+
- Modular `.claude/rules/` with path-scoping: 40% noise reduction, 35% relevance increase
|
|
26
|
+
- Documented test/build commands: 30% reduction in back-and-forth
|
|
27
|
+
- 3-5 concrete code examples: 40% reduction in correction requests
|
|
28
|
+
|
|
29
|
+
## The 7 Essential Sections
|
|
30
|
+
|
|
31
|
+
Every optimized CLAUDE.md should contain ONLY these. Nothing else.
|
|
32
|
+
|
|
33
|
+
### 1. Project Purpose (1-3 lines)
|
|
34
|
+
What the project is. One sentence is ideal. The agent doesn't need your vision or goals.
|
|
35
|
+
|
|
36
|
+
```markdown
|
|
37
|
+
# MyApp
|
|
38
|
+
SaaS invoice management platform with Stripe billing.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Kill:** Vision statements, goals, target audience, roadmaps, business metrics, "why we built this."
|
|
42
|
+
|
|
43
|
+
### 2. Tech Stack (compact)
|
|
44
|
+
Only technologies the agent can't detect from package.json/config files.
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
## Tech Stack
|
|
48
|
+
- Next.js 15 (App Router) + TypeScript
|
|
49
|
+
- Prisma + PostgreSQL
|
|
50
|
+
- TanStack Form + Zod
|
|
51
|
+
- Tailwind + shadcn/ui
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Kill:** Version numbers from lockfiles, obvious deps (React in Next.js), descriptions of what each lib does.
|
|
55
|
+
|
|
56
|
+
### 3. Core Commands
|
|
57
|
+
Commands the agent needs. Only non-obvious ones.
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
## Commands
|
|
61
|
+
- `pnpm dev` - Dev server
|
|
62
|
+
- `pnpm build` - Production build
|
|
63
|
+
- `pnpm db:push` - Push schema changes
|
|
64
|
+
- `pnpm db:seed` - Seed database
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Kill:** `pnpm install` (obvious), `pnpm start` (obvious), self-explanatory package.json scripts.
|
|
68
|
+
|
|
69
|
+
### 4. Testing Commands
|
|
70
|
+
How to run tests. The research shows documented test commands reduce back-and-forth 30%.
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
## Testing
|
|
74
|
+
- `pnpm test` - Run all tests
|
|
75
|
+
- `pnpm test:e2e` - E2E tests (needs running dev server)
|
|
76
|
+
- Single file: `pnpm vitest run path/to/file.test.ts`
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 5. Important Files
|
|
80
|
+
Only files the agent wouldn't find naturally. Architecture-critical, non-obvious files.
|
|
81
|
+
|
|
82
|
+
```markdown
|
|
83
|
+
## Important Files
|
|
84
|
+
- `src/lib/auth.ts` - Auth config (Better Auth)
|
|
85
|
+
- `src/lib/safe-actions.ts` - Server action wrapper
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Kill:** `package.json`, `tsconfig.json`, `next.config.js`, any standard framework file the agent already knows.
|
|
89
|
+
|
|
90
|
+
### 6. Project-Specific Rules (Highest Value)
|
|
91
|
+
Prohibitions and constraints that prevent recurring mistakes. Research shows explicit prohibitions are more effective than positive guidance.
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
## Rules
|
|
95
|
+
- NEVER import from `@/features/*/server` in client components
|
|
96
|
+
- ALWAYS use `safe-action` wrapper for server actions
|
|
97
|
+
- Use TanStack Form for ALL forms (not native form/useState)
|
|
98
|
+
- Errors must use `ActionError` not `throw new Error`
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**These are the most valuable lines in the entire file.** Each rule should encode a mistake that was made before and must not be repeated.
|
|
102
|
+
|
|
103
|
+
### 7. Workflow (optional)
|
|
104
|
+
Only if the project has a non-standard workflow.
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
## Workflow
|
|
108
|
+
- Start with plan mode for features touching 3+ files
|
|
109
|
+
- Run `pnpm build` after changes (strict TypeScript)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Kill:** Standard git workflows, obvious PR processes.
|
|
113
|
+
|
|
114
|
+
## The 6 Bloat Categories (What to Remove)
|
|
115
|
+
|
|
116
|
+
### Category 1: Linter-Enforced Rules
|
|
117
|
+
The research is clear: if a tool enforces it, the context file shouldn't mention it.
|
|
118
|
+
|
|
119
|
+
Delete anything ESLint, Prettier, Biome, or TypeScript strict mode handles:
|
|
120
|
+
- Indentation, semicolons, trailing commas, quote style
|
|
121
|
+
- Import ordering, max line length
|
|
122
|
+
- Naming conventions in ESLint rules
|
|
123
|
+
- "Use const over let" / "Prefer arrow functions"
|
|
124
|
+
- "No unused variables" / "No any type"
|
|
125
|
+
- Type annotation rules
|
|
126
|
+
|
|
127
|
+
**Test:** Does `.eslintrc`, `biome.json`, or `tsconfig.json` enforce this? → Delete from CLAUDE.md.
|
|
128
|
+
|
|
129
|
+
### Category 2: Repository Overviews
|
|
130
|
+
The paper proved these are useless — agents discover repo structure themselves with zero performance benefit:
|
|
131
|
+
|
|
132
|
+
- Directory structure descriptions (agent can `ls`)
|
|
133
|
+
- Folder explanations (`src/components/ contains React components`)
|
|
134
|
+
- Architecture diagrams in text
|
|
135
|
+
- "This is a monorepo" (agent sees `packages/` or `apps/`)
|
|
136
|
+
- Framework defaults ("Next.js uses file-based routing")
|
|
137
|
+
- Feature descriptions ("The auth module handles login")
|
|
138
|
+
|
|
139
|
+
### Category 3: Marketing / Goals / Vision
|
|
140
|
+
Zero value for code generation:
|
|
141
|
+
- Mission statements, vision, goals
|
|
142
|
+
- Target audience, competitive positioning
|
|
143
|
+
- Feature roadmaps, business metrics
|
|
144
|
+
- "Why we built this" narratives
|
|
145
|
+
|
|
146
|
+
### Category 4: Redundant Specifications
|
|
147
|
+
The paper found removing redundant docs improved performance by 2.7%:
|
|
148
|
+
|
|
149
|
+
- Copy of TypeScript config settings
|
|
150
|
+
- Copy of ESLint config
|
|
151
|
+
- Environment variable names (agent reads `.env.example`)
|
|
152
|
+
- Database schema prose (agent reads `schema.prisma`)
|
|
153
|
+
- API route docs (agent reads the code)
|
|
154
|
+
- Component prop docs (TypeScript types handle this)
|
|
155
|
+
- README content repeated in CLAUDE.md
|
|
156
|
+
|
|
157
|
+
### Category 5: Verbose Explanations
|
|
158
|
+
Multi-paragraph explanations actively hurt — they consume context budget and add complexity:
|
|
159
|
+
|
|
160
|
+
- Paragraphs explaining why a pattern exists (one line is enough)
|
|
161
|
+
- Tutorials, onboarding guides, historical context
|
|
162
|
+
- Code examples longer than 5 lines (reference the file instead)
|
|
163
|
+
- Filler phrases: "In order to", "It's important to note that", "Please make sure to"
|
|
164
|
+
|
|
165
|
+
### Category 6: Generic Best Practices
|
|
166
|
+
The agent already knows these. Adding them wastes instruction slots:
|
|
167
|
+
- "Write clean code" / "Follow SOLID principles"
|
|
168
|
+
- "Write tests" (without specific commands)
|
|
169
|
+
- "Use meaningful variable names" / "Keep functions small"
|
|
170
|
+
- "DRY principle" / "Handle errors properly"
|
|
171
|
+
|
|
172
|
+
## Optimization Process
|
|
173
|
+
|
|
174
|
+
### Step 1: Inventory
|
|
175
|
+
Read every CLAUDE.md and `.claude/rules/*.md` in the project.
|
|
176
|
+
Count total lines across all files.
|
|
177
|
+
|
|
178
|
+
### Step 2: Cross-check linter configs
|
|
179
|
+
Read ESLint/Biome/Prettier/TypeScript configs. Any CLAUDE.md line duplicating an enforced rule → delete.
|
|
180
|
+
|
|
181
|
+
### Step 3: Apply the 6 bloat categories
|
|
182
|
+
For each line ask: **"Can the agent discover this by reading the project, or does a linter enforce this?"**
|
|
183
|
+
If yes → delete.
|
|
184
|
+
|
|
185
|
+
### Step 4: Check for redundancy
|
|
186
|
+
- Information duplicated across files → consolidate
|
|
187
|
+
- Information in README also in CLAUDE.md → remove from CLAUDE.md
|
|
188
|
+
- Information derivable from config files → remove
|
|
189
|
+
|
|
190
|
+
### Step 5: Compress survivors
|
|
191
|
+
- Paragraphs → bullet points
|
|
192
|
+
- 3-line rules → 1-line rules
|
|
193
|
+
- Remove all filler words
|
|
194
|
+
- Merge related items
|
|
195
|
+
|
|
196
|
+
### Step 6: Verify essentials remain
|
|
197
|
+
- [ ] Project purpose (1-3 lines)
|
|
198
|
+
- [ ] Tech stack (compact, non-obvious only)
|
|
199
|
+
- [ ] Core commands (non-obvious only)
|
|
200
|
+
- [ ] Testing commands
|
|
201
|
+
- [ ] Important files (non-obvious only)
|
|
202
|
+
- [ ] Project-specific rules (prohibitions + constraints)
|
|
203
|
+
- [ ] Workflow (only if non-standard)
|
|
204
|
+
|
|
205
|
+
### Step 7: Present changes
|
|
206
|
+
Show before/after with line counts. Explain what was removed and why (cite category). Let user approve.
|
|
207
|
+
|
|
208
|
+
## Target Metrics
|
|
209
|
+
|
|
210
|
+
| Metric | Target | Research Basis |
|
|
211
|
+
|--------|--------|----------------|
|
|
212
|
+
| Total lines | < 100 ideal, < 150 max | >200 lines = 30% directive loss |
|
|
213
|
+
| Sections | 5-7 | Minimal requirements only |
|
|
214
|
+
| Filler words | 0 | +45% corrections when vague |
|
|
215
|
+
| Linter-duplicate rules | 0 | Already enforced = wasted tokens |
|
|
216
|
+
| Marketing/goals text | 0 | Zero value for code generation |
|
|
217
|
+
| Generic best practices | 0 | Agent already knows them |
|
|
218
|
+
| Repository overviews | 0 | Research: zero navigation benefit |
|
|
219
|
+
|
|
220
|
+
## Before vs After Example
|
|
221
|
+
|
|
222
|
+
### Before (bloated — 47 lines, typical file is 200+)
|
|
223
|
+
```markdown
|
|
224
|
+
# MyApp - AI-Powered Invoice Management
|
|
225
|
+
|
|
226
|
+
## Vision
|
|
227
|
+
MyApp aims to simplify invoicing for small businesses worldwide.
|
|
228
|
+
|
|
229
|
+
## Goals
|
|
230
|
+
- Reach 10,000 users by Q3 2025
|
|
231
|
+
- Achieve 99.9% uptime
|
|
232
|
+
|
|
233
|
+
## Tech Stack
|
|
234
|
+
- Next.js 15 with App Router for server-side rendering
|
|
235
|
+
- React 19 for building user interfaces
|
|
236
|
+
- TypeScript for type safety
|
|
237
|
+
- Prisma ORM for database access
|
|
238
|
+
- PostgreSQL database hosted on Neon
|
|
239
|
+
- Tailwind CSS for styling
|
|
240
|
+
- shadcn/ui component library
|
|
241
|
+
- Stripe for payment processing
|
|
242
|
+
|
|
243
|
+
## Directory Structure
|
|
244
|
+
- src/app/ - Next.js app router pages
|
|
245
|
+
- src/components/ - Reusable React components
|
|
246
|
+
- src/lib/ - Utility functions
|
|
247
|
+
- src/features/ - Feature modules
|
|
248
|
+
- prisma/ - Database schema
|
|
249
|
+
|
|
250
|
+
## Code Style
|
|
251
|
+
- Use 2-space indentation
|
|
252
|
+
- Use semicolons
|
|
253
|
+
- Use single quotes
|
|
254
|
+
- Use const over let
|
|
255
|
+
- No unused variables
|
|
256
|
+
- Prefer arrow functions
|
|
257
|
+
- Use PascalCase for components
|
|
258
|
+
- Use camelCase for functions
|
|
259
|
+
|
|
260
|
+
## Important Notes
|
|
261
|
+
In order to maintain code quality, it's important to note that
|
|
262
|
+
all developers should follow clean code principles and ensure
|
|
263
|
+
that the codebase remains maintainable and readable.
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### After (optimized — complete file, 22 lines)
|
|
267
|
+
```markdown
|
|
268
|
+
# MyApp
|
|
269
|
+
SaaS invoice management platform.
|
|
270
|
+
|
|
271
|
+
## Tech Stack
|
|
272
|
+
- Next.js 15 (App Router) + TypeScript
|
|
273
|
+
- Prisma + PostgreSQL (Neon)
|
|
274
|
+
- Stripe payments
|
|
275
|
+
- Tailwind + shadcn/ui
|
|
276
|
+
|
|
277
|
+
## Commands
|
|
278
|
+
- `pnpm dev` - Dev server
|
|
279
|
+
- `pnpm build` - Build
|
|
280
|
+
- `pnpm test` - Tests
|
|
281
|
+
- `pnpm db:push` - Push schema
|
|
282
|
+
|
|
283
|
+
## Important Files
|
|
284
|
+
- `src/lib/auth.ts` - Auth config
|
|
285
|
+
- `src/lib/safe-actions.ts` - Server action wrapper
|
|
286
|
+
|
|
287
|
+
## Rules
|
|
288
|
+
- ALWAYS use safe-action wrapper for server actions
|
|
289
|
+
- NEVER import server modules in client components
|
|
290
|
+
- Use TanStack Form for ALL forms
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**What was removed and why:**
|
|
294
|
+
- Vision/Goals (Category 3: marketing — zero code value)
|
|
295
|
+
- React 19, TypeScript descriptions (Category 2: obvious from package.json)
|
|
296
|
+
- Directory structure (Category 2: agent discovers via `ls`)
|
|
297
|
+
- All code style rules (Category 1: ESLint/Prettier enforces these)
|
|
298
|
+
- "Important Notes" paragraph (Category 6: generic best practices + Category 5: filler)
|
|
299
|
+
|
|
300
|
+
**Result:** 47 → 22 lines. Research predicts ~4% better task completion and ~20% cost reduction.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: subagent-creator
|
|
3
3
|
description: Expert guidance for creating, building, and using Claude Code subagents and the Task tool. Use when working with subagents, setting up agent configurations, understanding how agents work, or using the Task tool to launch specialized agents.
|
|
4
4
|
---
|
|
5
5
|
|