draht-codex 2026.6.11
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/.codex-plugin/plugin.json +44 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/agents/architect.md +56 -0
- package/agents/debugger.md +67 -0
- package/agents/git-committer.md +61 -0
- package/agents/implementer.md +45 -0
- package/agents/reviewer.md +67 -0
- package/agents/security-auditor.md +119 -0
- package/agents/spec-reviewer.md +65 -0
- package/agents/verifier.md +55 -0
- package/bin/draht-tools.cjs +4875 -0
- package/cli.mjs +452 -0
- package/commands/atomic-commit.md +73 -0
- package/commands/discuss-phase.md +55 -0
- package/commands/execute-phase.md +173 -0
- package/commands/fix.md +121 -0
- package/commands/init-project.md +66 -0
- package/commands/map-codebase.md +73 -0
- package/commands/new-project.md +73 -0
- package/commands/next-milestone.md +50 -0
- package/commands/orchestrate.md +83 -0
- package/commands/pause-work.md +38 -0
- package/commands/plan-phase.md +142 -0
- package/commands/progress.md +30 -0
- package/commands/quick.md +95 -0
- package/commands/resume-work.md +35 -0
- package/commands/review.md +87 -0
- package/commands/verify-work.md +122 -0
- package/hooks/hooks.json +26 -0
- package/package.json +55 -0
- package/scripts/gsd-post-phase.cjs +144 -0
- package/scripts/gsd-post-task.cjs +165 -0
- package/scripts/gsd-pre-execute.cjs +146 -0
- package/scripts/gsd-quality-gate.cjs +252 -0
- package/scripts/prompt-context.cjs +36 -0
- package/scripts/session-start.cjs +52 -0
- package/skills/atomic-commit/SKILL.md +14 -0
- package/skills/atomic-reasoning/SKILL.md +107 -0
- package/skills/brainstorming/SKILL.md +120 -0
- package/skills/ddd-workflow/SKILL.md +111 -0
- package/skills/debugging-workflow/SKILL.md +101 -0
- package/skills/discuss-phase/SKILL.md +14 -0
- package/skills/execute-phase/SKILL.md +14 -0
- package/skills/fix/SKILL.md +14 -0
- package/skills/init-project/SKILL.md +14 -0
- package/skills/map-codebase/SKILL.md +14 -0
- package/skills/new-project/SKILL.md +14 -0
- package/skills/next-milestone/SKILL.md +14 -0
- package/skills/orchestrate/SKILL.md +14 -0
- package/skills/pause-work/SKILL.md +14 -0
- package/skills/plan-phase/SKILL.md +14 -0
- package/skills/progress/SKILL.md +14 -0
- package/skills/quick/SKILL.md +14 -0
- package/skills/resume-work/SKILL.md +14 -0
- package/skills/review/SKILL.md +14 -0
- package/skills/tdd-workflow/SKILL.md +117 -0
- package/skills/verification-gate/SKILL.md +82 -0
- package/skills/verify-work/SKILL.md +14 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Execute all plans in a phase with atomic commits (parallel implementer subagents + per-task two-stage review + TDD cycle)
|
|
3
|
+
argument-hint: "<phase-number> [--gaps-only]"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /execute-phase
|
|
8
|
+
|
|
9
|
+
Execute all plans in a phase with atomic commits, parallelizing independent plans via subagents. Each task is implemented, then **spec-reviewed**, then **quality-reviewed** before the next task begins.
|
|
10
|
+
|
|
11
|
+
Phase: $1
|
|
12
|
+
Arguments: $ARGUMENTS
|
|
13
|
+
|
|
14
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>`. For subagent delegation, spawn Codex subagents using the `implementer`, `spec-reviewer`, or `reviewer` agent prompts. Dispatch multiple parallel tasks in a single assistant turn by making multiple Codex subagent calls at once.
|
|
15
|
+
|
|
16
|
+
## Red Flags — STOP
|
|
17
|
+
|
|
18
|
+
STOP and report to the user instead of proceeding if **any** of these is true:
|
|
19
|
+
|
|
20
|
+
- `gsd-pre-execute.cjs` exits non-zero (missing DOMAIN.md, missing plans, uncommitted changes blocking start)
|
|
21
|
+
- Any plan file contains placeholder text: `[TBD]`, `[files]`, `[description]`, "appropriate error handling", "similar to Task N", "..." in code positions, or empty `<test>` / `<action>` / `<verify>` / `<done>` sections — these are not executable
|
|
22
|
+
- A plan has zero `<task>` elements
|
|
23
|
+
- `.planning/DOMAIN.md` is absent on a non-greenfield project — implementers will guess at naming
|
|
24
|
+
- The working tree is dirty with changes unrelated to this phase
|
|
25
|
+
- An implementer subagent returns `STATUS: BLOCKED` — never retry blindly; report what blocked it and ask the user
|
|
26
|
+
|
|
27
|
+
## Atomic Reasoning
|
|
28
|
+
|
|
29
|
+
Before executing, decompose this phase execution into atomic reasoning units:
|
|
30
|
+
|
|
31
|
+
**For each plan in the phase:**
|
|
32
|
+
1. **State the logical component** — What is this plan's singular purpose? What observable outcome does it produce?
|
|
33
|
+
2. **Validate independence** — Can this plan execute in parallel with others, or does it depend on their outputs? Which files does it touch?
|
|
34
|
+
3. **Verify correctness** — What tests will prove this plan works? What failure modes exist?
|
|
35
|
+
|
|
36
|
+
**Synthesize execution strategy:**
|
|
37
|
+
- Identify parallel execution groups (plans with no shared files/dependencies)
|
|
38
|
+
- Order dependent plans (plan B depends on plan A's outputs)
|
|
39
|
+
- Map each plan to a subagent task with clear success criteria
|
|
40
|
+
|
|
41
|
+
## Steps
|
|
42
|
+
|
|
43
|
+
0. Run the pre-execute check:
|
|
44
|
+
```bash
|
|
45
|
+
node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/scripts/gsd-pre-execute.cjs" $1
|
|
46
|
+
```
|
|
47
|
+
If it exits non-zero, STOP and report errors to the user. Do not proceed.
|
|
48
|
+
|
|
49
|
+
1. Run `draht-tools discover-plans $1` to find and order plans
|
|
50
|
+
2. Read each plan file yourself (from `.planning/phases/`) and analyze dependencies to identify which plans can run in parallel vs sequential. **Graph-impact:** run `draht-tools graph-impact <each plan's files>` and parallelize ONLY plans whose blast-radius/sink sets are disjoint; serialize any plans with overlapping reverse-dependents.
|
|
51
|
+
3. **Validate plans before dispatching:**
|
|
52
|
+
```bash
|
|
53
|
+
node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" validate-plans $1
|
|
54
|
+
```
|
|
55
|
+
If any plan reports placeholders or missing sections, STOP and fix the plan (or have the user re-run `/plan-phase`) before dispatching.
|
|
56
|
+
|
|
57
|
+
4. **Per-plan execution loop.** For each plan (parallel where independent, sequential where dependent):
|
|
58
|
+
|
|
59
|
+
For each `<task>` in the plan, run a **three-stage** dispatch — implementer → spec-reviewer → reviewer — before moving to the next task. Do not pause for user input between tasks; only stop when a stage returns `STATUS: BLOCKED` or `STATUS: NEEDS_CONTEXT`.
|
|
60
|
+
|
|
61
|
+
### Stage 1 — Implementer
|
|
62
|
+
Dispatch a Codex subagent using the `implementer` agent prompt and the prompt from the template below. Read the final `STATUS:` line in the response.
|
|
63
|
+
- `STATUS: DONE` → go to Stage 2.
|
|
64
|
+
- `STATUS: DONE_WITH_CONCERNS` → note the concerns; if any are correctness issues, instruct the implementer to fix and re-dispatch; otherwise go to Stage 2.
|
|
65
|
+
- `STATUS: NEEDS_CONTEXT` → provide the missing context (paste the relevant file content or decision) and re-dispatch. Do not skip.
|
|
66
|
+
- `STATUS: BLOCKED` → STOP. Report the blocker to the user. Do not move on.
|
|
67
|
+
|
|
68
|
+
### Stage 2 — Spec-reviewer
|
|
69
|
+
Once the implementer is DONE, dispatch a Codex subagent using the `spec-reviewer` agent prompt and a prompt of the form:
|
|
70
|
+
```
|
|
71
|
+
Review the diff for task <task-name> in plan <plan-file> against the spec below. ONLY check spec compliance — does the diff implement exactly what the spec asked for, no more, no less?
|
|
72
|
+
|
|
73
|
+
Task spec:
|
|
74
|
+
<paste the <task>...</task> XML>
|
|
75
|
+
|
|
76
|
+
Diff to review:
|
|
77
|
+
<run `git diff <range>` and paste, or instruct the agent to run it>
|
|
78
|
+
```
|
|
79
|
+
- `STATUS: DONE` → go to Stage 3.
|
|
80
|
+
- `STATUS: DONE_WITH_CONCERNS` → note, go to Stage 3.
|
|
81
|
+
- `STATUS: BLOCKED` → re-dispatch the implementer with the "Required Fixes" list to address the gaps. Repeat Stage 1+2 until `DONE`. **Never proceed to Stage 3 with a non-compliant diff.**
|
|
82
|
+
|
|
83
|
+
### Stage 3 — Reviewer (code quality)
|
|
84
|
+
Once spec compliance is ✅, dispatch a Codex subagent using the `reviewer` agent prompt and a prompt of the form:
|
|
85
|
+
```
|
|
86
|
+
Code-quality review of the diff for task <task-name>. Focus on correctness, type safety, conventions, maintainability, and domain language compliance. Spec compliance has already been confirmed — do NOT re-check spec.
|
|
87
|
+
|
|
88
|
+
Diff to review:
|
|
89
|
+
<run `git diff <range>` and paste, or instruct the agent to run it>
|
|
90
|
+
```
|
|
91
|
+
- `STATUS: DONE` → task is complete, run the post-task hook (below), then move to the next task.
|
|
92
|
+
- `STATUS: DONE_WITH_CONCERNS` → log the `Should fix` items; if any are correctness-critical, re-dispatch implementer; otherwise log and move on.
|
|
93
|
+
- `STATUS: BLOCKED` → `Must fix` issues exist; re-dispatch the implementer with the issue list. Repeat the three stages until `DONE`.
|
|
94
|
+
|
|
95
|
+
### Post-task hook
|
|
96
|
+
After Stage 3 passes for a task, record the result:
|
|
97
|
+
```bash
|
|
98
|
+
node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/scripts/gsd-post-task.cjs" <phase> <plan> <task-num> <status> <commit-hash>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
5. After all plans complete, run `draht-tools verify-phase $1` yourself (not the subagent)
|
|
102
|
+
6. Run the post-phase hook to generate the phase report:
|
|
103
|
+
```bash
|
|
104
|
+
node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/scripts/gsd-post-phase.cjs" $1
|
|
105
|
+
```
|
|
106
|
+
7. Run `draht-tools update-state` yourself
|
|
107
|
+
8. Final commit: `draht-tools commit-docs "complete phase $1 execution"`
|
|
108
|
+
9. Tell the user to start a fresh session (`/clear`) and run `/verify-work $1`
|
|
109
|
+
|
|
110
|
+
## Subagent Task Template (Stage 1: implementer)
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Execute this plan. Here is the full plan content:
|
|
114
|
+
|
|
115
|
+
<paste full plan XML here>
|
|
116
|
+
|
|
117
|
+
[Optional — orchestrator MAY paste a `draht-tools graph-context <task files>` slice here for orientation (pkg/layer/importers/imports/sinks). Codex subagents cannot run draht-tools.]
|
|
118
|
+
|
|
119
|
+
For each <task> in the plan, follow this TDD cycle:
|
|
120
|
+
1. RED — Write failing tests from <test>. Run the test runner, confirm they FAIL for the right reason. Commit with: git add <test-files> && git commit -m "red: <description>"
|
|
121
|
+
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>"
|
|
122
|
+
3. REFACTOR — Apply <refactor> improvements if any. Tests must stay green after each change. Commit with: git add <files> && git commit -m "refactor: <description>"
|
|
123
|
+
4. VERIFY — Run the <verify> step, confirm <done> criteria are met.
|
|
124
|
+
|
|
125
|
+
Domain rules: Use ubiquitous language from .planning/DOMAIN.md (read it). Do not import across bounded context boundaries.
|
|
126
|
+
|
|
127
|
+
Checkpoint handling:
|
|
128
|
+
- type="auto" → execute silently.
|
|
129
|
+
- type="checkpoint:human-verify" → stop and report back what was built.
|
|
130
|
+
- type="checkpoint:decision" → stop and report the options.
|
|
131
|
+
|
|
132
|
+
End your response with `STATUS: DONE` / `DONE_WITH_CONCERNS` / `NEEDS_CONTEXT` / `BLOCKED` per the agent contract.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Two-Stage Review Rationale
|
|
136
|
+
|
|
137
|
+
- **Spec compliance prevents over/under-building.** Implementers can drift — adding "helpful" extras or skipping pieces they think are obvious. The spec-reviewer catches this with fresh eyes.
|
|
138
|
+
- **Code quality runs only after spec ✅.** Mixing the two reviews lets quality concerns mask spec gaps. Keep them ordered.
|
|
139
|
+
- **Never accept "close enough" on spec compliance.** A `BLOCKED` from spec-reviewer means re-dispatch implementer, not move on.
|
|
140
|
+
|
|
141
|
+
## Parallelization Rules
|
|
142
|
+
|
|
143
|
+
- Plans sharing no files and having no dependency edges can run in parallel
|
|
144
|
+
- If plan B depends on output of plan A, plan B must wait for A to complete
|
|
145
|
+
- **Inside a plan, tasks run sequentially** — the three-stage review loop must complete before the next task starts (so each task gets clean review context)
|
|
146
|
+
- If a parallel subagent fails, report which plan failed and continue with independent plans
|
|
147
|
+
|
|
148
|
+
## TDD Rules
|
|
149
|
+
|
|
150
|
+
- Never write implementation before a failing test exists
|
|
151
|
+
- If a test passes immediately after being written, it is not testing the right thing — fix it
|
|
152
|
+
- Red → Green → Refactor is not optional; skipping steps invalidates the safety net
|
|
153
|
+
- Each TDD phase gets its own commit so the history is auditable
|
|
154
|
+
|
|
155
|
+
## Domain Rules
|
|
156
|
+
|
|
157
|
+
- All identifiers (class names, method names, variables) must use the ubiquitous language from `.planning/DOMAIN.md`
|
|
158
|
+
- Do not import across bounded context boundaries directly — use domain events or ACL adapters
|
|
159
|
+
- If implementation reveals a missing domain term, stop and update DOMAIN.md before continuing
|
|
160
|
+
|
|
161
|
+
## Workflow
|
|
162
|
+
|
|
163
|
+
This is one step in the per-phase cycle:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
/discuss-phase N → /plan-phase N → /execute-phase N → /verify-work N
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
After completing this command, tell the user to start a fresh session (`/clear`) and run `/verify-work $1`. Do NOT suggest `/next-milestone`.
|
|
170
|
+
|
|
171
|
+
## Flags
|
|
172
|
+
|
|
173
|
+
- `--gaps-only` → only execute FIX-PLAN.md files from failed verification
|
package/commands/fix.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Diagnose and fix a bug using a 4-phase systematic debugging protocol with TDD discipline
|
|
3
|
+
argument-hint: "<description of what's broken>"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /fix
|
|
8
|
+
|
|
9
|
+
Diagnose and fix a bug using the **four-phase systematic debugging protocol**: root cause investigation → pattern analysis → hypothesis & testing → implementation with a reproducing test.
|
|
10
|
+
|
|
11
|
+
Issue: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>`. For subagents, spawn Codex subagents using the `debugger` or `implementer` agent prompts.
|
|
14
|
+
|
|
15
|
+
## The Iron Law
|
|
16
|
+
|
|
17
|
+
> **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**
|
|
18
|
+
|
|
19
|
+
Symptom fixes are failure — they create new bugs in different places. If you find yourself proposing a "quick fix for now, investigate later", STOP and return to Phase 1.
|
|
20
|
+
|
|
21
|
+
## Red Flags — STOP
|
|
22
|
+
|
|
23
|
+
Stop immediately if you catch yourself:
|
|
24
|
+
- Proposing "quick fixes for now, investigate later"
|
|
25
|
+
- Attempting multiple changes simultaneously
|
|
26
|
+
- Skipping a reproducing test before fixing
|
|
27
|
+
- Proposing solutions before understanding data flow
|
|
28
|
+
- Making "one more fix attempt" after already trying 2+
|
|
29
|
+
- Watching each fix reveal new problems elsewhere
|
|
30
|
+
- Implementing before a failing test exists for the bug
|
|
31
|
+
|
|
32
|
+
When you've tried **3 fix attempts and still failing**, STOP. This is an architectural problem, not a hypothesis problem. Report back to the user — do not try a 4th fix.
|
|
33
|
+
|
|
34
|
+
## Atomic Reasoning
|
|
35
|
+
|
|
36
|
+
Before diagnosing, decompose this bug into atomic reasoning units:
|
|
37
|
+
|
|
38
|
+
1. **State the logical component** — What is the observed failure? What should happen vs what actually happens?
|
|
39
|
+
2. **Validate independence** — Which components/files are involved? Can we isolate the failure? Are there related bugs that should be fixed separately?
|
|
40
|
+
3. **Verify correctness** — What test will reproduce this bug reliably? What would prove it's fixed? What regressions could the fix introduce?
|
|
41
|
+
|
|
42
|
+
## The Four Phases
|
|
43
|
+
|
|
44
|
+
### Phase 1 — Root Cause Investigation (before ANY fix)
|
|
45
|
+
|
|
46
|
+
Once the affected/buggy file is identified, run `draht-tools graph-context <buggy-file>` and `draht-tools graph-callers <buggy-file>` to orient (package, layer, who calls it) — paste the summary into the Codex subagent prompt to support its "trace UPWARD" step.
|
|
47
|
+
|
|
48
|
+
Dispatch the `debugger` subagent with this prompt:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Investigate this issue using Phase 1 root-cause discipline. Do NOT fix anything — only diagnose.
|
|
52
|
+
|
|
53
|
+
Issue: $ARGUMENTS
|
|
54
|
+
|
|
55
|
+
Walk through these steps and report on each:
|
|
56
|
+
1. Read the error message / stack trace carefully — exact line numbers, exact file paths.
|
|
57
|
+
2. Reproduce consistently — what are the exact steps to trigger it? If you cannot reproduce, gather more data instead of guessing.
|
|
58
|
+
3. Check recent changes — `git log --oneline -20` and `git diff HEAD~5` against the affected files. What changed?
|
|
59
|
+
4. For multi-component flows: trace data flow. Where does the bad value originate? What called this with that value? Keep tracing UPWARD until you find the source. Fix at source, not at symptom.
|
|
60
|
+
5. State the root cause as one sentence: "X happens because Y at <file:line>."
|
|
61
|
+
|
|
62
|
+
End your response with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If `BLOCKED` or `NEEDS_CONTEXT`: provide the missing info and re-dispatch. Do not skip ahead.
|
|
66
|
+
|
|
67
|
+
### Phase 2 — Pattern Analysis
|
|
68
|
+
|
|
69
|
+
Read the root cause from Phase 1. Then:
|
|
70
|
+
|
|
71
|
+
1. Find working examples in the codebase that do the same kind of thing correctly — use `draht-tools graph-query "<concept>"` to locate reference implementations instead of grepping
|
|
72
|
+
2. Read those reference implementations **completely** — not skimmed
|
|
73
|
+
3. List every difference between the working code and the broken code, however small
|
|
74
|
+
4. Note dependencies: what config, settings, environment, or call-order does the working version assume?
|
|
75
|
+
|
|
76
|
+
If Phase 2 reveals a different root cause than Phase 1, go back to Phase 1 and re-investigate. Do not paper over the disagreement.
|
|
77
|
+
|
|
78
|
+
### Phase 3 — Single Hypothesis Test
|
|
79
|
+
|
|
80
|
+
1. State ONE hypothesis: "I think the root cause is X because Y."
|
|
81
|
+
2. Design the **smallest possible change** that would prove the hypothesis — one variable, one line if possible.
|
|
82
|
+
3. Apply it and observe. Did it fix the issue?
|
|
83
|
+
- **Yes** → proceed to Phase 4 with this fix.
|
|
84
|
+
- **No** → form a NEW hypothesis (do not pile changes on top). Revert the test change.
|
|
85
|
+
4. If after 3 hypotheses you are still failing, STOP. Question the architecture, not the hypothesis. Report to the user.
|
|
86
|
+
|
|
87
|
+
You may also say "I don't understand X" rather than pretend. That is the correct answer when it's true.
|
|
88
|
+
|
|
89
|
+
### Phase 4 — Implementation
|
|
90
|
+
|
|
91
|
+
1. **Write the reproducing test FIRST.** Smallest possible test that demonstrates the bug. Run it — confirm it FAILS for the right reason (not for a syntax error, not for a missing import).
|
|
92
|
+
- Commit: `git add <test-files> && git commit -m "red: reproduce <bug>"`
|
|
93
|
+
|
|
94
|
+
2. **Apply the single fix** identified in Phase 3. No other changes — no opportunistic refactor, no "while I'm here".
|
|
95
|
+
- Run the failing test — confirm it now PASSES.
|
|
96
|
+
- Run the FULL test suite — confirm no regressions.
|
|
97
|
+
- Commit: `git add <files> && git commit -m "green: fix <bug>"`
|
|
98
|
+
|
|
99
|
+
3. **Refactor (optional)** — only if there's clear improvement that doesn't change behaviour. Tests must stay green after every change.
|
|
100
|
+
- Commit: `git add <files> && git commit -m "refactor: <description>"`
|
|
101
|
+
|
|
102
|
+
4. **Verify the fix solved the original symptom**, not just the unit test. Run the user-level reproduction one more time.
|
|
103
|
+
|
|
104
|
+
5. **Update state**: `draht-tools update-state`
|
|
105
|
+
|
|
106
|
+
## Rationalization Table
|
|
107
|
+
|
|
108
|
+
| Excuse | Reality |
|
|
109
|
+
|--------|---------|
|
|
110
|
+
| "Simple bug, skip the process" | Simple bugs have root causes too. The process is fast. |
|
|
111
|
+
| "It's an emergency, no time" | Systematic debugging is *faster* than thrashing on guesses. |
|
|
112
|
+
| "I'll write the test after I confirm the fix" | Untested fixes don't stick. The test-first proves the bug existed. |
|
|
113
|
+
| "I'll just try a few things and see what works" | Can't isolate what worked. Creates new bugs. |
|
|
114
|
+
| "I already manually tested it" | A reproducing test is the only durable proof. |
|
|
115
|
+
|
|
116
|
+
## Rules
|
|
117
|
+
- Always reproduce before fixing — a fix without a test is a guess
|
|
118
|
+
- One bug, one fix, one commit series. Do not bundle unrelated changes.
|
|
119
|
+
- Fix at the source, not the symptom
|
|
120
|
+
- If 3 fix attempts have failed, the architecture is wrong — stop and discuss
|
|
121
|
+
- If the fix is non-obvious, the commit body explains the chain
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Initialize GSD planning for an existing project (codebase mapping → questioning → domain model → roadmap)
|
|
3
|
+
argument-hint: "[focus area]"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /init-project
|
|
8
|
+
|
|
9
|
+
Initialize planning framework for an existing project: codebase mapping → questioning → domain model → requirements → roadmap.
|
|
10
|
+
|
|
11
|
+
Focus: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
Use this when you have an existing codebase and want to add structured planning. For greenfield projects, use `/new-project` instead.
|
|
14
|
+
|
|
15
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool.
|
|
16
|
+
|
|
17
|
+
## Atomic Reasoning
|
|
18
|
+
|
|
19
|
+
Before initializing, decompose project understanding into atomic reasoning units:
|
|
20
|
+
|
|
21
|
+
**For each aspect of the existing project:**
|
|
22
|
+
1. **State the logical component** — What does this project do? Who are the users? What problems does it solve?
|
|
23
|
+
2. **Validate independence** — What bounded contexts exist in the code? What domain concepts are already present? Can they be separated cleanly?
|
|
24
|
+
3. **Verify correctness** — What works well that we must preserve? What pain points exist? What constraints limit changes?
|
|
25
|
+
|
|
26
|
+
**Synthesize initialization strategy:**
|
|
27
|
+
- Map existing architecture and conventions
|
|
28
|
+
- Extract domain model from code (bounded contexts, aggregates, ubiquitous language)
|
|
29
|
+
- Identify test strategy and coverage
|
|
30
|
+
- Define requirements that align with existing structure
|
|
31
|
+
- Create roadmap that respects what already works
|
|
32
|
+
|
|
33
|
+
## Steps
|
|
34
|
+
1. Run `draht-tools init` to check preconditions (git repo, etc.)
|
|
35
|
+
2. Run `draht-tools map-codebase` to build a structural map of the existing code, then `draht-tools map-graph` to produce `.planning/codebase/MAP.json` + `GRAPH_REPORT.md` (map-codebase alone does NOT emit MAP.json)
|
|
36
|
+
3. Analyze the codebase map to understand architecture, tech stack, and conventions: read `.planning/codebase/MAP.json` and run `draht-tools graph-hotspots` + `draht-tools graph-clusters` to surface high-traffic and cohesive modules
|
|
37
|
+
4. Deep questioning phase (3-7 rounds, 1-2 questions at a time):
|
|
38
|
+
- What is this project? Who uses it?
|
|
39
|
+
- What are the current pain points or goals?
|
|
40
|
+
- What is MVP vs aspirational scope?
|
|
41
|
+
- What constraints exist (infra, team size, deadlines)?
|
|
42
|
+
5. Run `draht-tools create-project` with gathered info
|
|
43
|
+
6. Run `draht-tools create-domain-model` to define bounded contexts, entities, and ubiquitous language
|
|
44
|
+
7. Create `.planning/DOMAIN.md` with the same sections as `/new-project`:
|
|
45
|
+
Bounded Contexts, Ubiquitous Language, Context Map, Aggregates, Domain Events.
|
|
46
|
+
Seed the Ubiquitous Language glossary from `GRAPH_REPORT.md` key concepts / `modules[*].symbols` (start from extracted terms, not zero)
|
|
47
|
+
8. Create `.planning/TEST-STRATEGY.md` with: Test Framework, Directory Conventions, Coverage Goals, Testing Levels, Excluded
|
|
48
|
+
9. Optional research phase via `draht-tools research`
|
|
49
|
+
10. Run `draht-tools create-requirements` with v1/v2/out-of-scope (map requirements to bounded contexts)
|
|
50
|
+
11. Run `draht-tools create-roadmap` with phases
|
|
51
|
+
12. Run `draht-tools init-state`
|
|
52
|
+
13. Git commit via `draht-tools commit-docs "initialize project planning"`
|
|
53
|
+
|
|
54
|
+
## Workflow
|
|
55
|
+
After project initialization, phases are executed one at a time in fresh sessions:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
/init-project → /discuss-phase 1 → /plan-phase 1 → /execute-phase 1 → /verify-work 1
|
|
59
|
+
→ ... (repeat for all phases in the milestone)
|
|
60
|
+
→ /next-milestone (only after ALL phases are complete)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Rules
|
|
64
|
+
- Ask 1-2 questions at a time, never dump 10 at once
|
|
65
|
+
- Respect what already exists — do not propose rewriting working code
|
|
66
|
+
- Stop when you have: current state, goals, MVP scope, constraints, success criteria
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze existing codebase before planning — extract architecture, domain model, and test strategy
|
|
3
|
+
argument-hint: "[directory]"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /map-codebase
|
|
8
|
+
|
|
9
|
+
Analyze existing codebase before planning, using subagents for parallel analysis.
|
|
10
|
+
|
|
11
|
+
Directory: $1
|
|
12
|
+
|
|
13
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>`. For subagents, spawn Codex subagents using the matching Draht agent prompts (for example `architect` and `verifier`).
|
|
14
|
+
|
|
15
|
+
## Atomic Reasoning
|
|
16
|
+
|
|
17
|
+
Before analyzing, decompose codebase understanding into atomic reasoning units:
|
|
18
|
+
|
|
19
|
+
**For each architectural layer:**
|
|
20
|
+
1. **State the logical component** — What is this directory/module's responsibility? What concepts does it encapsulate?
|
|
21
|
+
2. **Validate independence** — Is this a bounded context? What are its dependencies? Does it leak abstractions across boundaries?
|
|
22
|
+
3. **Verify correctness** — What domain terms appear in code? What aggregates exist? What test infrastructure is present?
|
|
23
|
+
|
|
24
|
+
**Synthesize analysis strategy:**
|
|
25
|
+
- Map directory structure to bounded contexts
|
|
26
|
+
- Extract domain language from identifiers (classes, functions, types)
|
|
27
|
+
- Identify context relationships (upstream/downstream, shared kernel)
|
|
28
|
+
- Document test strategy and coverage
|
|
29
|
+
- Note architectural concerns and patterns
|
|
30
|
+
|
|
31
|
+
## Steps
|
|
32
|
+
1. Run `draht-tools map-codebase $1`
|
|
33
|
+
2. Tool generates the prose docs (STACK.md, ARCHITECTURE.md, CONVENTIONS.md, CONCERNS.md, DOMAIN-HINTS.md) **and**, in the same pass, the **living architecture map** (MAP.json + MAP.html + GRAPH_REPORT.md).
|
|
34
|
+
2a. The living architecture map produced by step 1 (re-run `draht-tools map-graph $1` any time to refresh just the map without rewriting the docs):
|
|
35
|
+
- `.planning/codebase/MAP.json` — machine-readable map with **entry points** (CLI bins, HTTP routes, library main exports), **sinks** (FS / net / DB / stdout / exec calls), **bounded contexts** (packages), **cross-package dataflow edges**, **symbol-resolved call edges**, **flows** (which sinks each entry point reaches and through which intermediate module), per-module **layer** (presentation / application / domain / infrastructure / support), and exports/imports per file. Agents starting a new task should read MAP.json first instead of re-scanning the tree.
|
|
36
|
+
- `.planning/codebase/MAP.html` — interactive layered visualization with four views:
|
|
37
|
+
- **Architecture** — packages drawn as containers in architectural layers, with cross-package dataflow arrows. Thickness encodes import count.
|
|
38
|
+
- **Modules** — every file inside its package container, import edges between them; click a package or sink to highlight.
|
|
39
|
+
- **Flow Trace** — entry points on top, sinks on bottom, intermediate modules ranked by depth from entry. Click an entry point to trace which sinks it reaches.
|
|
40
|
+
- **Insights** — graphify-style knowledge graph: clusters (label-propagation communities), god-nodes (high-degree hotspots), and surprising cross-cluster edges.
|
|
41
|
+
Open directly, or run `draht-tools map-serve` for a live-reloading dev view (regenerates on every file save).
|
|
42
|
+
|
|
43
|
+
3. **Run parallel deep analysis via Codex subagents**:
|
|
44
|
+
Dispatch these two subagents in parallel (single assistant turn, two Codex subagent calls):
|
|
45
|
+
|
|
46
|
+
- **Codex subagent** with ``architect` agent prompt` and prompt:
|
|
47
|
+
"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).
|
|
48
|
+
|
|
49
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`."
|
|
50
|
+
|
|
51
|
+
- **Codex subagent** with ``verifier` agent prompt` and prompt:
|
|
52
|
+
"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.
|
|
53
|
+
|
|
54
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`."
|
|
55
|
+
|
|
56
|
+
4. Read each subagent's `STATUS:` line. `BLOCKED` or `NEEDS_CONTEXT` from either means STOP — `map-codebase` produces foundational artifacts and partial output here causes downstream confusion. Collect subagent results and merge with the draht-tools output.
|
|
57
|
+
5. Create `.planning/DOMAIN.md` (if it doesn't exist) with:
|
|
58
|
+
- `## Bounded Contexts` — one entry per discovered context with a brief description
|
|
59
|
+
- `## Ubiquitous Language` — glossary of extracted domain terms
|
|
60
|
+
- `## Context Map` — how bounded contexts relate (upstream/downstream, shared kernel, ACL)
|
|
61
|
+
- `## Aggregates` — aggregates and their root entities per context
|
|
62
|
+
- `## Domain Events` — any existing event names or patterns discovered
|
|
63
|
+
6. Create `.planning/TEST-STRATEGY.md` with: Test Framework, Directory Conventions, Coverage Goals, Testing Levels, Excluded
|
|
64
|
+
7. Commit: `draht-tools commit-docs "map existing codebase"`
|
|
65
|
+
|
|
66
|
+
## Living map for agents
|
|
67
|
+
|
|
68
|
+
Step 2a also writes `.planning/codebase/GRAPH_REPORT.md` — the **primary skimmable artifact**: key concepts (clusters), god nodes, surprising connections, and suggested questions. Read it first for orientation.
|
|
69
|
+
- The `MAP.json` is the machine-readable source of truth — now also carrying **clusters**, **hotspots**, **surprisingConnections**, **rationaleIndex**, per-module **symbols**, and edge **confidence** fields.
|
|
70
|
+
- Instead of walking the tree, agents orient with `draht-tools graph-context <file>`, `graph-impact <file>`, `graph-query "<concept>"`, `graph-callers`/`graph-callees`, `graph-path <from> <to>`, `graph-hotspots`, and `graph-clusters`.
|
|
71
|
+
- MAP.html gains an **Insights** view (clusters, god-nodes, surprising edges) alongside System / Modules / Flows.
|
|
72
|
+
- It is regenerated every time `map-codebase`, `map-graph`, or `map-serve` runs; run `draht-tools graph-hook install` to auto-refresh MAP.json on every commit.
|
|
73
|
+
- Developers can keep `draht-tools map-serve` running in a terminal — the HTML visualization updates live as files change, so architecture documentation is never stale.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Initialize a new project with structured GSD planning (questioning → domain model → requirements → roadmap)
|
|
3
|
+
argument-hint: "[description]"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /new-project
|
|
8
|
+
|
|
9
|
+
Initialize a new project: questioning → research → requirements → roadmap.
|
|
10
|
+
|
|
11
|
+
Description: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
> **Tool note**: When this command says `draht-tools <subcommand>`, invoke it as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool. `PLUGIN_ROOT` is used when Codex exposes it; `CLAUDE_PLUGIN_ROOT` is a compatibility fallback.
|
|
14
|
+
|
|
15
|
+
## Atomic Reasoning
|
|
16
|
+
|
|
17
|
+
Before questioning, decompose project vision into atomic reasoning units:
|
|
18
|
+
|
|
19
|
+
**For each aspect of the new project:**
|
|
20
|
+
1. **State the logical component** — What problem does this solve? Who are the users? What is core vs peripheral?
|
|
21
|
+
2. **Validate independence** — What bounded contexts will exist? What domain concepts are central? Can features be built independently?
|
|
22
|
+
3. **Verify correctness** — What defines MVP success? What constraints exist (time, tech, team)? What is explicitly out of scope?
|
|
23
|
+
|
|
24
|
+
**Synthesize project strategy:**
|
|
25
|
+
- Define bounded contexts and ubiquitous language upfront
|
|
26
|
+
- Establish test strategy before writing code
|
|
27
|
+
- Create requirements mapped to domain contexts
|
|
28
|
+
- Build roadmap with testable phase goals
|
|
29
|
+
- Ensure each phase delivers verifiable user value
|
|
30
|
+
|
|
31
|
+
## Steps
|
|
32
|
+
1. Run `draht-tools init` to check preconditions
|
|
33
|
+
2. If existing code detected, run `draht-tools map-codebase` first
|
|
34
|
+
3. Deep questioning phase (3-7 rounds, 1-2 questions at a time)
|
|
35
|
+
4. Run `draht-tools create-project` with gathered info
|
|
36
|
+
5. Run `draht-tools create-domain-model` to define bounded contexts, entities, and ubiquitous language
|
|
37
|
+
6. Create `.planning/DOMAIN.md` with:
|
|
38
|
+
- `## Bounded Contexts` — each context with name, responsibility, and brief description
|
|
39
|
+
- `## Ubiquitous Language` — glossary of domain terms agreed with the user (term → definition)
|
|
40
|
+
- `## Context Map` — how bounded contexts relate to each other (upstream/downstream, shared kernel, ACL)
|
|
41
|
+
- `## Aggregates` — aggregates and their root entities per context
|
|
42
|
+
- `## Domain Events` — named events that cross context boundaries
|
|
43
|
+
7. Create `.planning/TEST-STRATEGY.md` with:
|
|
44
|
+
- `## Test Framework` — chosen framework and rationale
|
|
45
|
+
- `## Directory Conventions` — where test files live relative to source
|
|
46
|
+
- `## Coverage Goals` — target coverage percentage and which paths are critical
|
|
47
|
+
- `## Testing Levels` — what is tested at unit level vs integration vs e2e, with examples
|
|
48
|
+
- `## Excluded` — what is explicitly not tested and why (config files, generated code, etc.)
|
|
49
|
+
8. Optional research phase via `draht-tools research`
|
|
50
|
+
9. Run `draht-tools create-requirements` with v1/v2/out-of-scope (map requirements to bounded contexts)
|
|
51
|
+
10. Run `draht-tools create-roadmap` with phases
|
|
52
|
+
11. Run `draht-tools init-state`
|
|
53
|
+
12. Git commit via `draht-tools commit-docs "initialize project planning"`
|
|
54
|
+
|
|
55
|
+
## Workflow
|
|
56
|
+
After project initialization, phases are executed one at a time in fresh sessions:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/new-project → /discuss-phase 1 → /plan-phase 1 → /execute-phase 1 → /verify-work 1
|
|
60
|
+
→ /discuss-phase 2 → /plan-phase 2 → /execute-phase 2 → /verify-work 2
|
|
61
|
+
→ ... (repeat for all phases in the milestone)
|
|
62
|
+
→ /next-milestone (only after ALL phases are complete)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Start a fresh session (`/clear`) between steps. Do NOT suggest `/next-milestone` until every phase in the milestone is verified.
|
|
66
|
+
|
|
67
|
+
## Rules
|
|
68
|
+
- Ask 1-2 questions at a time, never dump 10 at once
|
|
69
|
+
- Follow threads based on answers
|
|
70
|
+
- Use examples ("Like Stripe Checkout, or custom?")
|
|
71
|
+
- Confirm, don't assume
|
|
72
|
+
- 3-7 follow-up rounds typical
|
|
73
|
+
- Stop when you have: problem, audience, MVP scope, constraints, success criteria
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Plan the next milestone after ALL phases in the current one are complete
|
|
3
|
+
allowed-tools: Bash, Read, Write, Edit
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /next-milestone
|
|
7
|
+
|
|
8
|
+
Plan the next milestone after ALL phases in the current one are complete.
|
|
9
|
+
|
|
10
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool.
|
|
11
|
+
|
|
12
|
+
## Atomic Reasoning
|
|
13
|
+
|
|
14
|
+
Before planning the next milestone, decompose progress into atomic reasoning units:
|
|
15
|
+
|
|
16
|
+
**For each completed phase:**
|
|
17
|
+
1. **State the logical component** — What was built? What user value was delivered? What requirements were satisfied?
|
|
18
|
+
2. **Validate independence** — What worked well? What had issues? What assumptions proved wrong?
|
|
19
|
+
3. **Verify correctness** — Is every phase truly complete? Are there lingering fix plans? Is the codebase healthy?
|
|
20
|
+
|
|
21
|
+
**Synthesize milestone strategy:**
|
|
22
|
+
- Identify gaps from the current milestone
|
|
23
|
+
- Derive new requirements from lessons learned
|
|
24
|
+
- Group into a coherent next milestone with testable phase goals
|
|
25
|
+
- Ensure domain model and test strategy still reflect reality
|
|
26
|
+
|
|
27
|
+
## Steps
|
|
28
|
+
1. Run `draht-tools verify-milestone` to ensure every phase in the current milestone is `complete`
|
|
29
|
+
2. If any phase is not complete, STOP and tell the user which phase needs attention
|
|
30
|
+
3. Read all phase reports in `.planning/phase-N-report.md` to extract lessons learned
|
|
31
|
+
4. Read the execution log `.planning/execution-log.jsonl` for failure patterns
|
|
32
|
+
5. Refresh the living map if stale: `draht-tools map-graph --quiet` (guarded — skip if the post-phase hook already refreshed), then `draht-tools graph-clusters --surprising`. Compare clusters / bounded contexts / entry points against the milestone start to surface architectural drift before planning the next milestone
|
|
33
|
+
6. Review `.planning/DOMAIN.md` — is it still accurate? Any terms to add/revise (esp. drift flagged in step 5)?
|
|
34
|
+
7. Review `.planning/TEST-STRATEGY.md` — any updates needed?
|
|
35
|
+
8. Questioning phase (1-2 questions at a time):
|
|
36
|
+
- What is the next milestone's goal?
|
|
37
|
+
- What user-visible outcomes must be true by the end?
|
|
38
|
+
- What is in vs out of scope?
|
|
39
|
+
9. Propose phases for the next milestone. Each phase must have:
|
|
40
|
+
- A clear goal (outcome, not activity)
|
|
41
|
+
- Mapped requirements
|
|
42
|
+
- Acceptance criteria
|
|
43
|
+
10. Update `.planning/ROADMAP.md` with the new milestone header and phases (status: `pending`)
|
|
44
|
+
11. Update `.planning/REQUIREMENTS.md` with any new requirements
|
|
45
|
+
12. Commit: `draht-tools commit-docs "plan milestone <N>"`
|
|
46
|
+
|
|
47
|
+
## Rules
|
|
48
|
+
- Do not start planning phase details — that happens in `/discuss-phase` + `/plan-phase`
|
|
49
|
+
- Respect lessons learned from the previous milestone — don't repeat mistakes
|
|
50
|
+
- Keep the next milestone focused — 3-6 phases is typical
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Decompose a task and orchestrate multiple specialist subagents in parallel and chain modes
|
|
3
|
+
argument-hint: "<task description>"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /orchestrate
|
|
8
|
+
|
|
9
|
+
Decompose a task and dispatch the right mix of specialist subagents.
|
|
10
|
+
|
|
11
|
+
Task: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
> **Tool note**: Spawn Codex subagents using the matching Draht `architect` agent prompt, `implementer`, `spec-reviewer`, `reviewer`, `debugger`, `verifier`, `git-committer`, `security-auditor`. Dispatch multiple tasks in the same assistant turn for parallel execution.
|
|
14
|
+
|
|
15
|
+
## Atomic Reasoning
|
|
16
|
+
|
|
17
|
+
Before delegating, decompose the task into atomic work units:
|
|
18
|
+
|
|
19
|
+
1. **State the logical components** — What sub-tasks make up this work? Which are independent?
|
|
20
|
+
2. **Match agents to work** — Which specialist is right for each sub-task?
|
|
21
|
+
3. **Determine order** — What can run in parallel vs what must be sequential? For **code-touching** sub-tasks (skip for doc-only work), run `draht-tools graph-impact <files>` on each sub-task's targets: disjoint impact sets parallelize, overlapping ones sequence. The orchestrator runs it and pastes the summary into each Codex subagent's prompt.
|
|
22
|
+
4. **Define success** — What does "done" look like for each sub-task, and for the whole?
|
|
23
|
+
|
|
24
|
+
## Agent Selection Guide
|
|
25
|
+
|
|
26
|
+
| Need | Agent |
|
|
27
|
+
|---|---|
|
|
28
|
+
| Plan structure before coding | `architect` |
|
|
29
|
+
| Write or change code | `implementer` |
|
|
30
|
+
| Check that a diff covers exactly the spec — no more, no less | `spec-reviewer` |
|
|
31
|
+
| Review code quality (correctness, conventions, domain language) | `reviewer` |
|
|
32
|
+
| Find what's broken (root-cause diagnosis) | `debugger` |
|
|
33
|
+
| Audit for security issues | `security-auditor` |
|
|
34
|
+
| Run lint / typecheck / tests | `verifier` |
|
|
35
|
+
| Create atomic commits | `git-committer` |
|
|
36
|
+
|
|
37
|
+
`spec-reviewer` and `reviewer` are distinct on purpose. Spec-reviewer ONLY checks "did the diff implement what the spec asked, no more no less". Reviewer evaluates quality (naming, structure, type safety). For any task with a written spec, run spec-reviewer **before** reviewer — accepting "close enough" on spec is a known failure mode.
|
|
38
|
+
|
|
39
|
+
## Orchestration Modes
|
|
40
|
+
|
|
41
|
+
### Parallel
|
|
42
|
+
Dispatch several Codex subagent calls in a single assistant turn when the sub-tasks don't depend on each other. Example: review + security audit of the same change set.
|
|
43
|
+
|
|
44
|
+
### Chain
|
|
45
|
+
Dispatch Codex subagent calls sequentially when later work depends on earlier output. Example: architect produces plan → implementer executes plan → verifier runs tests → reviewer audits the diff.
|
|
46
|
+
|
|
47
|
+
### Fan-out / Fan-in
|
|
48
|
+
Architect decomposes into N independent plans → dispatch N implementers in parallel → collect all outputs → single verifier run → single reviewer audit. This is the standard pattern for `/execute-phase` work.
|
|
49
|
+
|
|
50
|
+
### Two-Stage Review (spec → quality)
|
|
51
|
+
For any task that has a written spec, follow implementer with **spec-reviewer first, then reviewer**:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
implementer → spec-reviewer → reviewer
|
|
55
|
+
↓ BLOCKED
|
|
56
|
+
re-dispatch implementer with required fixes
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Never run quality review on a spec-non-compliant diff. This is the standard pattern inside `/execute-phase`'s per-task loop.
|
|
60
|
+
|
|
61
|
+
## Reading Subagent Status
|
|
62
|
+
|
|
63
|
+
Every draht agent ends its response with one of four status lines. Branch on it:
|
|
64
|
+
|
|
65
|
+
- `STATUS: DONE` — proceed to the next step in the chain.
|
|
66
|
+
- `STATUS: DONE_WITH_CONCERNS` — note the concerns. If they're correctness-related, address before moving on; otherwise log and continue.
|
|
67
|
+
- `STATUS: NEEDS_CONTEXT` — provide the missing information and re-dispatch the same agent. Do NOT skip ahead with a guess.
|
|
68
|
+
- `STATUS: BLOCKED` — STOP. Report the blocker to the user. Do not retry the same agent on the same input — adjust the inputs (provide more context, decompose further, pick a different agent) or surface the problem.
|
|
69
|
+
|
|
70
|
+
## Steps
|
|
71
|
+
1. Read the task description and identify sub-tasks
|
|
72
|
+
2. Map each sub-task to the right agent from the table above
|
|
73
|
+
3. Decide parallel vs chain vs fan-out vs two-stage based on dependencies
|
|
74
|
+
4. Dispatch Codex subagent calls accordingly
|
|
75
|
+
5. Read each subagent's final `STATUS:` line and branch per the protocol above
|
|
76
|
+
6. Collect results, handle failures, report the final outcome to the user
|
|
77
|
+
|
|
78
|
+
## Rules
|
|
79
|
+
- Prefer parallel dispatch when possible — it's faster and each subagent has its own context
|
|
80
|
+
- Pass complete context to subagents — they cannot see the main conversation
|
|
81
|
+
- Do not nest delegations deeply — one level is usually enough
|
|
82
|
+
- Never retry the same agent on the same input after `BLOCKED` — change something
|
|
83
|
+
- For any spec-driven work, spec-reviewer runs before quality reviewer
|