draht-codex 2026.7.7 → 2026.7.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 +1 -1
- package/CHANGELOG.md +24 -0
- package/agents/advisor.md +45 -0
- package/agents/architect.md +28 -0
- package/agents/debugger.md +18 -0
- package/agents/git-committer.md +2 -0
- package/agents/implementer.md +24 -0
- package/agents/reviewer.md +9 -2
- package/agents/security-auditor.md +1 -0
- package/agents/spec-reviewer.md +2 -1
- package/agents/verifier.md +12 -1
- package/bin/draht-tools.cjs +1808 -988
- package/commands/discuss-phase.md +1 -1
- package/commands/execute-phase.md +8 -4
- package/commands/fix.md +13 -1
- package/commands/init-project.md +1 -0
- package/commands/map-codebase.md +1 -1
- package/commands/new-project.md +1 -0
- package/commands/next-milestone.md +3 -0
- package/commands/orchestrate-loop.md +100 -0
- package/commands/orchestrate.md +29 -6
- package/commands/pause-work.md +4 -3
- package/commands/plan-phase.md +6 -0
- package/commands/quick.md +6 -2
- package/commands/review.md +4 -1
- package/commands/verify-work.md +10 -8
- package/hooks/hooks.json +24 -0
- package/package.json +2 -2
- package/scripts/gsd-post-phase.cjs +24 -0
- package/scripts/gsd-post-task.cjs +9 -3
- package/scripts/gsd-quality-gate.cjs +8 -3
- package/scripts/post-edit-check.cjs +59 -0
- package/scripts/session-start.cjs +46 -0
- package/scripts/stop-quality-gate.cjs +68 -0
- package/skills/atomic-reasoning/SKILL.md +8 -0
- package/skills/brainstorming/SKILL.md +13 -2
- package/skills/debugging-workflow/SKILL.md +9 -0
- package/skills/gsd-workflow/SKILL.md +162 -0
- package/skills/loop-workflow/SKILL.md +52 -0
- package/skills/model-tiering/SKILL.md +45 -0
- package/skills/orchestrate-loop/SKILL.md +14 -0
- package/skills/verification-gate/SKILL.md +10 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Post-Edit Check Hook (PostToolUse: Edit|Write)
|
|
6
|
+
* Lints the edited file immediately, so formatting/lint rules hold on every
|
|
7
|
+
* edit instead of waiting for a commit or a prose-invoked gate.
|
|
8
|
+
*
|
|
9
|
+
* Reads the hook payload from stdin, runs a file-scoped `biome check` when the
|
|
10
|
+
* project uses Biome, and exits 2 with the findings on stderr so the agent
|
|
11
|
+
* sees and fixes them. Exits 0 (silent) in projects without Biome, for
|
|
12
|
+
* non-code files, and on any unexpected error — this hook must never wedge a
|
|
13
|
+
* session.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { execSync } = require("node:child_process");
|
|
17
|
+
const fs = require("node:fs");
|
|
18
|
+
const path = require("node:path");
|
|
19
|
+
|
|
20
|
+
const CODE_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
21
|
+
|
|
22
|
+
function readStdin() {
|
|
23
|
+
try {
|
|
24
|
+
return fs.readFileSync(0, "utf-8");
|
|
25
|
+
} catch {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const payload = JSON.parse(readStdin() || "{}");
|
|
32
|
+
const filePath = payload?.tool_input?.file_path;
|
|
33
|
+
if (!filePath || !fs.existsSync(filePath)) process.exit(0);
|
|
34
|
+
if (!CODE_EXTENSIONS.has(path.extname(filePath))) process.exit(0);
|
|
35
|
+
|
|
36
|
+
const cwd = payload?.cwd || process.cwd();
|
|
37
|
+
if (!fs.existsSync(path.join(cwd, "biome.json"))) process.exit(0);
|
|
38
|
+
|
|
39
|
+
const runner = fs.existsSync(path.join(cwd, "bun.lock")) || fs.existsSync(path.join(cwd, "bun.lockb"))
|
|
40
|
+
? "bunx"
|
|
41
|
+
: "npx";
|
|
42
|
+
try {
|
|
43
|
+
execSync(`${runner} biome check --error-on-warnings ${JSON.stringify(filePath)} 2>&1`, {
|
|
44
|
+
timeout: 15000,
|
|
45
|
+
encoding: "utf-8",
|
|
46
|
+
cwd,
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
const output = (error.stdout || error.stderr || "").toString();
|
|
50
|
+
if (error.signal || !output.trim()) process.exit(0); // timeout or tool failure — don't block
|
|
51
|
+
if (output.includes("No files were processed")) process.exit(0); // file ignored by biome config
|
|
52
|
+
console.error(`Lint issues in ${filePath} (fix before proceeding):`);
|
|
53
|
+
console.error(output.slice(0, 1500));
|
|
54
|
+
process.exit(2);
|
|
55
|
+
}
|
|
56
|
+
process.exit(0);
|
|
57
|
+
} catch {
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* Session Start Hook
|
|
6
6
|
* Surfaces draht planning state when a Codex session starts in a project.
|
|
7
7
|
* - Reports current phase and task from .planning/STATE.md
|
|
8
|
+
* - Rereads the standing spec: vision + constraints from .planning/PROJECT.md
|
|
9
|
+
* (goal-drift guard — the spec reaches every session, not just milestones)
|
|
10
|
+
* - Surfaces the most recent lessons from STATE.md ## Lessons
|
|
8
11
|
* - Flags CONTINUE-HERE.md if the previous session was paused
|
|
9
12
|
* - Silent in projects without .planning/
|
|
10
13
|
*/
|
|
@@ -36,6 +39,49 @@ if (fs.existsSync(statePath)) {
|
|
|
36
39
|
} catch {}
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
// PROJECT.md — standing spec digest (vision + constraints), reread every session
|
|
43
|
+
const projectPath = path.join(PLANNING, "PROJECT.md");
|
|
44
|
+
if (fs.existsSync(projectPath)) {
|
|
45
|
+
try {
|
|
46
|
+
const project = fs.readFileSync(projectPath, "utf-8");
|
|
47
|
+
const visionMatch = project.match(/## Vision\s*\n([^\n#]+)/);
|
|
48
|
+
if (visionMatch) {
|
|
49
|
+
lines.push("");
|
|
50
|
+
lines.push(`Vision: ${visionMatch[1].trim()}`);
|
|
51
|
+
}
|
|
52
|
+
const constraintsMatch = project.match(/## Constraints\s*\n([\s\S]*?)(?:\n## |$)/);
|
|
53
|
+
if (constraintsMatch) {
|
|
54
|
+
const constraints = constraintsMatch[1]
|
|
55
|
+
.split("\n")
|
|
56
|
+
.filter((l) => /^\s*[-*]\s/.test(l))
|
|
57
|
+
.slice(0, 6);
|
|
58
|
+
if (constraints.length > 0) {
|
|
59
|
+
lines.push("Constraints:");
|
|
60
|
+
for (const c of constraints) lines.push(c.trim());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// STATE.md ## Lessons — most recent lessons, so past failures aren't repeated
|
|
67
|
+
if (fs.existsSync(statePath)) {
|
|
68
|
+
try {
|
|
69
|
+
const state = fs.readFileSync(statePath, "utf-8");
|
|
70
|
+
const lessonsMatch = state.match(/## Lessons\s*\n([\s\S]*?)(?:\n## |$)/);
|
|
71
|
+
if (lessonsMatch) {
|
|
72
|
+
const lessons = lessonsMatch[1]
|
|
73
|
+
.split("\n")
|
|
74
|
+
.filter((l) => /^\s*[-*]\s/.test(l))
|
|
75
|
+
.slice(-3);
|
|
76
|
+
if (lessons.length > 0) {
|
|
77
|
+
lines.push("");
|
|
78
|
+
lines.push("Recent lessons:");
|
|
79
|
+
for (const l of lessons) lines.push(l.trim());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {}
|
|
83
|
+
}
|
|
84
|
+
|
|
39
85
|
// CONTINUE-HERE.md — resume marker
|
|
40
86
|
const continuePath = path.join(PLANNING, "CONTINUE-HERE.md");
|
|
41
87
|
if (fs.existsSync(continuePath)) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Stop-Time Quality Gate Hook (Stop)
|
|
6
|
+
* Runs the draht quality gate when the agent tries to end its turn with
|
|
7
|
+
* uncommitted source changes in a .planning project — so the gate fires even
|
|
8
|
+
* when the command prose that should have invoked it was skipped.
|
|
9
|
+
*
|
|
10
|
+
* Loop safety: exits 0 when stop_hook_active is set (we already blocked one
|
|
11
|
+
* stop this turn), so a persistently red gate blocks at most one stop.
|
|
12
|
+
* Opt out per-project with hooks.stopGate: false in .planning/config.json.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const { execSync, spawnSync } = require("node:child_process");
|
|
16
|
+
const fs = require("node:fs");
|
|
17
|
+
const path = require("node:path");
|
|
18
|
+
|
|
19
|
+
function readStdin() {
|
|
20
|
+
try {
|
|
21
|
+
return fs.readFileSync(0, "utf-8");
|
|
22
|
+
} catch {
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const payload = JSON.parse(readStdin() || "{}");
|
|
29
|
+
if (payload?.stop_hook_active) process.exit(0);
|
|
30
|
+
|
|
31
|
+
const cwd = payload?.cwd || process.cwd();
|
|
32
|
+
const planning = path.join(cwd, ".planning");
|
|
33
|
+
if (!fs.existsSync(planning)) process.exit(0);
|
|
34
|
+
|
|
35
|
+
// Config opt-out
|
|
36
|
+
try {
|
|
37
|
+
const config = JSON.parse(fs.readFileSync(path.join(planning, "config.json"), "utf-8"));
|
|
38
|
+
if (config?.hooks?.stopGate === false) process.exit(0);
|
|
39
|
+
} catch { /* no config — gate stays on */ }
|
|
40
|
+
|
|
41
|
+
// Only gate when uncommitted source changes exist — a conversational turn
|
|
42
|
+
// with a clean tree has nothing to verify.
|
|
43
|
+
let dirty = "";
|
|
44
|
+
try {
|
|
45
|
+
dirty = execSync("git status --porcelain 2>/dev/null", { encoding: "utf-8", cwd, timeout: 10000 });
|
|
46
|
+
} catch {
|
|
47
|
+
process.exit(0); // not a git repo
|
|
48
|
+
}
|
|
49
|
+
const dirtySource = dirty
|
|
50
|
+
.split("\n")
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.map((l) => l.slice(3))
|
|
53
|
+
.filter((f) => /\.(ts|tsx|js|jsx|mjs|cjs)$/.test(f));
|
|
54
|
+
if (dirtySource.length === 0) process.exit(0);
|
|
55
|
+
|
|
56
|
+
// --no-tests: types + lint only. Test runs belong to the post-task hook and
|
|
57
|
+
// /verify-work; a full suite on every turn-end would be unusable.
|
|
58
|
+
const gate = path.join(__dirname, "gsd-quality-gate.cjs");
|
|
59
|
+
const result = spawnSync("node", [gate, "--no-tests"], { encoding: "utf-8", cwd, timeout: 170000 });
|
|
60
|
+
if (result.status !== 0 && !result.error) {
|
|
61
|
+
console.error("Quality gate failed on uncommitted source changes — fix before ending the turn:");
|
|
62
|
+
console.error((result.stdout || "").slice(0, 1500));
|
|
63
|
+
process.exit(2);
|
|
64
|
+
}
|
|
65
|
+
process.exit(0);
|
|
66
|
+
} catch {
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
@@ -76,6 +76,14 @@ A unit is atomic if:
|
|
|
76
76
|
|
|
77
77
|
If any of these fail, decompose further.
|
|
78
78
|
|
|
79
|
+
## Order by Risk
|
|
80
|
+
|
|
81
|
+
Decomposition tells you the units; it doesn't tell you which to do first. When the units are independent, sequence is a lever — use it to fail cheaply.
|
|
82
|
+
|
|
83
|
+
Score each unit by **uncertainty** (has this codebase done it before?) × **blast radius** (how many other units become invalid if this one is wrong?). Do the highest-scoring unit first; push boilerplate last. Boilerplate never invalidates the plan — the risky, unfamiliar unit regularly does, and you want to discover that before you've built everything downstream of it.
|
|
84
|
+
|
|
85
|
+
*Example:* a feature needs a third-party webhook and a settings screen. Both are atomic. Prove the webhook round-trip first — if the contract isn't what you assumed, the settings screen you'd have built on top of it was wasted. *Prevents:* sinking effort into work that a later, riskier unit turns out to obsolete.
|
|
86
|
+
|
|
79
87
|
## Anti-Patterns — STOP
|
|
80
88
|
|
|
81
89
|
- **"Improve performance"** — not atomic. Pick one metric, one bottleneck, one change.
|
|
@@ -7,6 +7,16 @@ description: Socratic ideation gate before any project work begins. Use when the
|
|
|
7
7
|
|
|
8
8
|
The pre-planning gate. Before draht's GSD cycle runs, before code is scaffolded, before /new-project or /init-project, the idea has to be converged on. This skill enforces design-first discipline through dialogue.
|
|
9
9
|
|
|
10
|
+
## Hear the Problem Beneath the Ask
|
|
11
|
+
|
|
12
|
+
The user's words describe an artifact; the design must serve a need. They are rarely the same thing.
|
|
13
|
+
|
|
14
|
+
1. Separate the stated artifact ("a dashboard") from the underlying need — what decision, pain, or moment does it serve?
|
|
15
|
+
2. When the user names a solution, ask what it solves before refining it. Solutions stay candidates until the need is confirmed.
|
|
16
|
+
3. State the need back in one sentence ("so the real problem is X — right?") and get an explicit yes before proposing any approach.
|
|
17
|
+
|
|
18
|
+
*Example:* "I want an admin dashboard" → questioning reveals they check one number, once a week → a scheduled email beats the dashboard by a month of build time. *Prevents:* a polished spec for the wrong artifact.
|
|
19
|
+
|
|
10
20
|
## The Hard Gate
|
|
11
21
|
|
|
12
22
|
> Do NOT invoke any planning skill, write any code, scaffold any project, or take any implementation action until you have:
|
|
@@ -82,13 +92,14 @@ The file should include:
|
|
|
82
92
|
|
|
83
93
|
### 6. Self-Review the Written Spec
|
|
84
94
|
|
|
85
|
-
Before handing off,
|
|
95
|
+
Before handing off, attack the spec as if you were paid to kill it:
|
|
86
96
|
- Contradictions between sections (the goal says X, the architecture implies not-X)
|
|
87
97
|
- Gaps (a user story with no architectural support)
|
|
88
98
|
- Premature commitments (specific tech choices made before they were needed)
|
|
89
99
|
- Domain language drift (different names for the same thing)
|
|
100
|
+
- The strongest case the whole design is wrong — wrong scope, wrong user, or already solved by a simpler existing tool. Write that case and why the design survives it into the spec's Open Questions.
|
|
90
101
|
|
|
91
|
-
Report any findings to the user and update before proceeding.
|
|
102
|
+
Report any findings to the user and update before proceeding. A spec that was never attacked has never been tested.
|
|
92
103
|
|
|
93
104
|
### 7. Hand Off
|
|
94
105
|
|
|
@@ -13,6 +13,12 @@ Random fixes create new bugs. This skill enforces the four-phase systematic debu
|
|
|
13
13
|
|
|
14
14
|
A symptom fix is a failure. If you patch the visible error without understanding why it occurred, you've created the next bug.
|
|
15
15
|
|
|
16
|
+
## The Report Is a Symptom, Not a Diagnosis
|
|
17
|
+
|
|
18
|
+
Restate the failure as observable behaviour — "X happens when Y; expected Z" — before touching anything. If the reporter names a cause ("the cache is stale"), treat it as Hypothesis #0: it earns a test in Phase 3 like any other and does not skip Phase 1. The person who saw the bug saw the symptom; their diagnosis is a lead, not a finding.
|
|
19
|
+
|
|
20
|
+
*Example:* "fix the stale cache bug" — Phase 1 traces the data flow and finds the cache is fine; the query behind it silently drops a filter. The fix lands in the query. *Prevents:* shipping a correct fix to the wrong component.
|
|
21
|
+
|
|
16
22
|
## When to Apply
|
|
17
23
|
|
|
18
24
|
Any time you encounter:
|
|
@@ -33,6 +39,7 @@ Any time you encounter:
|
|
|
33
39
|
3. **Check recent changes.** `git log --oneline -20`, `git diff HEAD~N` on the affected paths. What was the last thing that touched this?
|
|
34
40
|
4. **Trace data flow.** Where does the bad value originate? What called the function with that value? Keep tracing **upward** until you find the source. Fix at source, not at the symptom site.
|
|
35
41
|
5. **State the root cause in one sentence:** "X happens because Y at <file:line>."
|
|
42
|
+
6. **Label each step** observed (you ran it and saw it), derived (follows necessarily from evidence), or assumed (unchecked — name what would check it). A root cause resting on an assumption is a hypothesis, not a diagnosis.
|
|
36
43
|
|
|
37
44
|
If you cannot state the root cause clearly, you do not understand the bug yet. Do not proceed.
|
|
38
45
|
|
|
@@ -91,6 +98,8 @@ Stop immediately if you catch yourself:
|
|
|
91
98
|
| "Let me try a few things" | Can't isolate what worked. Creates new bugs. |
|
|
92
99
|
| "I already manually tested it" | A reproducing test is the only durable proof. |
|
|
93
100
|
| "I can see what's wrong, I don't need Phase 1" | "See" is not "understand". Trace it. |
|
|
101
|
+
| "The user already told me the cause" | The reporter saw the symptom. Their diagnosis is Hypothesis #0, not a finding. |
|
|
102
|
+
| "The fix passed, so my diagnosis was right" | Fixes can mask. Verify the causal chain, not just the symptom's absence. |
|
|
94
103
|
|
|
95
104
|
## Relationship to /fix
|
|
96
105
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gsd-workflow
|
|
3
|
+
description: Draht's Get Shit Done workflow — how to use /new-project, /discuss-phase, /plan-phase, /execute-phase, /verify-work, /next-milestone, /pause-work, /resume-work, /progress, /fix, /quick and the .planning/ directory structure to drive a project from idea to shipping. Use when the user asks how to plan work, structure a project, set up milestones, track progress, or wants to start using draht's workflow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GSD (Get Shit Done) Workflow
|
|
7
|
+
|
|
8
|
+
Draht's GSD workflow is a milestone → phase → plan → task hierarchy that lives in `.planning/` and is driven by slash commands + hooks.
|
|
9
|
+
|
|
10
|
+
## Directory Structure
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
.planning/
|
|
14
|
+
├── PROJECT.md # what are we building
|
|
15
|
+
├── REQUIREMENTS.md # v1 / v2 / out-of-scope
|
|
16
|
+
├── ROADMAP.md # phases grouped into milestones
|
|
17
|
+
├── DOMAIN.md # bounded contexts + ubiquitous language (DDD)
|
|
18
|
+
├── TEST-STRATEGY.md # test framework, levels, coverage
|
|
19
|
+
├── STATE.md # current phase, status, last activity
|
|
20
|
+
├── CONTINUE-HERE.md # handoff doc (only when paused)
|
|
21
|
+
├── execution-log.jsonl # append-only task execution log
|
|
22
|
+
├── codebase/
|
|
23
|
+
│ ├── MAP.json # queryable knowledge graph (modules, symbols, edges, clusters)
|
|
24
|
+
│ └── GRAPH_REPORT.md # skimmable graph digest (god nodes, surprising connections, rationale)
|
|
25
|
+
├── phases/
|
|
26
|
+
│ └── 01-phase-slug/
|
|
27
|
+
│ ├── 01-01-PLAN.md
|
|
28
|
+
│ ├── 01-01-SUMMARY.md
|
|
29
|
+
│ └── 01-02-PLAN.md
|
|
30
|
+
└── phase-N-report.md # generated by post-phase hook
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Graph-first orientation
|
|
34
|
+
|
|
35
|
+
`.planning/codebase/MAP.json` + `GRAPH_REPORT.md` are the living map of the codebase. **Before you grep or walk the tree, query the living map.** This is the canonical reference block other skills point to.
|
|
36
|
+
|
|
37
|
+
| Command | Use |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `draht-tools graph-context <file...>` | pkg/layer/cluster/importers/imports/sinks/rationale — orient on an area |
|
|
40
|
+
| `draht-tools graph-impact <file...>` | blast radius: reverse-dependents, entry points reached, sinks, boundary warnings |
|
|
41
|
+
| `draht-tools graph-query <term...>` | ranked symbol+doc search — replaces grep for "find the X" |
|
|
42
|
+
| `draht-tools graph-callers/-callees <file> [--depth N]` | who calls / is called, N hops |
|
|
43
|
+
| `draht-tools graph-path <from> <to>` | shortest import path between two files |
|
|
44
|
+
| `draht-tools graph-hotspots` / `graph-clusters [--surprising]` | god nodes / structural clusters (structural ≠ semantic) |
|
|
45
|
+
| `draht-tools map-graph [--quiet]` | (re)build MAP.json + GRAPH_REPORT.md (the post-phase hook owns refresh) |
|
|
46
|
+
|
|
47
|
+
If `MAP.json` is absent, run `draht-tools map-graph` first. Subagents can't run `draht-tools` — the orchestrator runs the query and pastes the summary into the subagent prompt.
|
|
48
|
+
|
|
49
|
+
## The Cycle
|
|
50
|
+
|
|
51
|
+
### Project initialization (once)
|
|
52
|
+
- **`/new-project`** — greenfield: questioning → domain model → requirements → roadmap
|
|
53
|
+
- **`/init-project`** — existing codebase: map → extract domain → questioning → roadmap
|
|
54
|
+
- **`/map-codebase`** — standalone codebase analysis
|
|
55
|
+
|
|
56
|
+
### Per-phase cycle (fresh session between each step)
|
|
57
|
+
Each step is **graph-first** (see above): orient via `graph-context`/`graph-query`/`graph-impact` before grepping or walking the tree.
|
|
58
|
+
1. **`/discuss-phase N`** — capture decisions, gray areas, domain terms
|
|
59
|
+
2. **`/plan-phase N`** — create atomic execution plans (parallel via `architect` subagents). Architects emit `---END-PLAN---` to separate plan content from the `STATUS:` footer.
|
|
60
|
+
3. **`/execute-phase N`** — per-task three-stage loop: `implementer → spec-reviewer → reviewer`. TDD red→green→refactor inside each implementer task. Tasks within a plan are sequential; independent plans parallelize.
|
|
61
|
+
4. **`/verify-work N`** — parallel `verifier` + `security-auditor` + `reviewer` + `spec-reviewer` (phase-level compliance against the plan files), produce UAT report.
|
|
62
|
+
|
|
63
|
+
Start a fresh session (`/clear`) between steps. Each command assumes a clean context.
|
|
64
|
+
|
|
65
|
+
### Milestone transition
|
|
66
|
+
- **`/next-milestone`** — only after ALL phases in the current milestone are `complete`
|
|
67
|
+
|
|
68
|
+
### Session continuity
|
|
69
|
+
- **`/pause-work`** — create `CONTINUE-HERE.md` with in-progress state
|
|
70
|
+
- **`/resume-work`** — read handoff, verify state, continue
|
|
71
|
+
- **`/progress`** — show current position in the roadmap
|
|
72
|
+
|
|
73
|
+
### Ad-hoc
|
|
74
|
+
- **`/quick`** — small task with tracking. Implementer → spec-reviewer → (optional) reviewer.
|
|
75
|
+
- **`/fix`** — bug fix with 4-phase systematic debugging (root cause → pattern → hypothesis → reproducing-test-first impl). Stops after 3 failed fix attempts.
|
|
76
|
+
- **`/review`** — parallel `reviewer` + `security-auditor`, plus `spec-reviewer` when a plan is in scope.
|
|
77
|
+
- **`/atomic-commit`** — analyze diff, split into atomic conventional commits (Red Flag block prevents mixed-concern commits).
|
|
78
|
+
- **`/orchestrate`** — general-purpose specialist dispatch with parallel / chain / fan-out / two-stage modes.
|
|
79
|
+
|
|
80
|
+
## Subagent Roster
|
|
81
|
+
|
|
82
|
+
| Agent | Purpose |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `architect` | Plan structure before coding |
|
|
85
|
+
| `implementer` | Write or change code (inside TDD cycle) |
|
|
86
|
+
| `spec-reviewer` | Verify diff covers exactly what the spec asked — no more, no less |
|
|
87
|
+
| `reviewer` | Code-quality review (correctness, conventions, domain language) |
|
|
88
|
+
| `debugger` | Root-cause diagnosis |
|
|
89
|
+
| `verifier` | Run lint / typecheck / tests, report results |
|
|
90
|
+
| `security-auditor` | Security audit (injection, secrets, unsafe patterns) |
|
|
91
|
+
| `git-committer` | Create atomic conventional commits |
|
|
92
|
+
|
|
93
|
+
## Subagent STATUS Protocol
|
|
94
|
+
|
|
95
|
+
Every draht agent ends with one of four status lines. Orchestrating commands branch on it:
|
|
96
|
+
|
|
97
|
+
- **`STATUS: DONE`** — proceed
|
|
98
|
+
- **`STATUS: DONE_WITH_CONCERNS`** — proceed; log concerns. If correctness-related, address first.
|
|
99
|
+
- **`STATUS: NEEDS_CONTEXT`** — provide missing info and re-dispatch the same agent
|
|
100
|
+
- **`STATUS: BLOCKED`** — STOP. Do not retry the same agent on the same input. Adjust inputs or surface to user.
|
|
101
|
+
|
|
102
|
+
For any spec-driven work, `spec-reviewer` runs **before** `reviewer`. Spec compliance prevents over/under-building; running quality review first lets spec gaps hide.
|
|
103
|
+
|
|
104
|
+
## Task Format (XML inside PLAN.md files)
|
|
105
|
+
|
|
106
|
+
```xml
|
|
107
|
+
<task type="auto">
|
|
108
|
+
<n>Task name</n>
|
|
109
|
+
<context>Bounded context</context>
|
|
110
|
+
<domain>Aggregates/entities touched</domain>
|
|
111
|
+
<files>affected files</files>
|
|
112
|
+
<test>RED phase — write failing tests first</test>
|
|
113
|
+
<action>GREEN phase — minimal impl to pass tests</action>
|
|
114
|
+
<refactor>REFACTOR phase — improve without breaking tests</refactor>
|
|
115
|
+
<verify>How to verify (tests pass + manual check)</verify>
|
|
116
|
+
<done>What "done" looks like as assertions</done>
|
|
117
|
+
</task>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Task types: `auto`, `checkpoint:human-verify`, `checkpoint:decision`.
|
|
121
|
+
|
|
122
|
+
## Hooks
|
|
123
|
+
|
|
124
|
+
The plugin ships workflow hooks under `${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/`:
|
|
125
|
+
|
|
126
|
+
- `gsd-pre-execute.cjs <phase>` — preconditions before execution (DOMAIN.md, plans, uncommitted changes)
|
|
127
|
+
- `gsd-post-task.cjs <phase> <plan> <task> <status> [commit]` — record result + type check + tests + TDD cycle check
|
|
128
|
+
- `gsd-post-phase.cjs <phase>` — generate phase report, update ROADMAP status
|
|
129
|
+
- `gsd-quality-gate.cjs [--strict]` — lint + typecheck + test + coverage against `.planning/config.json` threshold
|
|
130
|
+
|
|
131
|
+
These are invoked from inside commands. In addition, two **lifecycle hooks** fire automatically regardless of command prose (registered in `hooks/hooks.json`):
|
|
132
|
+
|
|
133
|
+
- `post-edit-check.cjs` — PostToolUse on Edit/Write: file-scoped lint feedback on every edit
|
|
134
|
+
- `stop-quality-gate.cjs` — Stop: runs the quality gate when a turn ends with uncommitted source changes in a `.planning` project
|
|
135
|
+
|
|
136
|
+
## Configuration
|
|
137
|
+
|
|
138
|
+
`.planning/config.json` (optional):
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"hooks": {
|
|
143
|
+
"coverageThreshold": 80,
|
|
144
|
+
"tddMode": "advisory",
|
|
145
|
+
"qualityGateStrict": true,
|
|
146
|
+
"stopGate": true
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- `tddMode: "strict"` — post-task hook aborts on green: commit without preceding red:
|
|
152
|
+
- `tddMode: "advisory"` — logs a warning instead
|
|
153
|
+
- `qualityGateStrict` — **defaults to true**: the gate fails (exit 1) on any lint/type/test/coverage miss; set `false` to demote to warnings
|
|
154
|
+
- `stopGate: false` — disable the automatic Stop-time quality gate
|
|
155
|
+
- Hard stop: 3 recorded failures for the same task make `gsd-post-task.cjs` exit non-zero — the retry loop ends there
|
|
156
|
+
|
|
157
|
+
## Key Rules
|
|
158
|
+
|
|
159
|
+
- One phase at a time, one cycle step per session
|
|
160
|
+
- `/next-milestone` ONLY after every phase in the current milestone is verified
|
|
161
|
+
- Fix plans include a reproducing test before any implementation
|
|
162
|
+
- Never skip verification — it's the only thing that marks a phase complete
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: loop-workflow
|
|
3
|
+
description: Loop-driven development discipline — run agents in cycles of work gated by deterministic checks until a stop condition is met. Use when work needs iteration until a measurable criterion holds, when designing retry or verification loops, when a task is too large for one context window, or when choosing between one-shot orchestration and a loop. Triggers on "loop", "iterate until", "keep going until", "run until it passes", "ralph loop", "long-running", or any moment the agent is about to retry work without a defined stop condition.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Loop Workflow
|
|
7
|
+
|
|
8
|
+
A loop is an agent repeating cycles of work until a stop condition is met. The discipline: **the loop closes on a check, not on a feeling of doneness.** Without a check that produces pass/fail, "looks done" is the only signal available and the human becomes the verification loop.
|
|
9
|
+
|
|
10
|
+
## The Four Hand-offs
|
|
11
|
+
|
|
12
|
+
Every loop is defined by what gets handed off to it:
|
|
13
|
+
|
|
14
|
+
| Loop | Hand off | Draht surface |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| Turn-based | the check | TDD cycle inside one task (red → green → refactor → verify) |
|
|
17
|
+
| Goal-based | the stop condition | `/orchestrate-loop` (deterministic check + max iterations) |
|
|
18
|
+
| Phase-based | the spec | `/execute-phase` → `/verify-work` → `--gaps-only` cycle |
|
|
19
|
+
| Session-based | the process | GSD per-phase cycle (`/discuss-phase → /plan-phase → /execute-phase → /verify-work`), fresh context each step |
|
|
20
|
+
|
|
21
|
+
Pick the smallest loop that fits: a failing test needs the TDD loop, not a goal loop; a roadmap phase needs the phase cycle, not an ad-hoc goal loop.
|
|
22
|
+
|
|
23
|
+
## Anatomy of a Sound Loop
|
|
24
|
+
|
|
25
|
+
1. **Deterministic check** — a command whose exit code proves the goal. The loop is only as good as its check; a near-perfect verifier is the highest-leverage component of any loop.
|
|
26
|
+
2. **Explicit stop conditions** — criterion met, max iterations, stall. Every loop needs a bound; an unbounded loop is a bug, not persistence.
|
|
27
|
+
3. **Independent evaluation** — the agent doing the work never decides completion. Re-run the check outside the worker; route the final verdict to a fresh-context evaluator. Agents systematically overrate their own work.
|
|
28
|
+
4. **Recoverable state** — every iteration commits and appends a progress log, so any iteration can die without losing the loop. Fresh iterations run a startup ritual: read the progress log, run the check, observe before changing anything.
|
|
29
|
+
5. **One increment per cycle** — small verified steps beat one-shot attempts. Batching increments hides which change broke the check.
|
|
30
|
+
|
|
31
|
+
## Known Failure Modes → Counters
|
|
32
|
+
|
|
33
|
+
| Failure mode | Counter |
|
|
34
|
+
|---|---|
|
|
35
|
+
| Premature completion claims | Independent re-run of the check; evidence before claims |
|
|
36
|
+
| Self-graded verification | Fresh-context evaluator (spec-reviewer / reviewer) |
|
|
37
|
+
| One-shotting too much per cycle | One increment, one commit per iteration |
|
|
38
|
+
| State lost at context death | Commit every iteration + append-only progress log |
|
|
39
|
+
| Weakening tests or the check to pass | Tests and check are immutable inside a loop; violation means revert + hard stop |
|
|
40
|
+
| Spinning on the same failure | Stall detection — two identical failure signatures in a row means change the inputs, consult `advisor`, or stop |
|
|
41
|
+
| Time blindness (hours burned re-running slow checks) | Keep checks fast and their output terse: failures only |
|
|
42
|
+
|
|
43
|
+
## Interaction With Other Disciplines
|
|
44
|
+
|
|
45
|
+
- `verification-gate` supplies the evidence rules for reading loop results: label them observed / derived / assumed
|
|
46
|
+
- `tdd-workflow` is the innermost loop; `/orchestrate-loop` wraps the same shape at goal level
|
|
47
|
+
- `atomic-reasoning` cuts the increments: an increment is well-cut only if its check can fail while all others pass
|
|
48
|
+
- `model-tiering` sets the economics: loops are volume work, so workers run on the executor tier while steering (the orchestrating context, `advisor`, `spec-reviewer`) stays on the strongest tier — most loop tokens bill at the worker rate
|
|
49
|
+
|
|
50
|
+
## Scope
|
|
51
|
+
|
|
52
|
+
This skill is the discipline reference behind `/orchestrate-loop` and the retry mechanics in `/execute-phase` and `/verify-work`. Consult it before constructing any ad-hoc retry-until-done behaviour.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: model-tiering
|
|
3
|
+
description: Cost-efficient model tiering — the advisor pattern (a cheap executor consults a stronger model rarely) and the orchestrator pattern (a strong model plans while cheaper workers execute). Use when choosing which model runs a session vs its subagents, when cost matters on long agentic work, or when the user mentions "Fable", "advisor", "model tiering", "token cost", "cheaper model", or asks which model should drive a workflow.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Model Tiering
|
|
7
|
+
|
|
8
|
+
Two tiers, two directions of pull. Bill the volume tokens at the cheaper rate and spend the strongest model only where a single decision changes the outcome.
|
|
9
|
+
|
|
10
|
+
- **Advisor tier** — the strongest model available (Claude Fable 5)
|
|
11
|
+
- **Executor tier** — a fast, capable model (Claude Sonnet 5)
|
|
12
|
+
|
|
13
|
+
Reference numbers (SWE-bench Pro): a Sonnet 5 executor with a Fable 5 advisor reaches ~92% of Fable 5's solo score at ~63% of the price, with the advisor consulted roughly once per task. Official reference: <https://platform.claude.com/docs/en/agents-and-tools/tool-use/advisor-tool>
|
|
14
|
+
|
|
15
|
+
## Pattern 1 — Advisor: the executor pulls intelligence down
|
|
16
|
+
|
|
17
|
+
Run the session on the executor tier; dispatch the `advisor` agent (pinned to the strongest tier) rarely and deliberately:
|
|
18
|
+
|
|
19
|
+
- **Once early** — after orientation (finding files, reading what's there) but BEFORE substantive work: writing, committing to an interpretation, building on an assumption
|
|
20
|
+
- **When stuck** — recurring errors, an approach that is not converging, results that don't fit
|
|
21
|
+
- **Once before declaring done** on hard tasks — after writes and test output exist; make the deliverable durable (commit it) before the consult
|
|
22
|
+
|
|
23
|
+
Treat the advice with serious weight: deviate only on empirical failure or primary-source contradiction. If your evidence points one way and the advisor points another, don't silently switch — surface the conflict in one reconcile consult ("I found X, you suggest Y — which constraint breaks the tie?").
|
|
24
|
+
|
|
25
|
+
Target ~1–3 consults per task. On short reactive tasks where the next action is dictated by output just read, skip the advisor — its value is highest before the approach crystallizes.
|
|
26
|
+
|
|
27
|
+
## Pattern 2 — Orchestrator: the strong model pushes work down
|
|
28
|
+
|
|
29
|
+
Run orchestrating sessions (`/orchestrate`, `/orchestrate-loop`, `/plan-phase`, `/execute-phase`) on the strongest tier and let workers execute on the executor tier. The orchestrator plans, decomposes, dispatches, and verifies; workers burn the volume tokens at the lower rate.
|
|
30
|
+
|
|
31
|
+
Pin worker models per agent via the plugin's `configure` command (it writes `model:` into the agent frontmatter). Keep `spec-reviewer` and the final verification gate on a strong tier — verifier quality bounds loop quality.
|
|
32
|
+
|
|
33
|
+
## Choosing
|
|
34
|
+
|
|
35
|
+
| Workload | Pattern |
|
|
36
|
+
|---|---|
|
|
37
|
+
| Mostly mechanical, occasional hard decisions | Advisor — one context, rare consults |
|
|
38
|
+
| Sustained planning and decomposition quality needed | Orchestrator — the strong model steers throughout |
|
|
39
|
+
| Long loops (`/orchestrate-loop`) | Orchestrator, with `advisor` consulted on stall |
|
|
40
|
+
|
|
41
|
+
The patterns compose: an orchestrating session on the executor tier can still pull `advisor` for its hardest decisions.
|
|
42
|
+
|
|
43
|
+
## API-level advisor (built harnesses)
|
|
44
|
+
|
|
45
|
+
For agents built directly on the Claude API (e.g. draht's own harness code), the advisor exists as a server-side tool: `{"type": "advisor_20260301", "name": "advisor", "model": "<advisor model id>"}` with beta header `advisor-tool-2026-03-01`. The executor calls `advisor()` with no input; the server forwards the full transcript to the advisor model and only the advice text returns. Cap cost with `max_uses` and `max_tokens` on the tool definition; trim advice length with an inline user-message request ("Advisor: please keep your guidance under 80 words").
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrate-loop
|
|
3
|
+
description: Draht command prompt wrapper for orchestrate-loop. Use when the user selects the Draht orchestrate-loop workflow or wants to run a verification-gated loop of fresh subagent iterations until a deterministic check passes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Draht Command: orchestrate-loop
|
|
7
|
+
|
|
8
|
+
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
|
+
|
|
10
|
+
When invoked:
|
|
11
|
+
1. Read `../../commands/orchestrate-loop.md` relative to this `SKILL.md`.
|
|
12
|
+
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
|
+
3. Follow that command template as the active workflow.
|
|
14
|
+
4. Use Draht support skills such as `atomic-reasoning`, `loop-workflow`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -19,6 +19,16 @@ Before you say *done*, *fixed*, *works*, *passes*, *ready*, *complete*, or any e
|
|
|
19
19
|
4. **VERIFY** the output actually supports the claim (not just "no error visible")
|
|
20
20
|
5. **ONLY THEN** state the result, with the evidence inline
|
|
21
21
|
|
|
22
|
+
## Label What You Know
|
|
23
|
+
|
|
24
|
+
Evidence isn't binary — statements sit on a ladder, and mislabeling one rung as another is how false confidence spreads. Tag each claim:
|
|
25
|
+
|
|
26
|
+
- **observed** — you ran it and saw the output this session
|
|
27
|
+
- **derived** — follows necessarily from something observed (not "probably", *necessarily*)
|
|
28
|
+
- **assumed** — believed but unchecked; name what would check it
|
|
29
|
+
|
|
30
|
+
A conclusion inherits the weakest label it rests on. "Tests pass (observed), so the feature works (assumed — no end-to-end run)" is an *assumed* verdict wearing an observed one's confidence. Say "the feature works" only when you've observed the feature, not just the tests around it.
|
|
31
|
+
|
|
22
32
|
## What Requires Empirical Verification
|
|
23
33
|
|
|
24
34
|
| Claim | Required Evidence |
|