draht-codex 2026.7.7-1 → 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 +18 -0
- package/agents/advisor.md +45 -0
- package/agents/reviewer.md +1 -0
- package/agents/spec-reviewer.md +1 -1
- package/bin/draht-tools.cjs +1808 -988
- package/commands/execute-phase.md +4 -3
- package/commands/fix.md +1 -1
- package/commands/next-milestone.md +1 -0
- package/commands/orchestrate-loop.md +100 -0
- package/commands/orchestrate.md +25 -2
- package/commands/pause-work.md +4 -3
- package/commands/plan-phase.md +1 -0
- package/commands/quick.md +2 -2
- 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/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
|
@@ -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.
|