specdacular 0.10.1 → 0.11.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.
Files changed (55) hide show
  1. package/README.md +3 -3
  2. package/bin/install.js +3 -1
  3. package/bin/specd.js +135 -0
  4. package/commands/specd.best-practices.md +75 -0
  5. package/commands/specd.docs.md +81 -0
  6. package/commands/specd.docs.review.md +80 -0
  7. package/commands/specd.generate-skills.learn.md +65 -0
  8. package/commands/specd.new-runner-task.md +52 -0
  9. package/commands/specd.new.md +6 -6
  10. package/commands/specd.runner-status.md +27 -0
  11. package/package.json +6 -2
  12. package/runner/main/agent/parser.js +39 -0
  13. package/runner/main/agent/runner.js +137 -0
  14. package/runner/main/agent/template.js +16 -0
  15. package/runner/main/bootstrap.js +69 -0
  16. package/runner/main/db.js +45 -0
  17. package/runner/main/index.js +103 -0
  18. package/runner/main/ipc.js +72 -0
  19. package/runner/main/notifications/telegram.js +45 -0
  20. package/runner/main/orchestrator.js +193 -0
  21. package/runner/main/paths.js +36 -0
  22. package/runner/main/pipeline/resolver.js +20 -0
  23. package/runner/main/pipeline/sequencer.js +42 -0
  24. package/runner/main/server/api.js +125 -0
  25. package/runner/main/server/index.js +33 -0
  26. package/runner/main/server/websocket.js +24 -0
  27. package/runner/main/state/manager.js +83 -0
  28. package/runner/main/template-manager.js +41 -0
  29. package/runner/main/test/agent-parser.test.js +44 -0
  30. package/runner/main/test/bootstrap.test.js +58 -0
  31. package/runner/main/test/db.test.js +72 -0
  32. package/runner/main/test/paths.test.js +29 -0
  33. package/runner/main/test/state-manager.test.js +72 -0
  34. package/runner/main/test/template-manager.test.js +66 -0
  35. package/runner/main/worktree/manager.js +95 -0
  36. package/runner/package.json +22 -0
  37. package/runner/preload.js +19 -0
  38. package/specdacular/HELP.md +14 -11
  39. package/specdacular/agents/best-practices-researcher.md +271 -0
  40. package/specdacular/references/load-context.md +4 -7
  41. package/specdacular/templates/orchestrator/CONCERNS.md +1 -1
  42. package/specdacular/templates/orchestrator/PROJECTS.md +3 -4
  43. package/specdacular/templates/tasks/PLAN.md +2 -2
  44. package/specdacular/workflows/best-practices.md +472 -0
  45. package/specdacular/workflows/context-add.md +16 -30
  46. package/specdacular/workflows/context-manual-review.md +7 -7
  47. package/specdacular/workflows/docs-review.md +273 -0
  48. package/specdacular/workflows/docs.md +420 -0
  49. package/specdacular/workflows/generate-learn-skill.md +214 -0
  50. package/specdacular/workflows/new.md +5 -4
  51. package/specdacular/workflows/orchestrator/new.md +4 -4
  52. package/specdacular/workflows/orchestrator/plan.md +6 -6
  53. package/commands/specd.codebase.map.md +0 -72
  54. package/commands/specd.codebase.review.md +0 -39
  55. package/specdacular/workflows/map-codebase.md +0 -715
@@ -1,715 +0,0 @@
1
- <purpose>
2
- Orchestrate parallel codebase mapper agents to analyze codebase and produce 4 AI-optimized documents in .specd/codebase/
3
-
4
- Each agent has fresh context, explores a specific focus area, and **writes documents directly**. The orchestrator only receives confirmation + line counts.
5
-
6
- Output: .specd/codebase/ folder with 4 documents optimized for Claude consumption.
7
- </purpose>
8
-
9
- <philosophy>
10
- **These documents are FOR CLAUDE, not humans.**
11
-
12
- The 4 documents answer questions Claude can't get from reading code:
13
- - **MAP.md** — "Where is X? What functions exist?"
14
- - **PATTERNS.md** — "How do I write code that fits?"
15
- - **STRUCTURE.md** — "Where do I put new code?"
16
- - **CONCERNS.md** — "What will bite me?"
17
-
18
- **Why dedicated mapper agents:**
19
- - Fresh context per domain (no token contamination)
20
- - Agents write documents directly (no context transfer back to orchestrator)
21
- - Orchestrator only summarizes what was created (minimal context usage)
22
- - Parallel execution (faster)
23
- </philosophy>
24
-
25
- <process>
26
-
27
- <step name="detect_mode">
28
- Determine if this is a single-project or multi-project setup.
29
-
30
- Use AskUserQuestion:
31
- - header: "Setup Mode"
32
- - question: "Is this a multi-project setup (monorepo or multiple related projects)?"
33
- - options:
34
- - "Single project" — One codebase, one .specd/ (most common)
35
- - "Multi-project" — Multiple projects that coordinate (monorepo, multi-repo)
36
-
37
- **If Single project:**
38
- Set mode = "project".
39
- Continue to check_existing.
40
-
41
- **If Multi-project:**
42
- Set mode = "orchestrator".
43
- Continue to check_existing.
44
- </step>
45
-
46
- <step name="check_existing">
47
- **First, check for legacy setup (DEC-012):**
48
-
49
- ```bash
50
- # Check if .specd/ exists but has no config.json (legacy setup)
51
- if [ -d ".specd" ] && [ ! -f ".specd/config.json" ]; then
52
- echo "legacy_setup"
53
- fi
54
- ```
55
-
56
- **If legacy_setup detected:**
57
-
58
- ```
59
- Your codebase map was created with an older version of Specdacular.
60
- Re-mapping is recommended — this will also ask about multi-project support.
61
- ```
62
-
63
- Use AskUserQuestion:
64
- - header: "Legacy Setup"
65
- - question: "Re-map your codebase with the latest Specdacular?"
66
- - options:
67
- - "Yes, re-map (Recommended)" — Re-run mapping with multi-project detection
68
- - "Skip for now" — Keep existing map, continue without re-mapping
69
-
70
- **If "Yes, re-map":** Delete .specd/codebase/, continue with detect_mode flow.
71
- **If "Skip for now":** Exit workflow.
72
-
73
- **If .specd/config.json exists, check version:**
74
-
75
- ```bash
76
- cat .specd/config.json 2>/dev/null
77
- ```
78
-
79
- If `specd_version` is less than current version (1), offer to re-map with same prompt as legacy flow above.
80
-
81
- **Then check if .specd/codebase/ already exists:**
82
-
83
- ```bash
84
- ls -la .specd/codebase/ 2>/dev/null
85
- ```
86
-
87
- **If exists:**
88
-
89
- Use the AskUserQuestion tool:
90
-
91
- ```json
92
- {
93
- "questions": [{
94
- "question": "Codebase map already exists. What would you like to do?",
95
- "header": "Existing map",
96
- "options": [
97
- {
98
- "label": "Refresh - remap codebase",
99
- "description": "Delete existing docs and generate fresh analysis"
100
- },
101
- {
102
- "label": "Skip - use existing",
103
- "description": "Keep current codebase map, no changes"
104
- }
105
- ],
106
- "multiSelect": false
107
- }]
108
- }
109
- ```
110
-
111
- If "Refresh": Delete .specd/codebase/, continue based on mode.
112
- If "Skip": Exit workflow
113
-
114
- **If doesn't exist:**
115
- Continue based on mode.
116
-
117
- **Mode branching (after check_existing resolves):**
118
- - If mode = "project": continue to check_existing_docs (existing single-project flow)
119
- - If mode = "orchestrator": continue to register_projects (multi-project flow, see below)
120
- </step>
121
-
122
- <step name="check_existing_docs">
123
- Check for existing documentation in the codebase:
124
-
125
- ```bash
126
- # Find common documentation files
127
- ls README* CONTRIBUTING* ARCHITECTURE* docs/ doc/ wiki/ 2>/dev/null
128
- find . -maxdepth 2 -name "*.md" -not -path "./node_modules/*" -not -path "./.git/*" 2>/dev/null | head -20
129
- ```
130
-
131
- **Always read and incorporate any docs found.** This is automatic - existing documentation contains tribal knowledge we want to capture.
132
-
133
- **Then ask user if there's more we missed:**
134
-
135
- Use the AskUserQuestion tool:
136
-
137
- ```json
138
- {
139
- "questions": [{
140
- "question": "Do you have any other documentation I should incorporate? (wiki, Notion, external docs, etc.)",
141
- "header": "More docs?",
142
- "options": [
143
- {
144
- "label": "No - that's everything",
145
- "description": "Proceed with what was found in the repo"
146
- },
147
- {
148
- "label": "Yes - I have more",
149
- "description": "I'll share additional documentation or context"
150
- }
151
- ],
152
- "multiSelect": false
153
- }]
154
- }
155
- ```
156
-
157
- **If user selects "Yes - I have more":**
158
- Wait for user to provide additional context (paste docs, share links, explain architecture).
159
- Incorporate this into the context for mapper agents.
160
-
161
- **Then continue to create_structure.**
162
- </step>
163
-
164
- <step name="create_structure">
165
- Create .specd/codebase/ directory:
166
-
167
- ```bash
168
- mkdir -p .specd/codebase
169
- ```
170
-
171
- **Create project-level config (DEC-012):**
172
-
173
- Write `.specd/config.json`:
174
- ```json
175
- {
176
- "type": "project",
177
- "specd_version": 1,
178
- "created": "{YYYY-MM-DD}"
179
- }
180
- ```
181
-
182
- This enables future version detection and mode detection for all workflows.
183
-
184
- **Documents to be created:**
185
- - MAP.md (from map mapper) — Navigation: function signatures, entry points, modules
186
- - PATTERNS.md (from patterns mapper) — Code examples: services, error handling, testing
187
- - STRUCTURE.md (from structure mapper) — Organization: where to put new code
188
- - CONCERNS.md (from concerns mapper) — Warnings: gotchas, anti-patterns, tech debt
189
-
190
- Continue to spawn_agents.
191
- </step>
192
-
193
- <step name="spawn_agents">
194
- Spawn 4 parallel specd-codebase-mapper agents.
195
-
196
- Use Task tool with `subagent_type="specd-codebase-mapper"` and `run_in_background=true` for parallel execution.
197
-
198
- **CRITICAL:** Use the dedicated `specd-codebase-mapper` agent, NOT `Explore`.
199
-
200
- **If existing documentation was found and user said to incorporate it:**
201
- Include a summary of the existing docs in each agent's prompt:
202
- ```
203
- Existing documentation context:
204
- {summary of README, ARCHITECTURE, CONTRIBUTING, etc.}
205
-
206
- Use this context to inform your analysis. Incorporate relevant architectural decisions, gotchas, and conventions mentioned in the docs.
207
- ```
208
-
209
- **Agent 1: Map Focus**
210
-
211
- Task tool parameters:
212
- ```
213
- subagent_type: "specd-codebase-mapper"
214
- model: "sonnet"
215
- run_in_background: true
216
- description: "Map codebase navigation"
217
- ```
218
-
219
- Prompt:
220
- ```
221
- Focus: map
222
-
223
- Create a navigation map of this codebase for Claude.
224
-
225
- Write MAP.md to .specd/codebase/ containing:
226
- - Entry points (where execution starts)
227
- - Core modules with function signatures
228
- - External integrations (services, env vars)
229
- - Key type definitions
230
-
231
- Extract ACTUAL function signatures from the code. Include file paths everywhere.
232
- Return confirmation only when done.
233
- ```
234
-
235
- **Agent 2: Patterns Focus**
236
-
237
- Task tool parameters:
238
- ```
239
- subagent_type: "specd-codebase-mapper"
240
- model: "sonnet"
241
- run_in_background: true
242
- description: "Map codebase patterns"
243
- ```
244
-
245
- Prompt:
246
- ```
247
- Focus: patterns
248
-
249
- Extract code patterns from this codebase for Claude to follow.
250
-
251
- Write PATTERNS.md to .specd/codebase/ containing:
252
- - Service/handler patterns (with real code examples)
253
- - Error handling patterns (with real code examples)
254
- - Testing patterns (with real code examples)
255
- - Mocking patterns (with real code examples)
256
- - Import conventions
257
-
258
- Use ACTUAL code from the codebase, not generic examples. Include file paths and line numbers.
259
- Return confirmation only when done.
260
- ```
261
-
262
- **Agent 3: Structure Focus**
263
-
264
- Task tool parameters:
265
- ```
266
- subagent_type: "specd-codebase-mapper"
267
- model: "sonnet"
268
- run_in_background: true
269
- description: "Map codebase structure"
270
- ```
271
-
272
- Prompt:
273
- ```
274
- Focus: structure
275
-
276
- Document where to put new code in this codebase.
277
-
278
- Write STRUCTURE.md to .specd/codebase/ containing:
279
- - Quick reference table: "I want to add X → put it in Y"
280
- - Directory purposes (what goes where)
281
- - Naming conventions
282
- - Where NOT to put code
283
- - Active migrations (if any)
284
-
285
- Be prescriptive: "Put new services in X" not "Services are in X".
286
- Return confirmation only when done.
287
- ```
288
-
289
- **Agent 4: Concerns Focus**
290
-
291
- Task tool parameters:
292
- ```
293
- subagent_type: "specd-codebase-mapper"
294
- model: "sonnet"
295
- run_in_background: true
296
- description: "Map codebase concerns"
297
- ```
298
-
299
- Prompt:
300
- ```
301
- Focus: concerns
302
-
303
- Find gotchas and problems in this codebase that Claude needs to know.
304
-
305
- Write CONCERNS.md to .specd/codebase/ containing:
306
- - Gotchas (surprising but intentional behaviors)
307
- - Anti-patterns (what NOT to do, with examples)
308
- - Tech debt (with guidance on working around it)
309
- - Fragile areas (with safe modification guidance)
310
- - Dependency notes (pinned versions, upgrade blockers)
311
- - Performance notes
312
-
313
- Gotchas section is MOST IMPORTANT. Include file paths for everything.
314
- Return confirmation only when done.
315
- ```
316
-
317
- Continue to collect_confirmations.
318
- </step>
319
-
320
- <step name="collect_confirmations">
321
- Wait for all 4 agents to complete.
322
-
323
- Read each agent's output file to collect confirmations.
324
-
325
- **Expected confirmation format from each agent:**
326
- ```
327
- ## Mapping Complete
328
-
329
- **Focus:** {focus}
330
- **Document written:** `.specd/codebase/{DOC}.md` ({N} lines)
331
-
332
- Key findings:
333
- - {summary}
334
- ```
335
-
336
- If any agent failed, note the failure and continue with successful documents.
337
-
338
- Continue to verify_output.
339
- </step>
340
-
341
- <step name="verify_output">
342
- Verify all documents created successfully:
343
-
344
- ```bash
345
- ls -la .specd/codebase/
346
- wc -l .specd/codebase/*.md
347
- ```
348
-
349
- **Verification checklist:**
350
- - All 4 documents exist (MAP.md, PATTERNS.md, STRUCTURE.md, CONCERNS.md)
351
- - No empty documents (each should have >20 lines)
352
-
353
- If any documents missing or empty, note which agents may have failed.
354
-
355
- Continue to commit_codebase_map.
356
- </step>
357
-
358
- <step name="commit_codebase_map">
359
- Commit the codebase map.
360
-
361
- @~/.claude/specdacular/references/commit-docs.md
362
-
363
- - **$FILES:** `.specd/codebase/*.md .specd/config.json`
364
- - **$MESSAGE:** `docs: map codebase for Claude` with list of documents created
365
- - **$LABEL:** `codebase map`
366
-
367
- Continue to completion.
368
- </step>
369
-
370
- <step name="completion">
371
- Present completion summary.
372
-
373
- **Get line counts:**
374
- ```bash
375
- wc -l .specd/codebase/*.md
376
- ```
377
-
378
- **Output format:**
379
-
380
- ```
381
- Codebase mapped for Claude.
382
-
383
- Created .specd/codebase/:
384
- - MAP.md ([N] lines) — Navigation: modules, functions, entry points
385
- - PATTERNS.md ([N] lines) — Code examples to follow
386
- - STRUCTURE.md ([N] lines) — Where to put new code
387
- - CONCERNS.md ([N] lines) — Gotchas and anti-patterns
388
-
389
- These docs help Claude understand your codebase. They'll be referenced during planning and implementation.
390
-
391
- To review: `cat .specd/codebase/MAP.md`
392
- ```
393
-
394
- End workflow.
395
- </step>
396
-
397
- <!-- ═══════════════════════════════════════════════════════
398
- MULTI-PROJECT FLOW
399
- Reached when detect_mode sets mode = "orchestrator".
400
- check_existing branches here instead of to check_existing_docs.
401
- ═══════════════════════════════════════════════════════ -->
402
-
403
- <step name="register_projects">
404
- Register sub-projects for orchestrator mode.
405
-
406
- **Scan for project markers in immediate subdirectories:**
407
-
408
- ```bash
409
- # Find directories with common project markers
410
- for dir in */; do
411
- if [ -f "${dir}package.json" ] || [ -f "${dir}go.mod" ] || [ -f "${dir}Cargo.toml" ] || [ -f "${dir}pyproject.toml" ] || [ -f "${dir}pom.xml" ] || [ -f "${dir}build.gradle" ] || [ -f "${dir}Makefile" ] || [ -f "${dir}Gemfile" ]; then
412
- echo "${dir%/}"
413
- fi
414
- done
415
- ```
416
-
417
- **Present found projects:**
418
- ```
419
- Found these potential projects:
420
- - {dir1}/ (has package.json)
421
- - {dir2}/ (has go.mod)
422
- - {dir3}/ (has package.json)
423
-
424
- These will be registered as sub-projects.
425
- ```
426
-
427
- Use AskUserQuestion:
428
- - header: "Projects"
429
- - question: "Are these the right projects? You can adjust in the next step."
430
- - options:
431
- - "Yes, these are correct" — Continue with found projects
432
- - "I need to adjust" — Let user add/remove projects
433
-
434
- **If "I need to adjust":**
435
- Ask user to describe which projects to add or remove. Update the list accordingly.
436
-
437
- **For each project, ask for a one-liner description:**
438
- Use AskUserQuestion for each project (or batch if 3 or fewer):
439
- - header: "{project-name}"
440
- - question: "Brief description of {project-name}?"
441
- - options: Provide 2-3 inferred descriptions based on directory contents + "Something else"
442
-
443
- **Build project registry:**
444
- ```json
445
- [
446
- {"name": "{dir1}", "path": "./{dir1}", "description": "{user description}"},
447
- {"name": "{dir2}", "path": "./{dir2}", "description": "{user description}"}
448
- ]
449
- ```
450
-
451
- Continue to create_orchestrator_structure.
452
- </step>
453
-
454
- <step name="create_orchestrator_structure">
455
- Create orchestrator-level .specd/ directory and config.
456
-
457
- ```bash
458
- mkdir -p .specd/codebase
459
- ```
460
-
461
- **Write .specd/config.json (DEC-006, DEC-012):**
462
- ```json
463
- {
464
- "type": "orchestrator",
465
- "specd_version": 1,
466
- "created": "{YYYY-MM-DD}",
467
- "projects": [
468
- {"name": "{name}", "path": "{path}", "description": "{description}"}
469
- ]
470
- }
471
- ```
472
-
473
- **Create per-project .specd/ structures:**
474
- For each registered project:
475
- ```bash
476
- mkdir -p {project-path}/.specd/codebase
477
- ```
478
-
479
- **Write per-project config.json (DEC-012):**
480
- For each registered project, write `{project-path}/.specd/config.json`:
481
- ```json
482
- {
483
- "type": "project",
484
- "specd_version": 1,
485
- "created": "{YYYY-MM-DD}"
486
- }
487
- ```
488
-
489
- Continue to check_existing_docs_multi.
490
- </step>
491
-
492
- <step name="check_existing_docs_multi">
493
- Check for existing documentation across all projects.
494
-
495
- For each registered project, check for docs:
496
- ```bash
497
- ls {project-path}/README* {project-path}/CONTRIBUTING* {project-path}/ARCHITECTURE* {project-path}/docs/ 2>/dev/null
498
- ```
499
-
500
- Also check root-level docs:
501
- ```bash
502
- ls README* CONTRIBUTING* ARCHITECTURE* docs/ 2>/dev/null
503
- ```
504
-
505
- **Always read and incorporate any docs found** — same as single-project flow.
506
-
507
- Ask user for additional docs (same AskUserQuestion as check_existing_docs).
508
-
509
- Continue to spawn_per_project_agents.
510
- </step>
511
-
512
- <step name="spawn_per_project_agents">
513
- Spawn 4 mapper agents per sub-project, all in parallel.
514
-
515
- For each registered project, spawn the same 4 agents as the single-project flow (map, patterns, structure, concerns), but scoped to the project's directory.
516
-
517
- **CRITICAL:** Each agent's prompt must specify the project path so it writes to `{project-path}/.specd/codebase/`.
518
-
519
- Use Task tool with `subagent_type="specd-codebase-mapper"` and `run_in_background=true`.
520
-
521
- **Per project, spawn 4 agents:**
522
-
523
- Agent prompts follow the same pattern as the single-project agents in `spawn_agents`, with these modifications:
524
- - Working directory context: "This project is at {project-path}/"
525
- - Output path: "Write to {project-path}/.specd/codebase/{DOC}.md"
526
- - Scope: "Only analyze code within {project-path}/"
527
-
528
- **If existing documentation was found for a project:**
529
- Include project-specific docs in that project's agent prompts (same as single-project).
530
-
531
- All agents (across all projects) are spawned simultaneously for maximum parallelism.
532
-
533
- Wait for all agents to complete. Verify each project has all 4 documents:
534
-
535
- ```bash
536
- # Verify per-project docs
537
- for project in {project-paths}; do
538
- echo "Checking $project..."
539
- ls -la "$project/.specd/codebase/"
540
- wc -l "$project/.specd/codebase/"*.md 2>/dev/null
541
- done
542
- ```
543
-
544
- If any agents failed, note which project/document and continue.
545
-
546
- Continue to spawn_orchestrator_agent.
547
- </step>
548
-
549
- <step name="spawn_orchestrator_agent">
550
- Spawn a single orchestrator mapper agent to synthesize system-level docs (DEC-007: runs AFTER all per-project mappers complete).
551
-
552
- This agent reads sub-project codebase docs and scans codebases for system-level artifacts.
553
-
554
- Use Task tool:
555
- ```
556
- subagent_type: "specd-codebase-mapper"
557
- model: "sonnet"
558
- run_in_background: true
559
- description: "Map orchestrator system docs"
560
- ```
561
-
562
- Prompt:
563
- ```
564
- Focus: orchestrator
565
-
566
- You are mapping a multi-project system. Sub-project analysis is already complete.
567
-
568
- **Projects in this system:**
569
- {For each project: name, path, description}
570
-
571
- **Sub-project docs available:**
572
- {For each project: list the 4 .specd/codebase/ files with paths}
573
-
574
- **Your job:**
575
- 1. Read all sub-project codebase docs (MAP.md, PATTERNS.md, STRUCTURE.md, CONCERNS.md for each project)
576
- 2. Scan codebases for system-level artifacts:
577
- - docker-compose.yml, docker files
578
- - CI/CD configs (.github/workflows/, .gitlab-ci.yml, etc.)
579
- - Shared configs (eslint, prettier, tsconfig at root)
580
- - Cross-project imports or references
581
- - Shared databases, APIs, message queues
582
- 3. Write 4 orchestrator-level docs to .specd/codebase/:
583
-
584
- **PROJECTS.md** — Project registry with responsibilities and entry points
585
- Follow template structure: registry table, per-project details, codebase doc links.
586
-
587
- **TOPOLOGY.md** — How projects communicate
588
- Follow template: per-relationship sections with communication method, pattern, shared domains, source of truth, data flow. Include shared resources table and Mermaid diagram.
589
-
590
- **CONTRACTS.md** — Shared interface descriptions (keep loose per DEC-008)
591
- Follow template: per-relationship contract nature. Describe relationships, not specific endpoints.
592
-
593
- **CONCERNS.md** — Cross-cutting system-level gotchas
594
- Follow template: per-concern with scope, issue, impact, mitigation. Focus on SYSTEM-level concerns that span projects, not project-internal concerns.
595
-
596
- Return confirmation with line counts for all 4 docs.
597
- ```
598
-
599
- Wait for orchestrator agent to complete. Verify docs exist:
600
-
601
- ```bash
602
- ls -la .specd/codebase/
603
- wc -l .specd/codebase/*.md
604
- ```
605
-
606
- Continue to commit_orchestrator_map.
607
- </step>
608
-
609
- <step name="commit_orchestrator_map">
610
- Commit all mapping results (orchestrator + all sub-projects).
611
-
612
- **IMPORTANT — Check auto-commit setting first:**
613
-
614
- ```bash
615
- cat .specd/config.json 2>/dev/null || echo '{"auto_commit_docs": true}'
616
- ```
617
-
618
- **If `auto_commit_docs` is `false`:** Do NOT commit. Print:
619
- ```
620
- Auto-commit disabled for docs — orchestrator codebase map not committed.
621
- ```
622
- Skip to orchestrator_completion.
623
-
624
- **If `auto_commit_docs` is `true` or not set (default):**
625
-
626
- ```bash
627
- # Add orchestrator docs and config
628
- git add .specd/codebase/*.md .specd/config.json
629
-
630
- # Add per-project docs and configs
631
- # {For each project:}
632
- git add {project-path}/.specd/codebase/*.md {project-path}/.specd/config.json
633
-
634
- git commit -m "$(cat <<'EOF'
635
- docs: map multi-project codebase for Claude
636
-
637
- Orchestrator:
638
- - PROJECTS.md - Project registry
639
- - TOPOLOGY.md - Communication patterns
640
- - CONTRACTS.md - Shared interfaces
641
- - CONCERNS.md - System-level gotchas
642
-
643
- Projects mapped:
644
- {For each project: - {name}: MAP, PATTERNS, STRUCTURE, CONCERNS}
645
-
646
- Co-Authored-By: Claude <noreply@anthropic.com>
647
- EOF
648
- )"
649
- ```
650
-
651
- Continue to orchestrator_completion.
652
- </step>
653
-
654
- <step name="orchestrator_completion">
655
- Present multi-project completion summary.
656
-
657
- **Get line counts for orchestrator and each project:**
658
- ```bash
659
- wc -l .specd/codebase/*.md
660
- # For each project:
661
- wc -l {project-path}/.specd/codebase/*.md
662
- ```
663
-
664
- **Output format:**
665
-
666
- ```
667
- Multi-project codebase mapped for Claude.
668
-
669
- Orchestrator (.specd/codebase/):
670
- - PROJECTS.md ({N} lines) — Project registry
671
- - TOPOLOGY.md ({N} lines) — Communication patterns
672
- - CONTRACTS.md ({N} lines) — Shared interfaces
673
- - CONCERNS.md ({N} lines) — System-level concerns
674
-
675
- {For each project:}
676
- {project-name} ({project-path}/.specd/codebase/):
677
- - MAP.md ({N} lines) — Navigation
678
- - PATTERNS.md ({N} lines) — Code patterns
679
- - STRUCTURE.md ({N} lines) — File organization
680
- - CONCERNS.md ({N} lines) — Project-level gotchas
681
-
682
- These docs help Claude understand your system across projects.
683
- They'll be referenced during planning and implementation.
684
- ```
685
-
686
- End workflow.
687
- </step>
688
-
689
- </process>
690
-
691
- <success_criteria>
692
- **Single-project mode:**
693
- - .specd/codebase/ directory created
694
- - .specd/config.json created with type and specd_version (DEC-012)
695
- - 4 parallel specd-codebase-mapper agents spawned with run_in_background=true
696
- - Agents write documents directly (orchestrator doesn't receive document contents)
697
- - All 4 documents exist: MAP.md, PATTERNS.md, STRUCTURE.md, CONCERNS.md
698
- - Documents contain real code examples (not placeholders)
699
- - Clear completion summary with line counts
700
-
701
- **Multi-project mode (additional):**
702
- - detect_mode correctly identifies multi-project setup
703
- - Projects registered with name, path, description
704
- - .specd/config.json created with type=orchestrator and projects array (DEC-006)
705
- - Per-project .specd/config.json created with type=project (DEC-012)
706
- - 4 agents spawned per project, all in parallel
707
- - Orchestrator agent runs after per-project agents complete (DEC-007)
708
- - Orchestrator docs: PROJECTS.md, TOPOLOGY.md, CONTRACTS.md, CONCERNS.md
709
- - Per-project docs: MAP.md, PATTERNS.md, STRUCTURE.md, CONCERNS.md per project
710
- - Multi-project completion summary with per-project line counts
711
-
712
- **Legacy detection:**
713
- - .specd/ without config.json detected as legacy
714
- - User prompted to re-map
715
- </success_criteria>