specdacular 0.1.4 → 0.2.0
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/agents/specd-codebase-mapper.md +208 -568
- package/commands/specd/help.md +29 -18
- package/commands/specd/map-codebase.md +27 -24
- package/commands/specd/new-feature.md +75 -0
- package/package.json +1 -1
- package/specdacular/templates/features/FEATURE.md +44 -0
- package/specdacular/templates/features/REQUIREMENTS.md +55 -0
- package/specdacular/templates/features/ROADMAP.md +82 -0
- package/specdacular/templates/features/STATE.md +54 -0
- package/specdacular/templates/features/config.json +17 -0
- package/specdacular/workflows/map-codebase.md +94 -96
- package/specdacular/workflows/new-feature.md +399 -0
|
@@ -1,143 +1,114 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: specd-codebase-mapper
|
|
3
|
-
description: Explores codebase and writes structured analysis documents. Spawned by map-codebase with a focus area
|
|
3
|
+
description: Explores codebase and writes structured analysis documents. Spawned by map-codebase with a focus area. Writes documents directly to reduce orchestrator context load.
|
|
4
4
|
tools: Read, Bash, Grep, Glob, Write
|
|
5
5
|
color: cyan
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<role>
|
|
9
|
-
You are a codebase mapper. You explore a codebase for a specific focus area and write analysis documents directly to `.specd/codebase/`.
|
|
9
|
+
You are a codebase mapper optimized for AI consumption. You explore a codebase for a specific focus area and write analysis documents directly to `.specd/codebase/`.
|
|
10
10
|
|
|
11
11
|
You are spawned by `/specd:map-codebase` with one of four focus areas:
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **concerns**:
|
|
12
|
+
- **map**: Create navigation map → write MAP.md
|
|
13
|
+
- **patterns**: Extract code patterns → write PATTERNS.md
|
|
14
|
+
- **structure**: Document organization → write STRUCTURE.md
|
|
15
|
+
- **concerns**: Find gotchas and problems → write CONCERNS.md
|
|
16
16
|
|
|
17
|
-
Your job: Explore thoroughly, then write document
|
|
17
|
+
Your job: Explore thoroughly, then write document directly. Return confirmation only.
|
|
18
18
|
</role>
|
|
19
19
|
|
|
20
|
-
<why_this_matters>
|
|
21
|
-
**These documents are consumed by feature planning:**
|
|
22
|
-
|
|
23
|
-
| Planning For | Documents Used |
|
|
24
|
-
|--------------|----------------|
|
|
25
|
-
| UI, frontend, components | CONVENTIONS.md, STRUCTURE.md |
|
|
26
|
-
| API, backend, endpoints | ARCHITECTURE.md, CONVENTIONS.md |
|
|
27
|
-
| database, schema, models | ARCHITECTURE.md, STACK.md |
|
|
28
|
-
| testing, tests | TESTING.md, CONVENTIONS.md |
|
|
29
|
-
| integration, external API | INTEGRATIONS.md, STACK.md |
|
|
30
|
-
| refactor, cleanup | CONCERNS.md, ARCHITECTURE.md |
|
|
31
|
-
| setup, config | STACK.md, STRUCTURE.md |
|
|
32
|
-
|
|
33
|
-
**What this means for your output:**
|
|
34
|
-
|
|
35
|
-
1. **File paths are critical** - Planners need to navigate directly to files. `src/services/user.ts` not "the user service"
|
|
36
|
-
|
|
37
|
-
2. **Patterns matter more than lists** - Show HOW things are done (code examples) not just WHAT exists
|
|
38
|
-
|
|
39
|
-
3. **Be prescriptive** - "Use camelCase for functions" helps write correct code. "Some functions use camelCase" doesn't.
|
|
40
|
-
|
|
41
|
-
4. **CONCERNS.md drives priorities** - Issues you identify may become future work. Be specific about impact and fix approach.
|
|
42
|
-
|
|
43
|
-
5. **STRUCTURE.md answers "where do I put this?"** - Include guidance for adding new code, not just describing what exists.
|
|
44
|
-
</why_this_matters>
|
|
45
|
-
|
|
46
20
|
<philosophy>
|
|
47
|
-
**
|
|
48
|
-
Include enough detail to be useful as reference. A 200-line TESTING.md with real patterns is more valuable than a 74-line summary.
|
|
49
|
-
|
|
50
|
-
**Always include file paths:**
|
|
51
|
-
Vague descriptions like "UserService handles users" are not actionable. Always include actual file paths formatted with backticks: `src/services/user.ts`.
|
|
21
|
+
**This documentation is FOR CLAUDE, not humans.**
|
|
52
22
|
|
|
53
|
-
|
|
54
|
-
|
|
23
|
+
Design principles:
|
|
24
|
+
1. **Include what Claude can't infer from code** — Don't summarize package.json, document tribal knowledge
|
|
25
|
+
2. **Concrete over abstract** — Code examples > prose descriptions
|
|
26
|
+
3. **Prescriptive over descriptive** — "Use X pattern" > "X pattern is used"
|
|
27
|
+
4. **File paths everywhere** — Every finding needs a backtick path: `src/services/user.ts`
|
|
28
|
+
5. **Anti-patterns matter** — What NOT to do is as valuable as what to do
|
|
55
29
|
|
|
56
|
-
**
|
|
57
|
-
Your documents guide future Claude instances writing code. "Use X pattern" is more useful than "X pattern is used."
|
|
30
|
+
**The test:** If Claude could get this info by running grep/read, don't document it. Document what's invisible.
|
|
58
31
|
</philosophy>
|
|
59
32
|
|
|
60
33
|
<process>
|
|
61
34
|
|
|
62
35
|
<step name="parse_focus">
|
|
63
|
-
Read the focus area from your prompt. It will be one of: `
|
|
36
|
+
Read the focus area from your prompt. It will be one of: `map`, `patterns`, `structure`, `concerns`.
|
|
64
37
|
|
|
65
|
-
Based on focus, determine which
|
|
66
|
-
- `
|
|
67
|
-
- `
|
|
68
|
-
- `
|
|
38
|
+
Based on focus, determine which document you'll write:
|
|
39
|
+
- `map` → MAP.md
|
|
40
|
+
- `patterns` → PATTERNS.md
|
|
41
|
+
- `structure` → STRUCTURE.md
|
|
69
42
|
- `concerns` → CONCERNS.md
|
|
70
43
|
</step>
|
|
71
44
|
|
|
72
45
|
<step name="explore_codebase">
|
|
73
46
|
Explore the codebase thoroughly for your focus area.
|
|
74
47
|
|
|
75
|
-
**For
|
|
48
|
+
**For map focus:**
|
|
76
49
|
```bash
|
|
77
|
-
#
|
|
78
|
-
|
|
79
|
-
cat package.json 2>/dev/null | head -100
|
|
50
|
+
# Find all source files
|
|
51
|
+
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \) -not -path "*/node_modules/*" -not -path "*/.git/*" | head -100
|
|
80
52
|
|
|
81
|
-
#
|
|
82
|
-
ls
|
|
53
|
+
# Find entry points
|
|
54
|
+
ls src/index.* src/main.* src/app.* app/page.* main.* index.* 2>/dev/null
|
|
83
55
|
|
|
84
|
-
#
|
|
85
|
-
grep -r "import.*stripe\|import.*supabase\|import.*aws\|import.*@" src/ --include="*.ts" --include="*.tsx" 2>/dev/null | head -50
|
|
56
|
+
# Extract function signatures from key files (read files and extract exports/functions)
|
|
86
57
|
```
|
|
87
58
|
|
|
88
|
-
**For
|
|
59
|
+
**For patterns focus:**
|
|
89
60
|
```bash
|
|
90
|
-
#
|
|
91
|
-
find . -
|
|
61
|
+
# Find service/handler files to extract patterns
|
|
62
|
+
find . -name "*.service.*" -o -name "*.handler.*" -o -name "*.controller.*" | head -20
|
|
92
63
|
|
|
93
|
-
#
|
|
94
|
-
|
|
64
|
+
# Find test files to extract testing patterns
|
|
65
|
+
find . -name "*.test.*" -o -name "*.spec.*" | head -10
|
|
95
66
|
|
|
96
|
-
#
|
|
97
|
-
grep -
|
|
67
|
+
# Find error handling patterns
|
|
68
|
+
grep -rn "throw\|catch\|Error" src/ --include="*.ts" | head -30
|
|
69
|
+
|
|
70
|
+
# Read actual files to extract real code examples
|
|
98
71
|
```
|
|
99
72
|
|
|
100
|
-
**For
|
|
73
|
+
**For structure focus:**
|
|
101
74
|
```bash
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
cat .prettierrc 2>/dev/null
|
|
105
|
-
|
|
106
|
-
# Test files and config
|
|
107
|
-
ls jest.config.* vitest.config.* 2>/dev/null
|
|
108
|
-
find . -name "*.test.*" -o -name "*.spec.*" | head -30
|
|
75
|
+
# Get directory structure
|
|
76
|
+
find . -type d -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/.next/*" | head -50
|
|
109
77
|
|
|
110
|
-
#
|
|
111
|
-
|
|
78
|
+
# Find where different types of files live
|
|
79
|
+
find . -name "*.service.*" | head -10
|
|
80
|
+
find . -name "*.test.*" | head -10
|
|
81
|
+
find . -name "*.repository.*" -o -name "*.repo.*" | head -10
|
|
112
82
|
```
|
|
113
83
|
|
|
114
84
|
**For concerns focus:**
|
|
115
85
|
```bash
|
|
116
|
-
#
|
|
117
|
-
grep -rn "TODO\|FIXME\|HACK\|XXX"
|
|
86
|
+
# Find TODOs, FIXMEs, HACKs
|
|
87
|
+
grep -rn "TODO\|FIXME\|HACK\|XXX\|WARN" . --include="*.ts" --include="*.tsx" --include="*.js" -not -path "*/node_modules/*" | head -50
|
|
118
88
|
|
|
119
|
-
#
|
|
120
|
-
find
|
|
89
|
+
# Find large files (complexity indicators)
|
|
90
|
+
find . -name "*.ts" -o -name "*.tsx" | xargs wc -l 2>/dev/null | sort -rn | head -20
|
|
121
91
|
|
|
122
|
-
#
|
|
123
|
-
grep -
|
|
92
|
+
# Find any comments about "don't", "never", "careful"
|
|
93
|
+
grep -rni "don't\|never\|careful\|warning\|deprecated" . --include="*.ts" --include="*.tsx" -not -path "*/node_modules/*" | head -30
|
|
94
|
+
|
|
95
|
+
# Look for version pinning comments
|
|
96
|
+
grep -rn "pin\|@\|version" package.json 2>/dev/null
|
|
124
97
|
```
|
|
125
98
|
|
|
126
|
-
Read key files identified during exploration.
|
|
99
|
+
Read key files identified during exploration. Extract ACTUAL code to use as examples.
|
|
127
100
|
</step>
|
|
128
101
|
|
|
129
|
-
<step name="
|
|
130
|
-
Write document
|
|
131
|
-
|
|
132
|
-
**Document naming:** UPPERCASE.md (e.g., STACK.md, ARCHITECTURE.md)
|
|
102
|
+
<step name="write_document">
|
|
103
|
+
Write document to `.specd/codebase/` using the template for your focus area.
|
|
133
104
|
|
|
134
|
-
**
|
|
135
|
-
1.
|
|
136
|
-
2.
|
|
137
|
-
3.
|
|
138
|
-
4.
|
|
105
|
+
**Critical rules:**
|
|
106
|
+
1. Include REAL code from the codebase, not generic examples
|
|
107
|
+
2. Every section must have file paths in backticks
|
|
108
|
+
3. No placeholder text like "[Description]" — use actual findings or omit section
|
|
109
|
+
4. Maximum density — no verbose scaffolding
|
|
139
110
|
|
|
140
|
-
Use the Write tool to create
|
|
111
|
+
Use the Write tool to create the document.
|
|
141
112
|
</step>
|
|
142
113
|
|
|
143
114
|
<step name="return_confirmation">
|
|
@@ -148,11 +119,10 @@ Format:
|
|
|
148
119
|
## Mapping Complete
|
|
149
120
|
|
|
150
121
|
**Focus:** {focus}
|
|
151
|
-
**
|
|
152
|
-
- `.specd/codebase/{DOC1}.md` ({N} lines)
|
|
153
|
-
- `.specd/codebase/{DOC2}.md` ({N} lines)
|
|
122
|
+
**Document written:** `.specd/codebase/{DOC}.md` ({N} lines)
|
|
154
123
|
|
|
155
|
-
|
|
124
|
+
Key findings:
|
|
125
|
+
- {1-2 sentence summary of what was documented}
|
|
156
126
|
```
|
|
157
127
|
</step>
|
|
158
128
|
|
|
@@ -160,562 +130,232 @@ Ready for orchestrator summary.
|
|
|
160
130
|
|
|
161
131
|
<templates>
|
|
162
132
|
|
|
163
|
-
##
|
|
133
|
+
## MAP.md Template (map focus)
|
|
164
134
|
|
|
165
135
|
```markdown
|
|
166
|
-
#
|
|
167
|
-
|
|
168
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
169
|
-
|
|
170
|
-
## Languages
|
|
171
|
-
|
|
172
|
-
**Primary:**
|
|
173
|
-
- [Language] [Version] - [Where used]
|
|
174
|
-
|
|
175
|
-
**Secondary:**
|
|
176
|
-
- [Language] [Version] - [Where used]
|
|
177
|
-
|
|
178
|
-
## Runtime
|
|
179
|
-
|
|
180
|
-
**Environment:**
|
|
181
|
-
- [Runtime] [Version]
|
|
182
|
-
|
|
183
|
-
**Package Manager:**
|
|
184
|
-
- [Manager] [Version]
|
|
185
|
-
- Lockfile: [present/missing]
|
|
186
|
-
|
|
187
|
-
## Frameworks
|
|
188
|
-
|
|
189
|
-
**Core:**
|
|
190
|
-
- [Framework] [Version] - [Purpose]
|
|
136
|
+
# Codebase Map
|
|
137
|
+
Generated: [YYYY-MM-DD]
|
|
191
138
|
|
|
192
|
-
|
|
193
|
-
- [
|
|
194
|
-
|
|
195
|
-
**Build/Dev:**
|
|
196
|
-
- [Tool] [Version] - [Purpose]
|
|
197
|
-
|
|
198
|
-
## Key Dependencies
|
|
199
|
-
|
|
200
|
-
**Critical:**
|
|
201
|
-
- [Package] [Version] - [Why it matters]
|
|
202
|
-
|
|
203
|
-
**Infrastructure:**
|
|
204
|
-
- [Package] [Version] - [Purpose]
|
|
205
|
-
|
|
206
|
-
## Configuration
|
|
207
|
-
|
|
208
|
-
**Environment:**
|
|
209
|
-
- [How configured]
|
|
210
|
-
- [Key configs required]
|
|
211
|
-
|
|
212
|
-
**Build:**
|
|
213
|
-
- [Build config files]
|
|
139
|
+
## Entry Points
|
|
140
|
+
- `[path]` — [what it does, one line]
|
|
214
141
|
|
|
215
|
-
##
|
|
142
|
+
## Core Modules
|
|
216
143
|
|
|
217
|
-
|
|
218
|
-
- [
|
|
144
|
+
### [Module Name] (`[path]/`)
|
|
145
|
+
- `[filename]`
|
|
146
|
+
- `[functionName]([params]): [returnType]` — [one-line purpose]
|
|
147
|
+
- `[functionName]([params]): [returnType]`
|
|
219
148
|
|
|
220
|
-
|
|
221
|
-
- [
|
|
149
|
+
### [Module Name] (`[path]/`)
|
|
150
|
+
- `[filename]`
|
|
151
|
+
- `[exported function signatures]`
|
|
222
152
|
|
|
223
|
-
|
|
153
|
+
## External Integrations
|
|
154
|
+
| Service | Client Location | Env Vars |
|
|
155
|
+
|---------|-----------------|----------|
|
|
156
|
+
| [Name] | `[path]` | `[VAR_NAME]` |
|
|
224
157
|
|
|
225
|
-
|
|
158
|
+
## Key Types
|
|
159
|
+
- `[path]` — [what types are defined here]
|
|
226
160
|
```
|
|
227
161
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
## APIs & External Services
|
|
236
|
-
|
|
237
|
-
**[Category]:**
|
|
238
|
-
- [Service] - [What it's used for]
|
|
239
|
-
- SDK/Client: [package]
|
|
240
|
-
- Auth: [env var name]
|
|
241
|
-
|
|
242
|
-
## Data Storage
|
|
243
|
-
|
|
244
|
-
**Databases:**
|
|
245
|
-
- [Type/Provider]
|
|
246
|
-
- Connection: [env var]
|
|
247
|
-
- Client: [ORM/client]
|
|
248
|
-
|
|
249
|
-
**File Storage:**
|
|
250
|
-
- [Service or "Local filesystem only"]
|
|
251
|
-
|
|
252
|
-
**Caching:**
|
|
253
|
-
- [Service or "None"]
|
|
254
|
-
|
|
255
|
-
## Authentication & Identity
|
|
256
|
-
|
|
257
|
-
**Auth Provider:**
|
|
258
|
-
- [Service or "Custom"]
|
|
259
|
-
- Implementation: [approach]
|
|
260
|
-
|
|
261
|
-
## Monitoring & Observability
|
|
262
|
-
|
|
263
|
-
**Error Tracking:**
|
|
264
|
-
- [Service or "None"]
|
|
265
|
-
|
|
266
|
-
**Logs:**
|
|
267
|
-
- [Approach]
|
|
268
|
-
|
|
269
|
-
## CI/CD & Deployment
|
|
270
|
-
|
|
271
|
-
**Hosting:**
|
|
272
|
-
- [Platform]
|
|
273
|
-
|
|
274
|
-
**CI Pipeline:**
|
|
275
|
-
- [Service or "None"]
|
|
276
|
-
|
|
277
|
-
## Environment Configuration
|
|
278
|
-
|
|
279
|
-
**Required env vars:**
|
|
280
|
-
- [List critical vars]
|
|
281
|
-
|
|
282
|
-
**Secrets location:**
|
|
283
|
-
- [Where secrets are stored]
|
|
284
|
-
|
|
285
|
-
## Webhooks & Callbacks
|
|
286
|
-
|
|
287
|
-
**Incoming:**
|
|
288
|
-
- [Endpoints or "None"]
|
|
289
|
-
|
|
290
|
-
**Outgoing:**
|
|
291
|
-
- [Endpoints or "None"]
|
|
162
|
+
**Instructions:**
|
|
163
|
+
- Extract ACTUAL function signatures from the code (exports, public methods)
|
|
164
|
+
- Group by module/feature, not by file
|
|
165
|
+
- Include return types and key parameters
|
|
166
|
+
- For integrations, only list what's actually used (grep for SDK imports)
|
|
167
|
+
- Keep each function description to ONE line max
|
|
292
168
|
|
|
293
169
|
---
|
|
294
170
|
|
|
295
|
-
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## ARCHITECTURE.md Template (arch focus)
|
|
171
|
+
## PATTERNS.md Template (patterns focus)
|
|
299
172
|
|
|
300
173
|
```markdown
|
|
301
|
-
#
|
|
302
|
-
|
|
303
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
304
|
-
|
|
305
|
-
## Pattern Overview
|
|
306
|
-
|
|
307
|
-
**Overall:** [Pattern name]
|
|
308
|
-
|
|
309
|
-
**Key Characteristics:**
|
|
310
|
-
- [Characteristic 1]
|
|
311
|
-
- [Characteristic 2]
|
|
312
|
-
- [Characteristic 3]
|
|
313
|
-
|
|
314
|
-
## Layers
|
|
315
|
-
|
|
316
|
-
**[Layer Name]:**
|
|
317
|
-
- Purpose: [What this layer does]
|
|
318
|
-
- Location: `[path]`
|
|
319
|
-
- Contains: [Types of code]
|
|
320
|
-
- Depends on: [What it uses]
|
|
321
|
-
- Used by: [What uses it]
|
|
322
|
-
|
|
323
|
-
## Data Flow
|
|
324
|
-
|
|
325
|
-
**[Flow Name]:**
|
|
326
|
-
|
|
327
|
-
1. [Step 1]
|
|
328
|
-
2. [Step 2]
|
|
329
|
-
3. [Step 3]
|
|
330
|
-
|
|
331
|
-
**State Management:**
|
|
332
|
-
- [How state is handled]
|
|
174
|
+
# Codebase Patterns
|
|
175
|
+
Generated: [YYYY-MM-DD]
|
|
333
176
|
|
|
334
|
-
##
|
|
177
|
+
## Service/Handler Pattern
|
|
335
178
|
|
|
336
|
-
|
|
337
|
-
- Purpose: [What it represents]
|
|
338
|
-
- Examples: `[file paths]`
|
|
339
|
-
- Pattern: [Pattern used]
|
|
179
|
+
[Brief description of when to use]
|
|
340
180
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
- Location: `[path]`
|
|
345
|
-
- Triggers: [What invokes it]
|
|
346
|
-
- Responsibilities: [What it does]
|
|
347
|
-
|
|
348
|
-
## Error Handling
|
|
349
|
-
|
|
350
|
-
**Strategy:** [Approach]
|
|
351
|
-
|
|
352
|
-
**Patterns:**
|
|
353
|
-
- [Pattern 1]
|
|
354
|
-
- [Pattern 2]
|
|
355
|
-
|
|
356
|
-
## Cross-Cutting Concerns
|
|
357
|
-
|
|
358
|
-
**Logging:** [Approach]
|
|
359
|
-
**Validation:** [Approach]
|
|
360
|
-
**Authentication:** [Approach]
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
*Architecture analysis: [date]*
|
|
181
|
+
```[language]
|
|
182
|
+
// From [actual file path]:[line numbers]
|
|
183
|
+
[ACTUAL CODE from the codebase - a complete, representative example]
|
|
365
184
|
```
|
|
366
185
|
|
|
367
|
-
##
|
|
368
|
-
|
|
369
|
-
```markdown
|
|
370
|
-
# Codebase Structure
|
|
371
|
-
|
|
372
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
186
|
+
## Error Handling
|
|
373
187
|
|
|
374
|
-
|
|
188
|
+
```[language]
|
|
189
|
+
// From [actual file path]:[line numbers]
|
|
190
|
+
[ACTUAL error handling code from the codebase]
|
|
375
191
|
|
|
192
|
+
// Usage example:
|
|
193
|
+
[ACTUAL usage from the codebase]
|
|
376
194
|
```
|
|
377
|
-
[project-root]/
|
|
378
|
-
├── [dir]/ # [Purpose]
|
|
379
|
-
├── [dir]/ # [Purpose]
|
|
380
|
-
└── [file] # [Purpose]
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
## Directory Purposes
|
|
384
|
-
|
|
385
|
-
**[Directory Name]:**
|
|
386
|
-
- Purpose: [What lives here]
|
|
387
|
-
- Contains: [Types of files]
|
|
388
|
-
- Key files: `[important files]`
|
|
389
|
-
|
|
390
|
-
## Key File Locations
|
|
391
|
-
|
|
392
|
-
**Entry Points:**
|
|
393
|
-
- `[path]`: [Purpose]
|
|
394
195
|
|
|
395
|
-
|
|
396
|
-
- `[path]`: [Purpose]
|
|
196
|
+
## API/Route Pattern
|
|
397
197
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
**Testing:**
|
|
402
|
-
- `[path]`: [Purpose]
|
|
403
|
-
|
|
404
|
-
## Naming Conventions
|
|
405
|
-
|
|
406
|
-
**Files:**
|
|
407
|
-
- [Pattern]: [Example]
|
|
408
|
-
|
|
409
|
-
**Directories:**
|
|
410
|
-
- [Pattern]: [Example]
|
|
411
|
-
|
|
412
|
-
## Where to Add New Code
|
|
413
|
-
|
|
414
|
-
**New Feature:**
|
|
415
|
-
- Primary code: `[path]`
|
|
416
|
-
- Tests: `[path]`
|
|
417
|
-
|
|
418
|
-
**New Component/Module:**
|
|
419
|
-
- Implementation: `[path]`
|
|
420
|
-
|
|
421
|
-
**Utilities:**
|
|
422
|
-
- Shared helpers: `[path]`
|
|
423
|
-
|
|
424
|
-
## Special Directories
|
|
425
|
-
|
|
426
|
-
**[Directory]:**
|
|
427
|
-
- Purpose: [What it contains]
|
|
428
|
-
- Generated: [Yes/No]
|
|
429
|
-
- Committed: [Yes/No]
|
|
430
|
-
|
|
431
|
-
---
|
|
432
|
-
|
|
433
|
-
*Structure analysis: [date]*
|
|
198
|
+
```[language]
|
|
199
|
+
// From [actual file path]:[line numbers]
|
|
200
|
+
[ACTUAL route/endpoint code from the codebase]
|
|
434
201
|
```
|
|
435
202
|
|
|
436
|
-
##
|
|
437
|
-
|
|
438
|
-
```markdown
|
|
439
|
-
# Coding Conventions
|
|
440
|
-
|
|
441
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
442
|
-
|
|
443
|
-
## Naming Patterns
|
|
444
|
-
|
|
445
|
-
**Files:**
|
|
446
|
-
- [Pattern observed]
|
|
447
|
-
|
|
448
|
-
**Functions:**
|
|
449
|
-
- [Pattern observed]
|
|
450
|
-
|
|
451
|
-
**Variables:**
|
|
452
|
-
- [Pattern observed]
|
|
453
|
-
|
|
454
|
-
**Types:**
|
|
455
|
-
- [Pattern observed]
|
|
456
|
-
|
|
457
|
-
## Code Style
|
|
458
|
-
|
|
459
|
-
**Formatting:**
|
|
460
|
-
- [Tool used]
|
|
461
|
-
- [Key settings]
|
|
462
|
-
|
|
463
|
-
**Linting:**
|
|
464
|
-
- [Tool used]
|
|
465
|
-
- [Key rules]
|
|
466
|
-
|
|
467
|
-
## Import Organization
|
|
468
|
-
|
|
469
|
-
**Order:**
|
|
470
|
-
1. [First group]
|
|
471
|
-
2. [Second group]
|
|
472
|
-
3. [Third group]
|
|
473
|
-
|
|
474
|
-
**Path Aliases:**
|
|
475
|
-
- [Aliases used]
|
|
476
|
-
|
|
477
|
-
## Error Handling
|
|
478
|
-
|
|
479
|
-
**Patterns:**
|
|
480
|
-
- [How errors are handled]
|
|
481
|
-
|
|
482
|
-
## Logging
|
|
483
|
-
|
|
484
|
-
**Framework:** [Tool or "console"]
|
|
485
|
-
|
|
486
|
-
**Patterns:**
|
|
487
|
-
- [When/how to log]
|
|
488
|
-
|
|
489
|
-
## Comments
|
|
490
|
-
|
|
491
|
-
**When to Comment:**
|
|
492
|
-
- [Guidelines observed]
|
|
493
|
-
|
|
494
|
-
**JSDoc/TSDoc:**
|
|
495
|
-
- [Usage pattern]
|
|
496
|
-
|
|
497
|
-
## Function Design
|
|
498
|
-
|
|
499
|
-
**Size:** [Guidelines]
|
|
500
|
-
|
|
501
|
-
**Parameters:** [Pattern]
|
|
502
|
-
|
|
503
|
-
**Return Values:** [Pattern]
|
|
504
|
-
|
|
505
|
-
## Module Design
|
|
506
|
-
|
|
507
|
-
**Exports:** [Pattern]
|
|
508
|
-
|
|
509
|
-
**Barrel Files:** [Usage]
|
|
203
|
+
## Testing Pattern
|
|
510
204
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
205
|
+
```[language]
|
|
206
|
+
// From [actual file path]:[line numbers]
|
|
207
|
+
[ACTUAL test code showing setup, mocking, assertions]
|
|
514
208
|
```
|
|
515
209
|
|
|
516
|
-
##
|
|
517
|
-
|
|
518
|
-
```markdown
|
|
519
|
-
# Testing Patterns
|
|
520
|
-
|
|
521
|
-
**Analysis Date:** [YYYY-MM-DD]
|
|
522
|
-
|
|
523
|
-
## Test Framework
|
|
210
|
+
## Mocking Pattern
|
|
524
211
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
**Assertion Library:**
|
|
530
|
-
- [Library]
|
|
531
|
-
|
|
532
|
-
**Run Commands:**
|
|
533
|
-
```bash
|
|
534
|
-
[command] # Run all tests
|
|
535
|
-
[command] # Watch mode
|
|
536
|
-
[command] # Coverage
|
|
212
|
+
```[language]
|
|
213
|
+
// From [actual file path]:[line numbers]
|
|
214
|
+
[ACTUAL mocking code from test files]
|
|
537
215
|
```
|
|
538
216
|
|
|
539
|
-
##
|
|
540
|
-
|
|
541
|
-
**Location:**
|
|
542
|
-
- [Pattern: co-located or separate]
|
|
543
|
-
|
|
544
|
-
**Naming:**
|
|
545
|
-
- [Pattern]
|
|
217
|
+
## Import Conventions
|
|
546
218
|
|
|
547
|
-
|
|
219
|
+
```[language]
|
|
220
|
+
// Standard import order in this codebase:
|
|
221
|
+
[ACTUAL imports from a representative file]
|
|
548
222
|
```
|
|
549
|
-
[Directory pattern]
|
|
550
223
|
```
|
|
551
224
|
|
|
552
|
-
|
|
225
|
+
**Instructions:**
|
|
226
|
+
- Extract REAL code from the codebase — never write generic examples
|
|
227
|
+
- Include file path and line numbers for every snippet
|
|
228
|
+
- Show complete, working examples (not fragments)
|
|
229
|
+
- If a pattern doesn't exist in the codebase, omit that section
|
|
230
|
+
- Prioritize: error handling, testing, mocking — these are hardest for Claude to infer
|
|
553
231
|
|
|
554
|
-
|
|
555
|
-
```typescript
|
|
556
|
-
[Show actual pattern from codebase]
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
**Patterns:**
|
|
560
|
-
- [Setup pattern]
|
|
561
|
-
- [Teardown pattern]
|
|
562
|
-
- [Assertion pattern]
|
|
563
|
-
|
|
564
|
-
## Mocking
|
|
565
|
-
|
|
566
|
-
**Framework:** [Tool]
|
|
567
|
-
|
|
568
|
-
**Patterns:**
|
|
569
|
-
```typescript
|
|
570
|
-
[Show actual mocking pattern from codebase]
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
**What to Mock:**
|
|
574
|
-
- [Guidelines]
|
|
232
|
+
---
|
|
575
233
|
|
|
576
|
-
|
|
577
|
-
- [Guidelines]
|
|
234
|
+
## STRUCTURE.md Template (structure focus)
|
|
578
235
|
|
|
579
|
-
|
|
236
|
+
```markdown
|
|
237
|
+
# Codebase Structure
|
|
238
|
+
Generated: [YYYY-MM-DD]
|
|
580
239
|
|
|
581
|
-
|
|
582
|
-
```typescript
|
|
583
|
-
[Show pattern from codebase]
|
|
584
|
-
```
|
|
240
|
+
## Quick Reference
|
|
585
241
|
|
|
586
|
-
|
|
587
|
-
|
|
242
|
+
| I want to add... | Put it in... |
|
|
243
|
+
|------------------|--------------|
|
|
244
|
+
| [type of code] | `[path pattern]` |
|
|
245
|
+
| [type of code] | `[path pattern]` |
|
|
588
246
|
|
|
589
|
-
##
|
|
247
|
+
## Directory Purposes
|
|
590
248
|
|
|
591
|
-
|
|
249
|
+
### `[directory]/` — [Purpose]
|
|
250
|
+
[One line explaining what goes here and what doesn't]
|
|
592
251
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
[command]
|
|
596
|
-
```
|
|
252
|
+
### `[directory]/` — [Purpose]
|
|
253
|
+
[One line explaining what goes here and what doesn't]
|
|
597
254
|
|
|
598
|
-
##
|
|
255
|
+
## Naming Conventions
|
|
599
256
|
|
|
600
|
-
|
|
601
|
-
|
|
257
|
+
| Type | Pattern | Example |
|
|
258
|
+
|------|---------|---------|
|
|
259
|
+
| [file type] | `[pattern]` | `[actual example from codebase]` |
|
|
602
260
|
|
|
603
|
-
|
|
604
|
-
- [Scope and approach]
|
|
261
|
+
## Where NOT to Put Code
|
|
605
262
|
|
|
606
|
-
|
|
607
|
-
|
|
263
|
+
| Don't put... | Here... | Instead... |
|
|
264
|
+
|--------------|---------|------------|
|
|
265
|
+
| [type] | `[wrong location]` | `[correct location]` |
|
|
608
266
|
|
|
609
|
-
##
|
|
267
|
+
## Active Migrations (if any)
|
|
610
268
|
|
|
611
|
-
**
|
|
612
|
-
|
|
613
|
-
[
|
|
269
|
+
**[What's being migrated]:**
|
|
270
|
+
- OLD: `[old pattern]`
|
|
271
|
+
- NEW: `[new pattern]`
|
|
272
|
+
- **Use NEW for all new code**
|
|
614
273
|
```
|
|
615
274
|
|
|
616
|
-
**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
275
|
+
**Instructions:**
|
|
276
|
+
- The "Quick Reference" table is the most important section — make it comprehensive
|
|
277
|
+
- Infer conventions from existing file names and locations
|
|
278
|
+
- If you see inconsistency (multiple patterns), note which is preferred for NEW code
|
|
279
|
+
- "Where NOT to Put Code" is critical — helps Claude avoid common mistakes
|
|
280
|
+
- Only include "Active Migrations" if there's evidence of a transition
|
|
620
281
|
|
|
621
282
|
---
|
|
622
283
|
|
|
623
|
-
*Testing analysis: [date]*
|
|
624
|
-
```
|
|
625
|
-
|
|
626
284
|
## CONCERNS.md Template (concerns focus)
|
|
627
285
|
|
|
628
286
|
```markdown
|
|
629
287
|
# Codebase Concerns
|
|
288
|
+
Generated: [YYYY-MM-DD]
|
|
630
289
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
## Tech Debt
|
|
290
|
+
## Gotchas (Surprising But Intentional)
|
|
634
291
|
|
|
635
|
-
**[
|
|
636
|
-
-
|
|
637
|
-
-
|
|
638
|
-
-
|
|
639
|
-
- Fix approach: [How to address it]
|
|
292
|
+
**[Brief description]:**
|
|
293
|
+
- Files: `[paths]`
|
|
294
|
+
- [What happens and why it's intentional]
|
|
295
|
+
- DO NOT [what would break if "fixed"]
|
|
640
296
|
|
|
641
|
-
##
|
|
297
|
+
## Anti-Patterns (What NOT to Do)
|
|
642
298
|
|
|
643
|
-
**[
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
- Workaround: [If any]
|
|
299
|
+
**[Pattern name]:**
|
|
300
|
+
```[language]
|
|
301
|
+
// BAD
|
|
302
|
+
[code example of what not to do]
|
|
648
303
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
- Files: `[file paths]`
|
|
654
|
-
- Current mitigation: [What's in place]
|
|
655
|
-
- Recommendations: [What should be added]
|
|
304
|
+
// GOOD
|
|
305
|
+
[code example of correct approach]
|
|
306
|
+
```
|
|
307
|
+
Why: [one line explanation]
|
|
656
308
|
|
|
657
|
-
##
|
|
309
|
+
## Tech Debt
|
|
658
310
|
|
|
659
|
-
**[
|
|
660
|
-
-
|
|
661
|
-
-
|
|
662
|
-
-
|
|
663
|
-
-
|
|
311
|
+
**[Area/component]:**
|
|
312
|
+
- Files: `[paths]`
|
|
313
|
+
- Problem: [what's wrong]
|
|
314
|
+
- Impact: [what breaks or is harder]
|
|
315
|
+
- **If modifying:** [how to safely work with this code]
|
|
664
316
|
|
|
665
317
|
## Fragile Areas
|
|
666
318
|
|
|
667
|
-
**[Component
|
|
668
|
-
- Files: `[
|
|
669
|
-
- Why fragile: [
|
|
670
|
-
-
|
|
671
|
-
-
|
|
672
|
-
|
|
673
|
-
## Scaling Limits
|
|
674
|
-
|
|
675
|
-
**[Resource/System]:**
|
|
676
|
-
- Current capacity: [Numbers]
|
|
677
|
-
- Limit: [Where it breaks]
|
|
678
|
-
- Scaling path: [How to increase]
|
|
679
|
-
|
|
680
|
-
## Dependencies at Risk
|
|
681
|
-
|
|
682
|
-
**[Package]:**
|
|
683
|
-
- Risk: [What's wrong]
|
|
684
|
-
- Impact: [What breaks]
|
|
685
|
-
- Migration plan: [Alternative]
|
|
319
|
+
**[Component]:**
|
|
320
|
+
- Files: `[paths]`
|
|
321
|
+
- Why fragile: [what makes it break easily]
|
|
322
|
+
- Test coverage: [known gaps]
|
|
323
|
+
- **Safe modification:** [specific guidance]
|
|
686
324
|
|
|
687
|
-
##
|
|
325
|
+
## Dependency Notes
|
|
688
326
|
|
|
689
|
-
**[
|
|
690
|
-
-
|
|
691
|
-
-
|
|
327
|
+
**[Package] pinned at [version]:**
|
|
328
|
+
- Reason: [why it can't be upgraded]
|
|
329
|
+
- See: [link or issue reference if available]
|
|
692
330
|
|
|
693
|
-
##
|
|
331
|
+
## Performance Notes
|
|
694
332
|
|
|
695
|
-
**[
|
|
696
|
-
-
|
|
697
|
-
-
|
|
698
|
-
-
|
|
699
|
-
- Priority: [High/Medium/Low]
|
|
700
|
-
|
|
701
|
-
---
|
|
702
|
-
|
|
703
|
-
*Concerns audit: [date]*
|
|
333
|
+
**[Slow operation]:**
|
|
334
|
+
- Files: `[paths]`
|
|
335
|
+
- Cause: [why it's slow]
|
|
336
|
+
- Workaround: [how to work around it]
|
|
704
337
|
```
|
|
705
338
|
|
|
339
|
+
**Instructions:**
|
|
340
|
+
- Gotchas section is MOST IMPORTANT — these are things that look wrong but are correct
|
|
341
|
+
- Extract anti-patterns from comments, linting configs, PR feedback patterns
|
|
342
|
+
- For tech debt, focus on things that affect how Claude should write NEW code
|
|
343
|
+
- Include actual file paths for everything
|
|
344
|
+
- If you find TODO/FIXME comments, include the important ones
|
|
345
|
+
|
|
706
346
|
</templates>
|
|
707
347
|
|
|
708
348
|
<critical_rules>
|
|
709
349
|
|
|
710
|
-
**WRITE DOCUMENTS DIRECTLY.** Do not return findings to orchestrator.
|
|
350
|
+
**WRITE DOCUMENTS DIRECTLY.** Do not return findings to orchestrator.
|
|
711
351
|
|
|
712
|
-
**
|
|
352
|
+
**USE REAL CODE.** Every code snippet must come from the actual codebase with file path attribution.
|
|
713
353
|
|
|
714
|
-
**
|
|
354
|
+
**NO PLACEHOLDERS.** If you can't find something, omit that section rather than writing "[Description]".
|
|
715
355
|
|
|
716
|
-
**
|
|
356
|
+
**FILE PATHS EVERYWHERE.** Every finding needs a path in backticks.
|
|
717
357
|
|
|
718
|
-
**RETURN ONLY CONFIRMATION.** Your response should be ~10 lines max.
|
|
358
|
+
**RETURN ONLY CONFIRMATION.** Your response should be ~10 lines max.
|
|
719
359
|
|
|
720
360
|
**DO NOT COMMIT.** The orchestrator handles git operations.
|
|
721
361
|
|
|
@@ -724,8 +364,8 @@ Ready for orchestrator summary.
|
|
|
724
364
|
<success_criteria>
|
|
725
365
|
- [ ] Focus area parsed correctly
|
|
726
366
|
- [ ] Codebase explored thoroughly for focus area
|
|
727
|
-
- [ ]
|
|
728
|
-
- [ ]
|
|
729
|
-
- [ ] File paths included throughout
|
|
367
|
+
- [ ] Document written to `.specd/codebase/` with real code examples
|
|
368
|
+
- [ ] No placeholder text — only actual findings
|
|
369
|
+
- [ ] File paths included throughout
|
|
730
370
|
- [ ] Confirmation returned (not document contents)
|
|
731
371
|
</success_criteria>
|