@draht/coding-agent 2026.3.5 → 2026.3.6

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 (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/agents/architect.md +1 -0
  3. package/agents/debugger.md +1 -0
  4. package/agents/git-committer.md +1 -0
  5. package/agents/implementer.md +1 -0
  6. package/agents/reviewer.md +1 -0
  7. package/agents/security-auditor.md +1 -0
  8. package/agents/verifier.md +1 -0
  9. package/dist/agents/architect.md +1 -0
  10. package/dist/agents/debugger.md +1 -0
  11. package/dist/agents/git-committer.md +1 -0
  12. package/dist/agents/implementer.md +1 -0
  13. package/dist/agents/reviewer.md +1 -0
  14. package/dist/agents/security-auditor.md +1 -0
  15. package/dist/agents/verifier.md +1 -0
  16. package/dist/config.d.ts +7 -0
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +15 -0
  19. package/dist/config.js.map +1 -1
  20. package/dist/core/package-manager.d.ts.map +1 -1
  21. package/dist/core/package-manager.js +7 -7
  22. package/dist/core/package-manager.js.map +1 -1
  23. package/dist/core/prompt-templates.d.ts.map +1 -1
  24. package/dist/core/prompt-templates.js +4 -4
  25. package/dist/core/prompt-templates.js.map +1 -1
  26. package/dist/core/resource-loader.d.ts.map +1 -1
  27. package/dist/core/resource-loader.js +9 -8
  28. package/dist/core/resource-loader.js.map +1 -1
  29. package/dist/core/settings-manager.d.ts.map +1 -1
  30. package/dist/core/settings-manager.js +2 -2
  31. package/dist/core/settings-manager.js.map +1 -1
  32. package/dist/core/skills.d.ts.map +1 -1
  33. package/dist/core/skills.js +3 -3
  34. package/dist/core/skills.js.map +1 -1
  35. package/dist/migrations.d.ts.map +1 -1
  36. package/dist/migrations.js +2 -2
  37. package/dist/migrations.js.map +1 -1
  38. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  39. package/dist/modes/interactive/components/config-selector.js +3 -3
  40. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  41. package/dist/prompts/commands/discuss-phase.md +10 -0
  42. package/dist/prompts/commands/execute-phase.md +51 -34
  43. package/dist/prompts/commands/fix.md +8 -6
  44. package/dist/prompts/commands/init-project.md +12 -0
  45. package/dist/prompts/commands/map-codebase.md +17 -18
  46. package/dist/prompts/commands/new-project.md +12 -0
  47. package/dist/prompts/commands/next-milestone.md +5 -3
  48. package/dist/prompts/commands/plan-phase.md +27 -5
  49. package/dist/prompts/commands/quick.md +12 -5
  50. package/dist/prompts/commands/review.md +10 -10
  51. package/dist/prompts/commands/verify-work.md +31 -17
  52. package/package.json +4 -4
  53. package/prompts/commands/discuss-phase.md +10 -0
  54. package/prompts/commands/execute-phase.md +51 -34
  55. package/prompts/commands/fix.md +8 -6
  56. package/prompts/commands/init-project.md +12 -0
  57. package/prompts/commands/map-codebase.md +17 -18
  58. package/prompts/commands/new-project.md +12 -0
  59. package/prompts/commands/next-milestone.md +5 -3
  60. package/prompts/commands/plan-phase.md +27 -5
  61. package/prompts/commands/quick.md +12 -5
  62. package/prompts/commands/review.md +10 -10
  63. package/prompts/commands/verify-work.md +31 -17
@@ -4,7 +4,7 @@ description: "Analyze existing codebase before planning"
4
4
 
5
5
  # /map-codebase
6
6
 
7
- Analyze existing codebase before planning.
7
+ Analyze existing codebase before planning, using subagents for parallel analysis.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -16,23 +16,22 @@ Directory: $1
16
16
  ## Steps
17
17
  1. Run `draht-tools map-codebase $1`
18
18
  2. Tool generates: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, CONCERNS.md
19
- 3. Review output, supplement with your own analysis if needed
20
- 4. Identify implicit bounded contexts from directory structure:
21
- - Look for top-level `src/` subdirectories, packages, or modules that encapsulate a coherent domain concept
22
- - Note any cross-directory coupling that suggests context boundaries are blurred
23
- 5. Extract domain language from existing code:
24
- - Collect PascalCase class/interface/type names, key function names, and database table/collection names
25
- - Look for repeated nouns that represent core domain concepts (e.g., `Order`, `Invoice`, `Subscription`)
26
- 6. If `.planning/DOMAIN.md` does not already exist, create it with:
19
+ 3. **Run parallel deep analysis via subagents:**
20
+ Use the `subagent` tool in **parallel mode** with these tasks:
21
+ - `architect` agent: "Analyze the codebase at $1. Identify bounded contexts from directory structure — look for top-level src/ subdirectories, packages, or modules that encapsulate coherent domain concepts. Note any cross-directory coupling suggesting blurred context boundaries. Extract domain language: collect PascalCase class/interface/type names, key function names, database table/collection names. Look for repeated nouns representing core domain concepts. Output a structured list of: bounded contexts (name + description), domain terms (glossary), aggregates per context, and context relationships (upstream/downstream, shared kernel, ACL). Do NOT run draht, draht-tools, or pi commands."
22
+ - `verifier` agent: "Analyze the test infrastructure at $1. Discover: test framework(s) in use (check package.json, config files), test directory conventions (co-located, __tests__/, test/), existing coverage configuration and goals, which layers have tests (unit, integration, e2e), gaps and recommendations. Output a structured test strategy report. Do NOT run draht, draht-tools, or pi commands."
23
+
24
+ 4. Collect subagent results and merge with the draht-tools output
25
+ 5. Create `.planning/DOMAIN.md` (if it doesn't exist) with:
27
26
  - `## Bounded Contexts` — one entry per discovered context with a brief description
28
27
  - `## Ubiquitous Language` — glossary of extracted domain terms
29
- - `## Context Map` — rough diagram or list showing how contexts relate
30
- - `## Aggregates` — list aggregates and their root entities per context
28
+ - `## Context Map` — how bounded contexts relate (upstream/downstream, shared kernel, ACL)
29
+ - `## Aggregates` — aggregates and their root entities per context
31
30
  - `## Domain Events` — any existing event names or patterns discovered
32
- 7. Discover test infrastructure and document findings in `.planning/TEST-STRATEGY.md`:
33
- - Test framework(s) in use (Jest, Vitest, Bun test, Mocha, etc.)
34
- - Test directory conventions (co-located, `__tests__/`, `test/`, etc.)
35
- - Existing coverage configuration and goals (if any)
36
- - Which layers have tests today (unit, integration, e2e)
37
- - Gaps and recommendations
38
- 8. Commit: `draht-tools commit-docs "map existing codebase"`
31
+ 6. Create `.planning/TEST-STRATEGY.md` with:
32
+ - `## Test Framework` chosen framework and rationale
33
+ - `## Directory Conventions` where test files live relative to source
34
+ - `## Coverage Goals` — target coverage percentage and which paths are critical
35
+ - `## Testing Levels` what is tested at unit level vs integration vs e2e, with examples
36
+ - `## Excluded` — what is explicitly not tested and why
37
+ 7. Commit: `draht-tools commit-docs "map existing codebase"`
@@ -37,6 +37,18 @@ Description: $ARGUMENTS
37
37
  11. Run `draht-tools init-state`
38
38
  12. Git commit via `draht-tools commit-docs "initialize project planning"`
39
39
 
40
+ ## Workflow
41
+ After project initialization, phases are executed one at a time in new sessions:
42
+
43
+ ```
44
+ /new-project → /new → /discuss-phase 1 → /new → /plan-phase 1 → /new → /execute-phase 1 → /new → /verify-work 1
45
+ → /new → /discuss-phase 2 → /new → /plan-phase 2 → /new → /execute-phase 2 → /new → /verify-work 2
46
+ → ... (repeat for all phases in the milestone)
47
+ → /new → /next-milestone (only after ALL phases are complete)
48
+ ```
49
+
50
+ Each step runs in its own session (`/new` between steps). Do NOT suggest `/next-milestone` until every phase in the milestone is verified.
51
+
40
52
  ## Rules
41
53
  - Ask 1-2 questions at a time, never dump 10 at once
42
54
  - Follow threads based on answers
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: "Plan the next milestone after current one completes"
2
+ description: "Plan the next milestone after ALL phases in the current milestone are complete"
3
3
  ---
4
4
 
5
5
  # /next-milestone
6
6
 
7
- Plan the next milestone after the current one is complete.
7
+ Plan the next milestone after ALL phases in the current one are complete.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -13,7 +13,9 @@ Plan the next milestone after the current one is complete.
13
13
 
14
14
  ## Prerequisites
15
15
  - `.planning/ROADMAP.md` must exist
16
- - Current milestone should be complete or nearly complete
16
+ - ALL phases in the current milestone must be complete (verified via /verify-work)
17
+ - This command is ONLY for milestone transitions — NOT for moving between phases within a milestone
18
+ - Between phases, use `/discuss-phase`, `/plan-phase`, `/execute-phase`, `/verify-work` — never `/next-milestone`
17
19
 
18
20
  ## Steps
19
21
  1. Load project context:
@@ -4,7 +4,7 @@ description: "Create atomic execution plans for a roadmap phase"
4
4
 
5
5
  # /plan-phase
6
6
 
7
- Create atomic execution plans for a roadmap phase.
7
+ Create atomic execution plans for a roadmap phase, using subagents for parallel plan creation.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -21,10 +21,22 @@ Phase: $1
21
21
  b. Derive observable truths (3-7 from user perspective)
22
22
  c. From each observable truth, derive the test scenarios that would prove it (specific inputs → expected outputs or state changes)
23
23
  d. Map to required artifacts (files, endpoints, schemas)
24
- e. Break into atomic tasks (2-5 per plan)
25
- 4. Write plans: `draht-tools create-plan $1 P`
26
- 5. Validate: `draht-tools validate-plans $1`
27
- 6. Commit: `draht-tools commit-docs "create phase $1 plans"`
24
+ e. Break into plan groups of 2-5 tasks each
25
+ 4. Identify which plans are independent (no shared files, no dependency edges)
26
+ 5. **Delegate plan creation to subagents:**
27
+ - For independent plans: use the `subagent` tool in **parallel mode** with `architect` agents, one per plan. Each task should include the phase context, the specific observable truths, target files, and the XML task format (below).
28
+ - For dependent plans: create them sequentially, each via a **single** `subagent` call to `architect`, passing the outputs of predecessor plans as context.
29
+ - Each subagent task must include:
30
+ - The phase context summary (paste it — subagents cannot run draht-tools)
31
+ - The specific observable truths this plan must satisfy
32
+ - The target files/artifacts
33
+ - The XML task format specification (below)
34
+ - Instruction to output the plan as XML (you will save it via `draht-tools create-plan`)
35
+
36
+ 6. Collect all plan outputs from subagents
37
+ 7. Save plans yourself: `draht-tools create-plan $1 P` for each plan
38
+ 8. Validate: `draht-tools validate-plans $1`
39
+ 9. Commit: `draht-tools commit-docs "create phase $1 plans"`
28
40
 
29
41
  ## Plan Format
30
42
  Plans use XML task format:
@@ -60,6 +72,16 @@ Plans use XML task format:
60
72
 
61
73
  Task types: `auto`, `checkpoint:human-verify`, `checkpoint:decision`
62
74
 
75
+ ## Workflow
76
+ This is one step in the per-phase cycle. Each step runs in its own session (`/new` between steps):
77
+
78
+ ```
79
+ /discuss-phase N → /new → /plan-phase N → /new → /execute-phase N → /new → /verify-work N → /new → /discuss-phase N+1 → ...
80
+ ```
81
+
82
+ After completing this command, tell the user to start a new session and run `/execute-phase $1`.
83
+ Do NOT suggest `/next-milestone` — that is only after ALL phases in the milestone are verified.
84
+
63
85
  ## Domain Rules for Plans
64
86
  - File/module structure should mirror bounded contexts (e.g., `src/billing/`, `src/catalog/`)
65
87
  - Never scatter one aggregate's logic across multiple contexts without an explicit ACL
@@ -16,10 +16,17 @@ Task: $ARGUMENTS
16
16
  ## Steps
17
17
  1. Run `draht-tools next-quick-number` to get task number
18
18
  2. Create quick plan: `draht-tools create-quick-plan NNN "$ARGUMENTS"`
19
- 3. Execute tasks following the TDD cycle:
20
- - **🔴 RED** — Write a failing test that describes the desired behaviour
21
- - **🟢 GREEN** — Write the minimum implementation to make it pass
22
- - **🔵 REFACTOR** — Clean up while keeping the test green
23
- - *Exception: skip the TDD cycle only for pure config or documentation-only tasks that have no testable behaviour*
19
+ 3. **Delegate execution to subagent**: Use the `subagent` tool in **single mode** with the `implementer` agent:
20
+ "Execute this task: $ARGUMENTS
21
+
22
+ Follow the TDD cycle:
23
+ - RED Write a failing test that describes the desired behaviour
24
+ - GREEN — Write the minimum implementation to make it pass
25
+ - REFACTOR — Clean up while keeping the test green
26
+ Exception: skip the TDD cycle only for pure config or documentation-only tasks that have no testable behaviour.
27
+
28
+ After completion, report: files changed, tests written, and verification results.
29
+ Do NOT run draht, draht-tools, draht help, or pi commands — use only standard tools."
30
+
24
31
  4. Write summary: `draht-tools write-quick-summary NNN`
25
32
  5. Update state: `draht-tools update-state`
@@ -4,7 +4,7 @@ description: "Code review and security audit of recent changes"
4
4
 
5
5
  # /review
6
6
 
7
- Ad-hoc code review and security audit of recent changes or a specific scope.
7
+ Code review and security audit of recent changes, using subagents for parallel analysis.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -17,16 +17,16 @@ If no scope given, reviews all recent uncommitted changes.
17
17
 
18
18
  ## Steps
19
19
  1. Identify the scope:
20
- - If argument given: review those files/directories/description
20
+ - If argument given: use those files/directories/description as scope
21
21
  - If no argument: run `git diff --stat` and `git diff --cached --stat` to find changes
22
- 2. For each changed file, examine:
23
- - Correctness: logic errors, off-by-one, null handling, error paths
24
- - Type safety: any `as` casts, `any` types, missing null checks
25
- - Conventions: naming, file organization, import style
26
- - Security: injection risks, auth bypasses, secrets in code, unsafe deserialization
27
- - Performance: unnecessary allocations, missing indexes, N+1 queries
28
- 3. Produce a prioritized findings report:
22
+ 2. Determine the list of changed files and produce a scope summary
23
+ 3. **Delegate to subagents in parallel:**
24
+ Use the `subagent` tool in **parallel mode** with these tasks:
25
+ - `reviewer` agent: "Review the following code changes for correctness, type safety, conventions, and potential issues. Scope: <scope summary and file list>. Read each changed file to understand the changes. For each finding: cite the exact file and line, explain the issue, suggest the fix. Prioritize: Critical (must fix) > Important (should fix) > Minor (style/optional). Do NOT run draht, draht-tools, or pi commands."
26
+ - `security-auditor` agent: "Audit the following code changes for security vulnerabilities. Scope: <scope summary and file list>. Read each changed file. Check for: injection risks, auth bypasses, secrets in code, unsafe deserialization, path traversal, prototype pollution. Report findings with severity, file, line, and recommendation. Do NOT run draht, draht-tools, or pi commands."
27
+
28
+ 4. Collect and merge results from both subagents
29
+ 5. Produce a unified, prioritized findings report:
29
30
  - **Critical** — must fix before merge (security, data loss, crashes)
30
31
  - **Important** — should fix (bugs, type issues, missing error handling)
31
32
  - **Minor** — style, naming, or optional improvements
32
- 4. For each finding: cite the exact file and line, explain the issue, suggest the fix
@@ -4,7 +4,7 @@ description: "Acceptance testing of completed phase work"
4
4
 
5
5
  # /verify-work
6
6
 
7
- Walk through acceptance testing of completed phase work.
7
+ Walk through acceptance testing of completed phase work, using subagents for parallel verification.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -14,20 +14,34 @@ Walk through acceptance testing of completed phase work.
14
14
  Phase: $1
15
15
 
16
16
  ## Steps
17
- 1. Run full test suite and capture results:
18
- - Execute all tests (`bun test` or project-specific runner)
19
- - Record pass/fail counts verification cannot proceed if tests are failing
20
- 2. Check domain language violations:
21
- - Load `.planning/DOMAIN.md` and extract all defined terms
22
- - Scan source files for PascalCase identifiers not present in the glossary
23
- - Flag any bounded context boundary violations (cross-context direct imports)
24
- 3. Run quality gate: `draht-tools quality-gate --strict`
25
- 4. Run `draht-tools extract-deliverables $1` to get testable items
26
- 5. Walk user through each deliverable one at a time
27
- 6. Record results (pass/fail/partially/skip)
28
- 7. For failures: diagnose and create fix plans via `draht-tools create-fix-plan $1 P`
17
+ 1. Run `draht-tools extract-deliverables $1` to get testable items
18
+ 2. **Run parallel verification via subagents:**
19
+ Use the `subagent` tool in **parallel mode** with these tasks:
20
+ - `verifier` agent: "Run the full test suite for this project. Check package.json for the test command. Record pass/fail counts. Then run any available lint and typecheck commands (e.g. npm run check, npm run lint, npx tsc --noEmit). Report all results with error details. Do NOT run draht, draht-tools, or pi commands."
21
+ - `security-auditor` agent: "Audit the recent code changes (use git log and git diff to find them). Check for injection risks, auth bypasses, secrets in code, unsafe patterns. Report findings by severity. Do NOT run draht, draht-tools, or pi commands."
22
+ - `reviewer` agent: "Review the recent code changes (use git log and git diff). Check domain language compliance against `.planning/DOMAIN.md` if it exists — scan for identifiers not in the glossary and cross-context boundary violations. Report findings. Do NOT run draht, draht-tools, or pi commands."
23
+
24
+ 3. Collect results from all subagents
25
+ 4. Walk user through each deliverable one at a time, incorporating findings from the parallel checks
26
+ 5. Record results (pass/fail/partially/skip)
27
+ 6. For failures: diagnose and create fix plans via `draht-tools create-fix-plan $1 P`
29
28
  - Fix plans MUST include a reproducing test that demonstrates the failure before any implementation
30
- 8. Write UAT report: `draht-tools write-uat $1`
31
- - Report must include: test health summary (pass/fail/coverage), domain model status (any glossary violations), deliverable results
32
- 9. If all passed: mark phase complete
33
- 10. If failures: route to `execute-phase $1 --gaps-only`
29
+ 7. Write UAT report: `draht-tools write-uat $1`
30
+ - Report must include: test health summary (pass/fail/coverage), security audit results, domain model status (any glossary violations), deliverable results
31
+ 8. If all passed: mark phase complete.
32
+ - If more phases remain in the milestone: tell the user to start a new session and run `/discuss-phase N+1`.
33
+ - If ALL phases in the milestone are complete: tell the user to start a new session and run `/next-milestone`.
34
+ 9. If failures: route to `execute-phase $1 --gaps-only`
35
+
36
+ ## Workflow
37
+ This is the last step in the per-phase cycle. Each step runs in its own session (`/new` between steps):
38
+
39
+ ```
40
+ /discuss-phase N → /new → /plan-phase N → /new → /execute-phase N → /new → /verify-work N
41
+ ```
42
+
43
+ After verify-work passes:
44
+ - More phases remaining → `/new` → `/discuss-phase N+1`
45
+ - ALL phases in milestone verified → `/new` → `/next-milestone`
46
+
47
+ `/next-milestone` is ONLY for generating new phases after every phase in the current milestone is complete.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draht/coding-agent",
3
- "version": "2026.3.5",
3
+ "version": "2026.3.6",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "drahtConfig": {
@@ -46,9 +46,9 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@mariozechner/jiti": "^2.6.2",
49
- "@draht/agent-core": "2026.3.5",
50
- "@draht/ai": "2026.3.5",
51
- "@draht/tui": "2026.3.5",
49
+ "@draht/agent-core": "2026.3.6",
50
+ "@draht/ai": "2026.3.6",
51
+ "@draht/tui": "2026.3.6",
52
52
  "@silvia-odwyer/photon-node": "^0.3.4",
53
53
  "chalk": "^5.5.0",
54
54
  "cli-highlight": "^2.1.11",
@@ -21,6 +21,16 @@ Phase: $1
21
21
  5. Record decisions with `draht-tools save-context $1`
22
22
  6. Commit: `draht-tools commit-docs "capture phase $1 context"`
23
23
 
24
+ ## Workflow
25
+ This is one step in the per-phase cycle. Each step runs in its own session (`/new` between steps):
26
+
27
+ ```
28
+ /discuss-phase N → /new → /plan-phase N → /new → /execute-phase N → /new → /verify-work N → /new → /discuss-phase N+1 → ...
29
+ ```
30
+
31
+ After completing this command, tell the user to start a new session and run `/plan-phase $1`.
32
+ Do NOT suggest `/next-milestone` — that is only after ALL phases in the milestone are verified.
33
+
24
34
  ## Gray Area Categories
25
35
  - **Visual features** → Layout, density, interactions, empty states
26
36
  - **APIs/CLIs** → Response format, error handling, auth
@@ -4,7 +4,7 @@ description: "Execute all plans in a phase with atomic commits"
4
4
 
5
5
  # /execute-phase
6
6
 
7
- Execute all plans in a phase with atomic commits.
7
+ Execute all plans in a phase with atomic commits, parallelizing independent plans via subagents.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -16,35 +16,47 @@ Arguments: $ARGUMENTS
16
16
 
17
17
  ## Steps
18
18
  1. Run `draht-tools discover-plans $1` to find and order plans
19
- 2. For each plan in dependency order:
20
- a. Load plan: `draht-tools read-plan $1 P`
21
- b. Execute each task in strict TDD cycle:
22
-
23
- **🔴 RED Write failing tests first**
24
- - Write the test cases from `<test>`
25
- - Run tests confirm they FAIL (if they pass, the test is wrong)
26
- - Commit failing tests: `draht-tools commit-task $1 P T "red: test description"`
27
-
28
- **🟢 GREEN Minimal implementation**
29
- - Write the minimum code from `<action>` to make tests pass
30
- - Use domain language from `<context>` and `<domain>` for all names
31
- - Run tests confirm they PASS
32
- - Commit: `draht-tools commit-task $1 P T "green: task name"`
33
-
34
- **🔵 REFACTOR Clean up with safety net**
35
- - Apply improvements from `<refactor>` (if any)
36
- - Run tests after each change — must stay green
37
- - Verify domain language compliance (names match DOMAIN.md)
38
- - Commit: `draht-tools commit-task $1 P T "refactor: description"`
39
-
40
- **✅ VERIFY**
41
- - Run the `<verify>` step
42
- - Confirm `<done>` criteria met
43
-
44
- c. Write summary: `draht-tools write-summary $1 P`
45
- 3. Phase verification: `draht-tools verify-phase $1`
46
- 4. Update state: `draht-tools update-state`
47
- 5. Final commit: `draht-tools commit-docs "complete phase $1 execution"`
19
+ 2. Read each plan file yourself (from `.planning/phases/`) and analyze dependencies to identify which plans can run in parallel vs sequential
20
+ 3. **Delegate execution to subagents:**
21
+ - For independent plans (no shared files, no dependency chain): use the `subagent` tool in **parallel mode** with `implementer` agents, one per plan.
22
+ - For dependent plans: execute them sequentially, each via a **single** `subagent` call to `implementer`, waiting for the previous to complete before starting the next.
23
+ - Each subagent task must include:
24
+ - The full plan content (paste it into the task the subagent cannot run draht-tools)
25
+ - The TDD cycle instructions (see template below)
26
+ - Instructions to commit with `git add <files> && git commit -m "description"`
27
+
28
+ 4. After all subagents complete, collect results and check for failures
29
+ 5. Run `draht-tools verify-phase $1` yourself (not the subagent)
30
+ 6. Run `draht-tools update-state` yourself
31
+ 7. Final commit: `draht-tools commit-docs "complete phase $1 execution"`
32
+ 8. After execution, tell the user to start a new session and run `/verify-work $1`.
33
+
34
+ ## Subagent Task Template
35
+
36
+ Each implementer subagent receives a task like:
37
+
38
+ ```
39
+ Execute this plan. Here is the full plan content:
40
+
41
+ <paste full plan XML here>
42
+
43
+ For each <task> in the plan, follow this TDD cycle:
44
+ 1. RED — Write failing tests from <test>. Run the test runner, confirm they FAIL. Commit with: git add <test-files> && git commit -m "red: <description>"
45
+ 2. GREEN — Write minimal implementation from <action> to make tests pass. Run tests, confirm PASS. Commit with: git add <files> && git commit -m "green: <task name>"
46
+ 3. REFACTOR — Apply <refactor> improvements if any. Tests must stay green after each change. Commit with: git add <files> && git commit -m "refactor: <description>"
47
+ 4. VERIFY Run the <verify> step, confirm <done> criteria are met.
48
+
49
+ Domain rules: Use ubiquitous language from .planning/DOMAIN.md (read it). Do not import across bounded context boundaries.
50
+ Checkpoint handling: type="auto" → execute silently. type="checkpoint:human-verify" → stop and report back what was built. type="checkpoint:decision" → stop and report the options.
51
+
52
+ Important: Do NOT run draht, draht-tools, draht help, or pi commands. Use only standard tools (read, bash, edit, write, grep, find, ls).
53
+ ```
54
+
55
+ ## Parallelization Rules
56
+ - Plans sharing no files and having no dependency edges can run in parallel
57
+ - If plan B depends on output of plan A, plan B must wait for A to complete
58
+ - Maximum parallel subagents: follow the subagent tool limits (max 8 tasks, 4 concurrent)
59
+ - If a parallel subagent fails, report which plan failed and continue with independent plans
48
60
 
49
61
  ## TDD Rules
50
62
  - Never write implementation before a failing test exists
@@ -57,10 +69,15 @@ Arguments: $ARGUMENTS
57
69
  - Do not import across bounded context boundaries directly — use domain events or ACL adapters
58
70
  - If implementation reveals a missing domain term, stop and update DOMAIN.md before continuing
59
71
 
60
- ## Checkpoint Handling
61
- - `type="auto"` execute without pausing
62
- - `type="checkpoint:human-verify"` → pause, show user, wait for confirmation
63
- - `type="checkpoint:decision"` → pause, present options, wait for choice
72
+ ## Workflow
73
+ This is one step in the per-phase cycle. Each step runs in its own session (`/new` between steps):
74
+
75
+ ```
76
+ /discuss-phase N → /new → /plan-phase N → /new → /execute-phase N → /new → /verify-work N → /new → /discuss-phase N+1 → ...
77
+ ```
78
+
79
+ After completing this command, tell the user to start a new session and run `/verify-work $1`.
80
+ Do NOT suggest `/next-milestone` — that is only after ALL phases in the milestone are verified.
64
81
 
65
82
  ## Flags
66
83
  - `--gaps-only` → only execute FIX-PLAN.md files from failed verification
@@ -4,7 +4,7 @@ description: "Diagnose and fix a bug with TDD discipline"
4
4
 
5
5
  # /fix
6
6
 
7
- Diagnose and fix a specific bug or failing task with TDD discipline.
7
+ Diagnose and fix a specific bug or failing task with TDD discipline, using a subagent for diagnosis.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -14,19 +14,21 @@ Diagnose and fix a specific bug or failing task with TDD discipline.
14
14
  Issue: $ARGUMENTS
15
15
 
16
16
  ## Steps
17
- 1. **Diagnose**: Read the relevant code and error output to identify the root cause
18
- - If a test is failing, run it first to see the actual error
19
- - If a runtime bug, reproduce it and capture the error
20
- 2. **Write a reproducing test**: Before touching any implementation:
21
- - Write a test that demonstrates the bug (it must fail)
17
+ 1. **Diagnose via subagent**: Use the `subagent` tool in **single mode** with the `debugger` agent:
18
+ "Diagnose this issue: $ARGUMENTS. Reproduce the bug by running the relevant test or command. Trace the root cause by reading the code. Identify the exact files and lines involved. Do NOT fix it yet only report the diagnosis with: root cause, affected files, and a recommended fix approach. Do NOT run draht, draht-tools, or pi commands."
19
+
20
+ 2. **Write a reproducing test**: Based on the diagnosis, write a test that demonstrates the bug (it must fail)
22
21
  - Commit: `draht-tools commit-docs "red: reproduce bug"`
22
+
23
23
  3. **Minimal fix**: Write the smallest change that makes the test pass
24
24
  - Do not refactor or add features — just fix the bug
25
25
  - Run the full test suite to check for regressions
26
26
  - Commit: `draht-tools commit-docs "green: fix description"`
27
+
27
28
  4. **Refactor** (if needed): Clean up without changing behavior
28
29
  - Tests must stay green after every change
29
30
  - Commit: `draht-tools commit-docs "refactor: description"`
31
+
30
32
  5. **Update state**: `draht-tools update-state`
31
33
 
32
34
  ## Rules
@@ -45,6 +45,18 @@ For greenfield projects, use `/new-project` instead.
45
45
  12. Run `draht-tools init-state`
46
46
  13. Git commit via `draht-tools commit-docs "initialize project planning"`
47
47
 
48
+ ## Workflow
49
+ After project initialization, phases are executed one at a time in new sessions:
50
+
51
+ ```
52
+ /init-project → /new → /discuss-phase 1 → /new → /plan-phase 1 → /new → /execute-phase 1 → /new → /verify-work 1
53
+ → /new → /discuss-phase 2 → /new → /plan-phase 2 → /new → /execute-phase 2 → /new → /verify-work 2
54
+ → ... (repeat for all phases in the milestone)
55
+ → /new → /next-milestone (only after ALL phases are complete)
56
+ ```
57
+
58
+ Each step runs in its own session (`/new` between steps). Do NOT suggest `/next-milestone` until every phase in the milestone is verified.
59
+
48
60
  ## Rules
49
61
  - Ask 1-2 questions at a time, never dump 10 at once
50
62
  - Follow threads based on answers
@@ -4,7 +4,7 @@ description: "Analyze existing codebase before planning"
4
4
 
5
5
  # /map-codebase
6
6
 
7
- Analyze existing codebase before planning.
7
+ Analyze existing codebase before planning, using subagents for parallel analysis.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -16,23 +16,22 @@ Directory: $1
16
16
  ## Steps
17
17
  1. Run `draht-tools map-codebase $1`
18
18
  2. Tool generates: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, CONCERNS.md
19
- 3. Review output, supplement with your own analysis if needed
20
- 4. Identify implicit bounded contexts from directory structure:
21
- - Look for top-level `src/` subdirectories, packages, or modules that encapsulate a coherent domain concept
22
- - Note any cross-directory coupling that suggests context boundaries are blurred
23
- 5. Extract domain language from existing code:
24
- - Collect PascalCase class/interface/type names, key function names, and database table/collection names
25
- - Look for repeated nouns that represent core domain concepts (e.g., `Order`, `Invoice`, `Subscription`)
26
- 6. If `.planning/DOMAIN.md` does not already exist, create it with:
19
+ 3. **Run parallel deep analysis via subagents:**
20
+ Use the `subagent` tool in **parallel mode** with these tasks:
21
+ - `architect` agent: "Analyze the codebase at $1. Identify bounded contexts from directory structure — look for top-level src/ subdirectories, packages, or modules that encapsulate coherent domain concepts. Note any cross-directory coupling suggesting blurred context boundaries. Extract domain language: collect PascalCase class/interface/type names, key function names, database table/collection names. Look for repeated nouns representing core domain concepts. Output a structured list of: bounded contexts (name + description), domain terms (glossary), aggregates per context, and context relationships (upstream/downstream, shared kernel, ACL). Do NOT run draht, draht-tools, or pi commands."
22
+ - `verifier` agent: "Analyze the test infrastructure at $1. Discover: test framework(s) in use (check package.json, config files), test directory conventions (co-located, __tests__/, test/), existing coverage configuration and goals, which layers have tests (unit, integration, e2e), gaps and recommendations. Output a structured test strategy report. Do NOT run draht, draht-tools, or pi commands."
23
+
24
+ 4. Collect subagent results and merge with the draht-tools output
25
+ 5. Create `.planning/DOMAIN.md` (if it doesn't exist) with:
27
26
  - `## Bounded Contexts` — one entry per discovered context with a brief description
28
27
  - `## Ubiquitous Language` — glossary of extracted domain terms
29
- - `## Context Map` — rough diagram or list showing how contexts relate
30
- - `## Aggregates` — list aggregates and their root entities per context
28
+ - `## Context Map` — how bounded contexts relate (upstream/downstream, shared kernel, ACL)
29
+ - `## Aggregates` — aggregates and their root entities per context
31
30
  - `## Domain Events` — any existing event names or patterns discovered
32
- 7. Discover test infrastructure and document findings in `.planning/TEST-STRATEGY.md`:
33
- - Test framework(s) in use (Jest, Vitest, Bun test, Mocha, etc.)
34
- - Test directory conventions (co-located, `__tests__/`, `test/`, etc.)
35
- - Existing coverage configuration and goals (if any)
36
- - Which layers have tests today (unit, integration, e2e)
37
- - Gaps and recommendations
38
- 8. Commit: `draht-tools commit-docs "map existing codebase"`
31
+ 6. Create `.planning/TEST-STRATEGY.md` with:
32
+ - `## Test Framework` chosen framework and rationale
33
+ - `## Directory Conventions` where test files live relative to source
34
+ - `## Coverage Goals` — target coverage percentage and which paths are critical
35
+ - `## Testing Levels` what is tested at unit level vs integration vs e2e, with examples
36
+ - `## Excluded` — what is explicitly not tested and why
37
+ 7. Commit: `draht-tools commit-docs "map existing codebase"`
@@ -37,6 +37,18 @@ Description: $ARGUMENTS
37
37
  11. Run `draht-tools init-state`
38
38
  12. Git commit via `draht-tools commit-docs "initialize project planning"`
39
39
 
40
+ ## Workflow
41
+ After project initialization, phases are executed one at a time in new sessions:
42
+
43
+ ```
44
+ /new-project → /new → /discuss-phase 1 → /new → /plan-phase 1 → /new → /execute-phase 1 → /new → /verify-work 1
45
+ → /new → /discuss-phase 2 → /new → /plan-phase 2 → /new → /execute-phase 2 → /new → /verify-work 2
46
+ → ... (repeat for all phases in the milestone)
47
+ → /new → /next-milestone (only after ALL phases are complete)
48
+ ```
49
+
50
+ Each step runs in its own session (`/new` between steps). Do NOT suggest `/next-milestone` until every phase in the milestone is verified.
51
+
40
52
  ## Rules
41
53
  - Ask 1-2 questions at a time, never dump 10 at once
42
54
  - Follow threads based on answers
@@ -1,10 +1,10 @@
1
1
  ---
2
- description: "Plan the next milestone after current one completes"
2
+ description: "Plan the next milestone after ALL phases in the current milestone are complete"
3
3
  ---
4
4
 
5
5
  # /next-milestone
6
6
 
7
- Plan the next milestone after the current one is complete.
7
+ Plan the next milestone after ALL phases in the current one are complete.
8
8
 
9
9
  ## Usage
10
10
  ```
@@ -13,7 +13,9 @@ Plan the next milestone after the current one is complete.
13
13
 
14
14
  ## Prerequisites
15
15
  - `.planning/ROADMAP.md` must exist
16
- - Current milestone should be complete or nearly complete
16
+ - ALL phases in the current milestone must be complete (verified via /verify-work)
17
+ - This command is ONLY for milestone transitions — NOT for moving between phases within a milestone
18
+ - Between phases, use `/discuss-phase`, `/plan-phase`, `/execute-phase`, `/verify-work` — never `/next-milestone`
17
19
 
18
20
  ## Steps
19
21
  1. Load project context: