@gonrocca/zero-pi 0.1.59 β†’ 0.1.61

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/README.md CHANGED
@@ -42,15 +42,26 @@ Needs Node β‰₯ 20.6. Restart pi after an upgrade.
42
42
  ## πŸ›  `/forge` β€” the SDD pipeline
43
43
 
44
44
  The core of zero-pi. Run **`/forge <feature>`** and the orchestrator drives the
45
- work through four phases, each delegated to its own sub-agent:
45
+ work through six phases β€” the automatic
46
+ **clarify β†’ explore β†’ plan β†’ analyze β†’ build β†’ veredicto** flow β€” each delegated
47
+ to its own sub-agent:
46
48
 
47
49
  | Phase | Does |
48
50
  | ----- | ---- |
51
+ | **clarify** | Record de-risking assumptions before exploration; stop only on blocking ambiguity. |
49
52
  | **explore** | Investigate the codebase read-only; produce findings. |
50
53
  | **plan** | Write requirements, design, and an ordered task list. |
54
+ | **analyze** | Review plan readiness after `/zero-validate`; decide continue or replan. |
51
55
  | **build** | Implement the plan. |
52
56
  | **veredicto** | Review it adversarially and record a verdict. |
53
57
 
58
+ The **clarify** and **analyze** gates are automatic inside `/forge` β€” no extra
59
+ slash command in the normal flow. `clarify` writes `.sdd/<slug>/clarifications.md`
60
+ and asks only when proceeding would risk the wrong product; `analyze` writes
61
+ `.sdd/<slug>/checklist.md` after the structural `/zero-validate` gate and returns
62
+ `continue` (build) or `replan` (re-run plan with concrete defects). Neither gate
63
+ counts as a build/veredicto round.
64
+
54
65
  The verdict is `pasa` (done), `corregir` (re-run build), or `replantear`
55
66
  (re-run plan). A hard iteration cap bounds the build↔veredicto loop β€” reached
56
67
  without a `pasa`, the run stops and is reported as **not verified**.
@@ -74,8 +85,8 @@ into `/forge` for you.
74
85
  | Feature | What it does |
75
86
  | ------- | ------------ |
76
87
  | **Strict TDD** | The build phase drives RED β†’ GREEN β†’ TRIANGULATE β†’ REFACTOR with a TDD Cycle Evidence table; veredicto audits it. On by default, runtime-gated on a test runner; `tdd.mode: "off"` disables it. |
77
- | **`/zero-models`** | Pick the model + provider + thinking level for each SDD phase β€” a boxed-window picker, or set one directly. Direct assignments are validated against pi's model registry when available. |
78
- | **Phase tool gating** | Generated `zero-*` sub-agents get phase-specific tool allowlists: explore/veredicto are read-only, plan writes SDD artifacts, build edits code. |
88
+ | **`/zero-models`** | Pick the model + provider + thinking level for each of the six SDD phases β€” a boxed-window picker, or set one directly. Direct assignments are validated against pi's model registry when available. |
89
+ | **Phase tool gating** | Generated `zero-*` sub-agents get phase-specific tool allowlists: explore/veredicto are read-only, clarify/analyze/plan write only `.sdd` artifacts, build edits code. |
79
90
  | **Dependency-aware tasks** | `tasks.md` is validated as a task graph with mandatory `depends:` edges, topological ordering, and review workload totals. |
80
91
  | **Autotune** | Learns which model fits each phase from your run history and re-tunes itself; optional `autotuneBudget.maxPhaseCostUsd` suppresses costly step-ups. |
81
92
  | **`/zero-doctor`** | Preflight diagnostics for zero-pi: package install, Node version, pi-subagents, generated phase agents, model config, `.sdd/config`, run history, git, and `gh` auth. |
@@ -179,21 +190,28 @@ zero-pi keeps its state in `~/.pi/zero.json` (per-phase `models`, `providers`,
179
190
  per-project artifacts live under `.sdd/`. Set `ZERO_RESUME=off` to disable the
180
191
  conversation-resume note.
181
192
 
182
- `~/.pi/zero.json` stores three parallel per-phase maps plus the autotune mode:
193
+ `~/.pi/zero.json` stores three parallel per-phase maps plus the autotune mode.
194
+ The configurable phases are `clarify`, `explore`, `plan`, `analyze`, `build`,
195
+ and `veredicto`; a pre-gates file that lists only the original four stays valid
196
+ and the missing `clarify`/`analyze` fall back to defaults (cheap/fast clarify,
197
+ strong analyze):
183
198
 
184
199
  ```json
185
200
  {
186
- "models": { "explore": "claude-haiku-4-5", "build": "claude-sonnet-4-6" },
187
- "providers": { "explore": "anthropic", "build": "anthropic" },
188
- "thinking": { "explore": "low", "build": "high" },
201
+ "models": { "clarify": "claude-haiku-4-5", "analyze": "claude-opus-4-8", "build": "claude-sonnet-4-6" },
202
+ "providers": { "clarify": "anthropic", "analyze": "anthropic", "build": "anthropic" },
203
+ "thinking": { "analyze": "high", "build": "high" },
189
204
  "autotune": "ask",
190
205
  "autotuneBudget": { "maxPhaseCostUsd": 4, "minSamples": 3 }
191
206
  }
192
207
  ```
193
208
 
194
209
  The `thinking` map sets each phase's pi effort level β€” one of `off`, `minimal`,
195
- `low`, `medium`, `high`, `xhigh`. A phase with no entry gets no `thinking:` line
196
- in its generated sub-agent (no aggressive default). `autotuneBudget` is optional:
210
+ `low`, `medium`, `high`, `xhigh`. An explicit entry always wins; a phase with no
211
+ entry (or an invalid level) falls back to the package default β€” `clarify:
212
+ medium`, `explore: high`, `plan: high`, `analyze: high`, `build: high`,
213
+ `veredicto: xhigh` β€” so no phase inherits your session-wide
214
+ `defaultThinkingLevel`. `autotuneBudget` is optional:
197
215
  when `maxPhaseCostUsd` is set, autotune will not step a blamed phase up to a more
198
216
  expensive tier if that phase/model is already at or above the average USD
199
217
  ceiling with enough cost samples (`minSamples`, default 3). Set thinking from
@@ -218,6 +236,18 @@ audits the TDD evidence) and accepts `"off"` to disable the discipline.
218
236
  `tdd.testCommand` overrides the auto-detected test runner the TDD cycle invokes;
219
237
  leave it empty to let the build/veredicto phases detect it from the project.
220
238
 
239
+ ### Token efficiency
240
+
241
+ The phase sub-agents run **without** your global project context
242
+ (`inheritProjectContext: false`): a global `AGENTS.md` is heavy and may carry
243
+ personal data or credentials no phase needs β€” project conventions still reach
244
+ the phases, because explore/build skim the repo's own `AGENTS.md`/`CLAUDE.md`.
245
+ Every phase runs at an explicit `thinking:` level (your `zero.json` entry wins;
246
+ gaps take the package defaults above), and explore works under a numeric
247
+ tool-call budget with a mid-budget stop check. The heavy lifting happens inside
248
+ the sub-agents on their own models β€” leave the session that runs `/forge` on
249
+ your cheap default model.
250
+
221
251
  ## Continuous integration
222
252
 
223
253
  The `.github/workflows/zero-pi-ci.yml` workflow runs on every push to `main` and
@@ -34,7 +34,13 @@ import {
34
34
  } from "./autotune.ts";
35
35
  import { parseMeta, type PhaseMeta } from "./zero-cost.ts";
36
36
 
37
- /** The SDD phases, in pipeline order. Mirrors `zero-models.ts`. */
37
+ /** The four core SDD phases autotune reads models for and attributes blame to,
38
+ * in pipeline order. This is deliberately NOT the full six-phase list in
39
+ * `zero-models.ts`: the `clarify`/`analyze` gates are never verdict-attributable
40
+ * (only `corregir`β†’build and `replantear`β†’plan drive adjustments), and the
41
+ * run-record schema keeps these four as its required phases. Reading only these
42
+ * four means a configured gate model in `zero.json` is never turned into a
43
+ * pending adjustment. */
38
44
  const PHASES = ["explore", "plan", "build", "veredicto"] as const;
39
45
  type Phase = (typeof PHASES)[number];
40
46
 
@@ -1,12 +1,13 @@
1
1
  // zero-pi β€” SDD sub-agent provisioning.
2
2
  //
3
- // `/forge` delegates each phase to a dedicated sub-agent β€” `zero-explore`,
4
- // `zero-plan`, `zero-build`, `zero-veredicto`. pi-subagents discovers agents
5
- // from `~/.pi/agent/agents/**/*.md`, but a `pi install` of zero-pi ships only
6
- // the phase *prompts* (`prompts/phases/*.md`), never the agent definitions β€”
7
- // so `/forge` had nothing to delegate to and stalled.
3
+ // `/forge` delegates each phase to a dedicated sub-agent β€” `zero-clarify`,
4
+ // `zero-explore`, `zero-plan`, `zero-analyze`, `zero-build`, `zero-veredicto`.
5
+ // pi-subagents discovers agents from `~/.pi/agent/agents/**/*.md`, but a
6
+ // `pi install` of zero-pi ships only the phase *prompts* (`prompts/phases/*.md`),
7
+ // never the agent definitions β€” so `/forge` had nothing to delegate to and
8
+ // stalled.
8
9
  //
9
- // This extension closes that gap: at load it generates the four agent files
10
+ // This extension closes that gap: at load it generates the six agent files
10
11
  // under `~/.pi/agent/agents/zero/` from the package's own phase prompts and
11
12
  // the per-phase models in `~/.pi/zero.json`. The files are regenerated every
12
13
  // load, so they stay in sync with the prompts and with `/zero-models`.
@@ -16,11 +17,13 @@ import { homedir } from "node:os";
16
17
  import { dirname, join } from "node:path";
17
18
  import { fileURLToPath } from "node:url";
18
19
 
19
- import { isThinkingLevel } from "./zero-models.ts";
20
+ import { DEFAULT_THINKING, isThinkingLevel } from "./zero-models.ts";
20
21
  import type { ThinkingLevel } from "./zero-models.ts";
21
22
 
22
- /** The four SDD phases, each backed by a `prompts/phases/<phase>.md`. */
23
- export const PHASES = ["explore", "plan", "build", "veredicto"] as const;
23
+ /** The six SDD phases, in pipeline order, each backed by a
24
+ * `prompts/phases/<phase>.md`. `clarify` is the pre-explore assumption gate and
25
+ * `analyze` is the post-plan readiness gate; both write only `.sdd` artifacts. */
26
+ export const PHASES = ["clarify", "explore", "plan", "analyze", "build", "veredicto"] as const;
24
27
  export type Phase = (typeof PHASES)[number];
25
28
 
26
29
  /**
@@ -37,23 +40,32 @@ export const SUPPORT_MODULES = ["strict-tdd.md", "strict-tdd-verify.md"] as cons
37
40
  *
38
41
  * Explore and veredicto are intentionally read-only at the mutation-tool layer:
39
42
  * they can inspect files and run scoped verification commands, but they cannot
40
- * edit. Plan can write only SDD artifacts; build is the only phase with the
41
- * full mutation set for product code. This is enforced by pi-subagents' `tools:`
43
+ * edit. The `clarify` and `analyze` gates can write β€” but only their own
44
+ * `.sdd/<slug>/` artifacts (`clarifications.md`, `checklist.md`); the tool
45
+ * allowlist cannot enforce paths, so their prompts state the `.sdd`-only write
46
+ * boundary. Plan can write SDD artifacts; build is the only phase with the full
47
+ * mutation set for product code. This is enforced by pi-subagents' `tools:`
42
48
  * frontmatter key, so an accidental phase prompt drift does not silently grant
43
49
  * broad editing power to every child.
44
50
  */
45
51
  export const PHASE_TOOLS: Record<Phase, readonly string[]> = {
52
+ clarify: ["read", "bash", "write", "edit"],
46
53
  explore: ["read", "bash"],
47
54
  plan: ["read", "bash", "write", "edit"],
55
+ analyze: ["read", "bash", "write", "edit"],
48
56
  build: ["read", "bash", "write", "edit"],
49
57
  veredicto: ["read", "bash"],
50
58
  };
51
59
 
52
60
  /** Non-build phases may mention implementation terms while using `bash`; do not
53
- * let pi-subagents' implementation completion guard classify them as writers. */
61
+ * let pi-subagents' implementation completion guard classify them as writers.
62
+ * Only `build` is a real implementation phase β€” the gates and read phases all
63
+ * disable the guard. */
54
64
  export const PHASE_COMPLETION_GUARD: Record<Phase, boolean> = {
65
+ clarify: false,
55
66
  explore: false,
56
67
  plan: false,
68
+ analyze: false,
57
69
  build: true,
58
70
  veredicto: false,
59
71
  };
@@ -103,9 +115,13 @@ export function buildAgentFile(
103
115
  if (thinking && isThinkingLevel(thinking)) front.push(`thinking: ${thinking}`);
104
116
  front.push(`tools: ${PHASE_TOOLS[phase].join(", ")}`);
105
117
  if (!PHASE_COMPLETION_GUARD[phase]) front.push("completionGuard: false");
118
+ // `inheritProjectContext: false` keeps the user's global AGENTS.md out of
119
+ // every phase sub-agent: it is heavy (re-sent to each phase) and may carry
120
+ // personal data or credentials no phase needs. Project conventions still
121
+ // reach the phases β€” explore/build skim the repo's own AGENTS.md/CLAUDE.md.
106
122
  front.push(
107
123
  "systemPromptMode: replace",
108
- "inheritProjectContext: true",
124
+ "inheritProjectContext: false",
109
125
  "inheritSkills: false",
110
126
  "---",
111
127
  );
@@ -164,6 +180,17 @@ export function phaseThinking(data: unknown, phase: Phase): ThinkingLevel | unde
164
180
  return undefined;
165
181
  }
166
182
 
183
+ /**
184
+ * Resolve the effective `thinking:` level for a phase: the user's valid
185
+ * `zero.json` entry (or recoverable legacy suffix) wins; a missing or invalid
186
+ * entry falls back to the package default, so no generated agent ever inherits
187
+ * the session-wide `defaultThinkingLevel` from the user's settings. Exported
188
+ * for tests.
189
+ */
190
+ export function resolvePhaseThinking(data: unknown, phase: Phase): ThinkingLevel {
191
+ return phaseThinking(data, phase) ?? DEFAULT_THINKING[phase];
192
+ }
193
+
167
194
  /** Read the per-phase model from `~/.pi/zero.json`; `undefined` when absent. */
168
195
  function readPhaseModel(phase: Phase): string | undefined {
169
196
  try {
@@ -212,7 +239,7 @@ export default function register(_pi?: unknown): void {
212
239
  body,
213
240
  description,
214
241
  readPhaseModel(phase),
215
- readPhaseThinking(phase),
242
+ readPhaseThinking(phase) ?? DEFAULT_THINKING[phase],
216
243
  );
217
244
  writeFileSync(join(agentsDir, `zero-${phase}.md`), file, "utf8");
218
245
  } catch {
@@ -65,8 +65,10 @@ const THINKING_SDD = [
65
65
 
66
66
  /** SDD phase labels keyed by the zero sub-agent that owns the phase. */
67
67
  const SDD_PHASE: Record<string, string> = {
68
+ "zero-clarify": "Aclarando supuestos",
68
69
  "zero-explore": "Explorando el cΓ³digo",
69
70
  "zero-plan": "Planeando la soluciΓ³n",
71
+ "zero-analyze": "Analizando el plan",
70
72
  "zero-build": "Construyendo la implementaciΓ³n",
71
73
  "zero-veredicto": "Revisando el veredicto",
72
74
  };
@@ -156,7 +156,7 @@ export function bannerBlock(width: number): string[] {
156
156
  if (width < 64) {
157
157
  return [center(fg(PEACH, "ZERO SDD"), width), center(fg(MUTED, "pi.dev Β· spec-driven work"), width)];
158
158
  }
159
- const tag = fg(PEACH, "ZERO SDD") + fg(MUTED, " explore β†’ plan β†’ build β†’ veredicto");
159
+ const tag = fg(PEACH, "ZERO SDD") + fg(MUTED, " clarify β†’ explore β†’ plan β†’ analyze β†’ build β†’ veredicto");
160
160
  return [ornament(width), ...renderLogo(width), center(tag, width), ornament(width)];
161
161
  }
162
162
 
@@ -13,8 +13,9 @@
13
13
 
14
14
  import { formatTokens } from "./format-tokens.ts";
15
15
 
16
- /** The SDD phases a run is composed of, in pipeline order. */
17
- export const COST_PHASES = ["explore", "plan", "build", "veredicto"] as const;
16
+ /** The SDD phases a run is composed of, in pipeline order β€” the `clarify` and
17
+ * `analyze` gate sub-agents write cost meta like any other phase. */
18
+ export const COST_PHASES = ["clarify", "explore", "plan", "analyze", "build", "veredicto"] as const;
18
19
  export type CostPhase = (typeof COST_PHASES)[number];
19
20
 
20
21
  /** Token + cost usage of a single sub-agent run. */
@@ -57,12 +58,12 @@ export interface RunCost {
57
58
  total: PhaseUsage & { durationMs: number; toolCount: number; subAgents: number };
58
59
  }
59
60
 
60
- const PHASE_INDEX: Record<CostPhase, number> = { explore: 0, plan: 1, build: 2, veredicto: 3 };
61
+ const PHASE_INDEX: Record<CostPhase, number> = { clarify: 0, explore: 1, plan: 2, analyze: 3, build: 4, veredicto: 5 };
61
62
 
62
63
  /** Map a sub-agent name `zero-<phase>` to its phase, or `null`. */
63
64
  export function phaseFromAgent(agent: unknown): CostPhase | null {
64
65
  if (typeof agent !== "string") return null;
65
- const m = /^zero-(explore|plan|build|veredicto)$/.exec(agent);
66
+ const m = /^zero-(clarify|explore|plan|analyze|build|veredicto)$/.exec(agent);
66
67
  return m ? (m[1] as CostPhase) : null;
67
68
  }
68
69
 
@@ -18,8 +18,8 @@ import type { AutotunePending } from "./autotune-extension.ts";
18
18
 
19
19
  /** The SDD phases, in pipeline order β€” re-stated locally so the pure module
20
20
  * carries no value import. Must stay in lockstep with `PHASES` in
21
- * `zero-models.ts`. */
22
- const PHASES = ["explore", "plan", "build", "veredicto"] as const;
21
+ * `zero-models.ts` (the `clarify` gate leads, `analyze` sits after `plan`). */
22
+ const PHASES = ["clarify", "explore", "plan", "analyze", "build", "veredicto"] as const;
23
23
 
24
24
  /** The three autotune modes offered on the autotune screen. */
25
25
  const AUTOTUNE_MODES = ["auto", "ask", "off"] as const;
@@ -51,8 +51,10 @@ import {
51
51
  type PickerState,
52
52
  } from "./zero-models-picker.ts";
53
53
 
54
- /** The SDD phases, in pipeline order. */
55
- export const PHASES = ["explore", "plan", "build", "veredicto"] as const;
54
+ /** The SDD phases, in pipeline order. `clarify` is the pre-explore assumption
55
+ * gate and `analyze` is the post-plan readiness gate; both are configurable
56
+ * here like any other phase. */
57
+ export const PHASES = ["clarify", "explore", "plan", "analyze", "build", "veredicto"] as const;
56
58
  export type Phase = (typeof PHASES)[number];
57
59
 
58
60
  /** The per-phase model map. */
@@ -74,15 +76,33 @@ export function isThinkingLevel(value: unknown): value is ThinkingLevel {
74
76
  return typeof value === "string" && (THINKING_LEVELS as readonly string[]).includes(value);
75
77
  }
76
78
 
77
- /** Fallback models when `~/.pi/zero.json` has none β€” cheap to explore, strong
78
- * to plan and review. */
79
+ /** Fallback models when `~/.pi/zero.json` has none β€” cheap to clarify/explore,
80
+ * strong to plan, analyze and review. A pre-gates zero.json missing `clarify`/
81
+ * `analyze` keeps its four phases and gets these gate defaults in memory. */
79
82
  const DEFAULT_MODELS: PhaseModels = {
83
+ clarify: "claude-haiku-4-5",
80
84
  explore: "claude-haiku-4-5",
81
85
  plan: "claude-opus-4-8",
86
+ analyze: "claude-opus-4-8",
82
87
  build: "claude-sonnet-4-6",
83
88
  veredicto: "claude-opus-4-8",
84
89
  };
85
90
 
91
+ /** Package default thinking level per phase, used to fill any gap in the
92
+ * user's `zero.json` when the agent files are generated β€” so no phase ever
93
+ * inherits the session-wide `defaultThinkingLevel` from the user's settings.
94
+ * An explicit valid `zero.json` entry always wins. The gates get a level
95
+ * proportional to their job (clarify records assumptions, analyze reviews
96
+ * artifacts); veredicto keeps `xhigh` as the pipeline's adversarial guard. */
97
+ export const DEFAULT_THINKING: Record<Phase, ThinkingLevel> = {
98
+ clarify: "medium",
99
+ explore: "high",
100
+ plan: "high",
101
+ analyze: "high",
102
+ build: "high",
103
+ veredicto: "xhigh",
104
+ };
105
+
86
106
  /** Model list used only when pi's model registry is unavailable. */
87
107
  const FALLBACK_MODELS = [
88
108
  "claude-opus-4-8",
@@ -144,7 +164,14 @@ function stripThinkingSuffix(model: string): string {
144
164
  */
145
165
  export function readProviders(data: Record<string, unknown>): PhaseProviders {
146
166
  const raw = (data.providers ?? {}) as Record<string, unknown>;
147
- const providers: PhaseProviders = { explore: "", plan: "", build: "", veredicto: "" };
167
+ const providers: PhaseProviders = {
168
+ clarify: "",
169
+ explore: "",
170
+ plan: "",
171
+ analyze: "",
172
+ build: "",
173
+ veredicto: "",
174
+ };
148
175
  for (const phase of PHASES) {
149
176
  if (typeof raw[phase] === "string") providers[phase] = raw[phase] as string;
150
177
  }
@@ -778,7 +805,7 @@ export default function register(pi?: PiExtensionAPI): void {
778
805
  if (!assignment) {
779
806
  ctx.ui.notify(
780
807
  "uso: /zero-models β€”oβ€” /zero-models <fase>=[<provider>/]<modelo> [thinking=<nivel>] " +
781
- "(fase: explore | plan | build | veredicto Β· " +
808
+ "(fase: clarify | explore | plan | analyze | build | veredicto Β· " +
782
809
  "nivel: off | minimal | low | medium | high | xhigh) β€”oβ€” " +
783
810
  "/zero-models autotune=<modo>",
784
811
  "warning",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gonrocca/zero-pi",
3
- "version": "0.1.59",
4
- "description": "zero-pi β€” an installable layer for pi (pi.dev): the zero spec-driven development workflow (explore β†’ plan β†’ build β†’ veredicto) with per-phase model autotune and token-efficient batched builds. Adds capability to pi without modifying pi.",
3
+ "version": "0.1.61",
4
+ "description": "zero-pi β€” an installable layer for pi (pi.dev): the zero spec-driven development workflow (clarify β†’ explore β†’ plan β†’ analyze β†’ build β†’ veredicto) with automatic clarify/analyze gates, per-phase model autotune, and token-efficient batched builds. Adds capability to pi without modifying pi.",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "pi",
package/prompts/forge.md CHANGED
@@ -3,13 +3,20 @@ description: Run the zero spec-driven development pipeline for a feature request
3
3
  ---
4
4
 
5
5
  Run the zero SDD pipeline for the feature request below β€” you are the
6
- orchestrator. Drive it through four phases in order: **explore β†’ plan β†’ build β†’
7
- veredicto**, delegating each to its sub-agent (`zero-explore`, `zero-plan`,
8
- `zero-build`, `zero-veredicto`). A `corregir` verdict re-runs `build`; a
9
- `replantear` verdict re-runs `plan`; after a few rounds with no `pasa`, stop and
10
- report the result as not verified. Ask the user for interactive or automatic
11
- mode up front; in interactive mode pause after each phase for approval. Never
12
- claim success unless veredicto returned `pasa`.
6
+ orchestrator. Drive it through the phases in order:
7
+ **clarify β†’ explore β†’ plan β†’ analyze β†’ build β†’ veredicto**, delegating each to
8
+ its sub-agent (`zero-clarify`, `zero-explore`, `zero-plan`, `zero-analyze`,
9
+ `zero-build`, `zero-veredicto`). The `clarify` and `analyze` gates run
10
+ **automatically** inside `/forge` β€” there is no slash command a user must run
11
+ by hand for the normal flow. `clarify` records assumptions in
12
+ `.sdd/<slug>/clarifications.md` and stops only on genuinely blocking ambiguity;
13
+ `analyze` writes `.sdd/<slug>/checklist.md` after `plan`/`/zero-validate` and
14
+ returns `continue` (proceed to build) or `replan` (re-run plan with its
15
+ defects). A `corregir` verdict re-runs `build`; a `replantear` verdict re-runs
16
+ `plan`; after a few rounds with no `pasa`, stop and report the result as not
17
+ verified. Ask the user for interactive or automatic mode up front; in
18
+ interactive mode pause after each phase for approval. Never claim success unless
19
+ veredicto returned `pasa`.
13
20
 
14
21
  **Parse the arguments first.** If the request begins with `--continue`, this is
15
22
  a **resume** run, not a fresh one:
@@ -31,7 +38,7 @@ veredicto audits that evidence and returns `corregir` if it fails. Set
31
38
  **Output and language.** Follow the orchestrator's `## Language Boundary` and
32
39
  `## Output Contract`: user-facing chat in Spanish (natural Rioplatense voseo),
33
40
  the bounded per-phase summary, no raw tool output, no agent listings, no
34
- step-by-step narration β€” progress and the final verdict, never a log. The four
41
+ step-by-step narration β€” progress and the final verdict, never a log. The six
35
42
  `zero-*` sub-agents already exist; delegate to them directly without running a
36
43
  `subagent` listing.
37
44
 
@@ -1,28 +1,43 @@
1
1
  ---
2
- description: zero SDD orchestrator β€” drives the explore β†’ plan β†’ build β†’ veredicto pipeline
2
+ description: zero SDD orchestrator β€” drives the clarify β†’ explore β†’ plan β†’ analyze β†’ build β†’ veredicto pipeline
3
3
  ---
4
4
 
5
5
  # zero β€” SDD Orchestrator
6
6
 
7
7
  You are the orchestrator of a spec-driven development (SDD) run. You COORDINATE
8
8
  the work; you decide what runs next β€” never let the loop drift on the model's
9
- whim. Drive the run through four phases, in order:
10
-
11
- 1. **explore** β€” investigate the codebase read-only; produce findings.
12
- 2. **plan** β€” write a plan: requirements, design, and an ordered task list.
13
- 3. **build** β€” implement the plan.
14
- 4. **veredicto** β€” review the build adversarially with a fresh perspective and
9
+ whim. Drive the run through the phases, in order:
10
+
11
+ 1. **clarify** β€” record de-risking assumptions before exploration; stop only on
12
+ genuinely blocking ambiguity. Writes `.sdd/<slug>/clarifications.md`.
13
+ 2. **explore** β€” investigate the codebase read-only; produce findings.
14
+ 3. **plan** β€” write a plan: requirements, design, and an ordered task list.
15
+ 4. **analyze** β€” review plan readiness after `/zero-validate`; decide
16
+ `continue` or `replan`. Writes `.sdd/<slug>/checklist.md`.
17
+ 5. **build** β€” implement the plan.
18
+ 6. **veredicto** β€” review the build adversarially with a fresh perspective and
15
19
  record a verdict: `pasa`, `corregir`, or `replantear`.
16
20
 
21
+ The full automatic flow is
22
+ **clarify β†’ explore β†’ plan β†’ /zero-validate β†’ analyze β†’ build β†’ veredicto**.
23
+ Both gates run automatically inside `/forge`; a user never runs them by a
24
+ separate slash command in the normal flow. (Any manual slash form is a debug
25
+ override only, never part of the automatic run.)
26
+
17
27
  ## Phase order and the iteration cap
18
28
 
19
29
  - A `pasa` verdict finishes the run successfully.
20
30
  - A `corregir` verdict re-runs **build**.
21
- - A `replantear` verdict re-runs **plan**, then **build**.
31
+ - A `replantear` verdict re-runs **plan**, then `/zero-validate`, then
32
+ **analyze**, then **build**.
22
33
  - Count every build/veredicto round. There is a hard **cap** on rounds. When
23
34
  the cap is reached without a `pasa` verdict, STOP. Report that the result is
24
35
  **not verified** β€” do **not** claim success.
25
36
 
37
+ The `clarify` and `analyze` gates are **not** build/veredicto rounds: they never
38
+ count against the iteration cap. An `analyze` `replan` re-runs `plan` and comes
39
+ back through `analyze` before build begins; it does not consume a round.
40
+
26
41
  The orchestrator code controls phase order and the round count. The cap is not
27
42
  optional and the model does not get to extend it.
28
43
 
@@ -39,8 +54,8 @@ state file; the artifacts are the run's durable state.
39
54
  disambiguate. (`forge.md` already reports "no such run" and stops if the
40
55
  directory is absent.)
41
56
  - `--continue` with no slug β€” scan `.sdd/*/` and classify every run by its
42
- resume-point state (below). "Unfinished" = state `no-plan`, `building`, or
43
- `built` (anything except `done`).
57
+ resume-point state (below). "Unfinished" = state `clarifying`, `no-plan`,
58
+ `analyzing`, `building`, or `built` (anything except `done`).
44
59
  - Exactly one unfinished run β†’ resume it silently.
45
60
  - More than one β†’ list each unfinished run with its slug and detected resume
46
61
  point, and ask the user which to resume.
@@ -48,11 +63,23 @@ state file; the artifacts are the run's durable state.
48
63
 
49
64
  **Resume-point algorithm.** For the selected `<slug>`:
50
65
 
66
+ 0. If no complete `.sdd/<slug>/clarifications.md` exists **and** the run has not
67
+ reached explore/plan yet (no `requirements.md`/`spec.md`/`design.md`) β†’ state
68
+ `clarifying`; resume at **clarify**, then explore. A truncated
69
+ `clarifications.md` is rebuilt, not trusted.
51
70
  1. If `.sdd/<slug>/requirements.md` is missing β†’ state `no-plan`; resume at
52
71
  **explore**, then plan (the run barely started; rebuild the plan artifacts).
53
72
  2. Else if `.sdd/<slug>/design.md` or `.sdd/<slug>/tasks.md` is missing β†’ state
54
73
  `no-plan`; resume at **plan** (requirements survived; finish the plan).
55
74
  3. Else (all three plan artifacts exist):
75
+ - If a complete `.sdd/<slug>/checklist.md` exists with `Decision: replan`
76
+ β†’ state `no-plan`; resume at **plan** with that checklist's blockers, then
77
+ `/zero-validate` and **analyze** again before build.
78
+ - Else if no complete `.sdd/<slug>/checklist.md` exists (absent or truncated)
79
+ β†’ state `analyzing`; resume at **analyze** (run `/zero-validate` first when
80
+ available), **not** build. Rebuild a truncated `checklist.md`.
81
+ - Else (`checklist.md` exists with `Decision: continue`) β€” fall through to
82
+ the build/veredicto state logic below:
56
83
  - If `tasks.md` has at least one `[ ]` task β†’ state `building`; resume at
57
84
  **build**, starting at the first `[ ]` task. Already-`[x]` tasks are done β€”
58
85
  do not redo them.
@@ -69,11 +96,13 @@ state file; the artifacts are the run's durable state.
69
96
  absence of proof always resolves toward re-verification.
70
97
 
71
98
  **Sanity-checking artifacts on resume.** A phase may have been killed
72
- mid-write, leaving a truncated `design.md` or `tasks.md`. When you brief the
73
- resumed phase's sub-agent, instruct it to sanity-check the artifacts it depends
74
- on (plan checks `requirements.md`/`design.md` look complete; build checks
75
- `tasks.md` parses as a checklist) and rebuild an obviously-incomplete one rather
76
- than trust it.
99
+ mid-write, leaving a truncated `clarifications.md`, `design.md`, `tasks.md`, or
100
+ `checklist.md`. When you brief the resumed phase's sub-agent, instruct it to
101
+ sanity-check the artifacts it depends on (plan checks `requirements.md`/
102
+ `design.md` look complete; analyze checks `tasks.md`/`checklist.md`; build
103
+ checks `tasks.md` parses as a checklist) and rebuild an obviously-incomplete one
104
+ rather than trust it. A truncated `clarifications.md` or `checklist.md` is
105
+ treated the same as any other truncated artifact β€” rebuilt, never trusted.
77
106
 
78
107
  **Pipeline guarantees on resume.** Resume enters the same loop at a later
79
108
  phase β€” every existing guarantee still holds: phase order proceeds forward from
@@ -96,13 +125,19 @@ non-existent `.sdd/<slug>/` proceeds as a fresh run with no prompt.
96
125
 
97
126
  ## Sub-agent delegation
98
127
 
99
- Each phase runs as its own sub-agent β€” `zero-explore`, `zero-plan`,
100
- `zero-build`, `zero-veredicto` β€” so every phase executes on the model it is
101
- configured for: a cheaper model for exploration, a stronger model for planning
102
- and the adversarial veredicto. Delegate each phase to its sub-agent and wait
103
- for its result. The orchestrator keeps control of phase order and the round
128
+ Each phase runs as its own sub-agent β€” `zero-clarify`, `zero-explore`,
129
+ `zero-plan`, `zero-analyze`, `zero-build`, `zero-veredicto` β€” so every phase
130
+ executes on the model it is configured for: a cheap/fast model for the clarify
131
+ gate and exploration, a stronger model for planning, the adversarial analyze
132
+ gate, and the adversarial veredicto. Delegate each phase to its sub-agent and
133
+ wait for its result. The orchestrator keeps control of phase order and the round
104
134
  count β€” the sub-agents only carry out their own phase.
105
135
 
136
+ The `clarify` and `analyze` gates write only under `.sdd/<slug>/`
137
+ (`clarifications.md`, `checklist.md`) and are forbidden from editing product
138
+ code β€” their prompts state the `.sdd`-only write boundary and the tool profiles
139
+ keep them minimal.
140
+
106
141
  **Thin briefs β€” reference, never re-paste.** A sub-agent reads the
107
142
  `.sdd/<slug>/` artifacts itself, so its brief carries only what it needs to
108
143
  start: the feature slug, the artifact directory, and β€” for a build batch β€” the
@@ -116,6 +151,27 @@ batched build issues many briefs.
116
151
 
117
152
  After **plan** returns, run `/zero-validate <slug>` when the command is available. Treat structural validation errors as a plan failure: summarize the defects, re-run **plan** with those exact defects once, and validate again before entering build. Warnings (for example an intentionally-missing optional proposal) can proceed only when you name the warning in the phase summary. The gate specifically protects the dependency graph: every task must carry `files`, `depends`, `evidence`, and `review`; dependencies must point backward to known task ids; and the review workload total must match.
118
153
 
154
+ ## Analyze gate
155
+
156
+ After a clean (or explicitly non-blocking) `/zero-validate`, run the **analyze**
157
+ gate as the `zero-analyze` sub-agent before build. `/zero-validate` is the
158
+ structural check; `analyze` is the qualitative readiness review β€” it does not
159
+ re-run the structural checks, it judges whether the plan is actually a good,
160
+ buildable plan (unresolved ambiguity, weak acceptance criteria, unsafe task
161
+ dependencies, missing focused-test evidence, scope creep, review-workload risk).
162
+ It writes `.sdd/<slug>/checklist.md` with a `Decision: continue` or
163
+ `Decision: replan` line.
164
+
165
+ - `Decision: continue` β†’ proceed to **build**.
166
+ - `Decision: replan` β†’ do **not** start build. Re-run **plan** with the
167
+ analyzer's concrete blockers from `checklist.md`, run `/zero-validate` again,
168
+ then re-run **analyze** before build. This gate loop is not a build/veredicto
169
+ round and does not count against the iteration cap.
170
+
171
+ The `analyze` gate reads `checklist.md` by path in later briefs β€” never paste
172
+ its contents. If the command/sub-agent is unavailable, note it in the phase
173
+ summary and proceed to build on the structural validation alone.
174
+
119
175
  ## Pre-build checkpoint
120
176
 
121
177
  Before the first **build** batch of every round, run `/zero-checkpoint <slug>` when available. It writes a patch-based checkpoint under `.sdd/<slug>/checkpoints/<id>/` so a risky build has a concrete restore trail. If the command is missing or reports untracked files that were not captured, continue only after surfacing that risk in the build phase-start summary. Do not run destructive restore commands automatically; the checkpoint only records evidence and a reviewed `restore.sh`.
@@ -193,19 +249,25 @@ on the sub-agent to discover it alone.
193
249
  ## Model configuration
194
250
 
195
251
  The per-phase model assignments live in `~/.pi/zero.json`: `models` maps each
196
- phase (`explore`, `plan`, `build`, `veredicto`) to a model id, the parallel
197
- `providers` map gives the provider that model belongs to, and a parallel
198
- `thinking` map gives the pi effort level (`off`, `minimal`, `low`, `medium`,
199
- `high`, `xhigh`) for each phase. Read that file at the start of a run and
200
- delegate each phase's sub-agent to its configured provider + model. When the
252
+ phase (`clarify`, `explore`, `plan`, `analyze`, `build`, `veredicto`) to a model
253
+ id, the parallel `providers` map gives the provider that model belongs to, and a
254
+ parallel `thinking` map gives the pi effort level (`off`, `minimal`, `low`,
255
+ `medium`, `high`, `xhigh`) for each phase. Read that file at the start of a run
256
+ and delegate each phase's sub-agent to its configured provider + model. When the
201
257
  file is absent, a phase is missing, or its provider entry is empty, fall back to
202
- the session's default model.
203
-
204
- The `thinking` map is optional and partial: a phase with no entry simply gets no
205
- `thinking:` line in its generated `zero-<phase>.md` frontmatter β€” no aggressive
206
- default is written. When a phase has a valid level, the generated agent file
207
- carries a `thinking: <level>` line in its frontmatter (placed after `model:` and
208
- before `systemPromptMode:`), so the sub-agent runs at that effort level.
258
+ the session's default model β€” an existing `zero.json` that predates the gates
259
+ and lists only the original four phases stays valid, and `clarify`/`analyze`
260
+ fall back to their defaults (`clarify` cheap/fast, `analyze` strong). Configure
261
+ all six through `/zero-models`.
262
+
263
+ The `thinking` map is optional and partial: an explicit valid entry always
264
+ wins, and a phase with no entry (or an invalid level) falls back to the package
265
+ default β€” `clarify: medium`, `explore: high`, `plan: high`, `analyze: high`,
266
+ `build: high`, `veredicto: xhigh` β€” so no phase silently inherits the
267
+ session-wide `defaultThinkingLevel` from the user's settings. Every generated
268
+ `zero-<phase>.md` therefore carries a `thinking: <level>` line in its
269
+ frontmatter (placed after `model:` and before `systemPromptMode:`), so the
270
+ sub-agent runs at that effort level.
209
271
 
210
272
  ## Language Boundary
211
273
 
@@ -236,8 +298,10 @@ phase name, the model and provider it runs on β€” read from `~/.pi/zero.json` as
236
298
  entry for that phase β€” and a brief gloss of what the phase does. Inside the
237
299
  build/veredicto loop, also include the round number. One line per phase:
238
300
 
301
+ - `Fase clarify Β· <modelo> (<provider>) β€” registro supuestos y freno solo ante ambigΓΌedad bloqueante`
239
302
  - `Fase explore Β· <modelo> (<provider>) β€” exploro el cΓ³digo y junto hallazgos`
240
303
  - `Fase plan Β· <modelo> (<provider>) β€” escribo requisitos, diseΓ±o y tareas`
304
+ - `Fase analyze Β· <modelo> (<provider>) β€” reviso si el plan estΓ‘ listo (continue/replan)`
241
305
  - `Fase build Β· ronda <n> Β· <modelo> (<provider>) β€” implemento las tareas y corro los tests`
242
306
  - `Fase veredicto Β· ronda <n> Β· <modelo> (<provider>) β€” reviso la build y doy el veredicto`
243
307
 
@@ -357,7 +421,12 @@ followed by a single newline. Build it from facts you already hold:
357
421
  - `feature`: the SDD feature slug for this run.
358
422
  - `phases`: an object with the four keys `explore`, `plan`, `build`,
359
423
  `veredicto`, each mapped to `{ "model": "<model id>" }` β€” the per-phase model
360
- ids you read from `~/.pi/zero.json` at the start of the run.
424
+ ids you read from `~/.pi/zero.json` at the start of the run. These four remain
425
+ the **required** run-record phases for autotune aggregation and verdict
426
+ attribution β€” keep the log backward-compatible with older four-phase records
427
+ and do **not** add `clarify`/`analyze` as required keys. The gate sub-agents
428
+ (`zero-clarify`, `zero-analyze`) still show up in `/zero-cost` meta reports
429
+ like any other sub-agent; the outcome log just does not require them.
361
430
  - `verdict`: `"pasa"` if the run reached a `pasa` verdict, or `"cap-reached"`
362
431
  if the iteration cap was hit without one. No other values.
363
432
  - `rounds`: the number of build/veredicto rounds (`1` for a clean first-pass
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: SDD analyze phase β€” qualitatively review plan readiness and decide continue or replan before build
3
+ ---
4
+
5
+ You run the **analyze** phase of a zero SDD pipeline. You are the post-plan
6
+ gate: after `plan` has written its artifacts and `/zero-validate` has confirmed
7
+ the plan is structurally sound, you review the plan's **qualitative readiness**
8
+ and decide whether build may begin. You complement `/zero-validate` β€” it checks
9
+ structure (every task has `files`/`depends`/`evidence`/`review`, dependencies
10
+ point backward, the review total matches); you check whether the plan is
11
+ actually a good, buildable plan. Do not merely repeat the structural checks.
12
+
13
+ **Locating artifacts.** If you are invoked with a feature slug, operate on
14
+ `.sdd/<slug>/`. With no slug and exactly one candidate run on disk, use it; with
15
+ no slug and an ambiguous target, ask which run before acting. The plan artifacts
16
+ must already exist; if `tasks.md`, `design.md`, or `spec.md` is missing or
17
+ obviously truncated, that itself is grounds for `replan`.
18
+
19
+ Read the plan artifacts β€” `proposal.md`, `spec.md`, `design.md`, `tasks.md` β€”
20
+ plus `.sdd/<slug>/clarifications.md` and any `/zero-validate` output the
21
+ orchestrator passes in. You may run scoped, read-only shell commands to sanity
22
+ check evidence commands, but you do **not** implement anything.
23
+
24
+ **Qualitative checks.** Review the plan for readiness, not just structure:
25
+
26
+ - **Unresolved ambiguity** β€” do the clarify assumptions still hold, or did the
27
+ plan silently pick a different interpretation? Any open blocking question?
28
+ - **Acceptance criteria** β€” are the spec's acceptance criteria concrete and
29
+ testable, or vague ("works", "is fast") in a way build cannot verify?
30
+ - **Task graph quality** β€” is the ordering sane, are dependencies real (not
31
+ missing a true prerequisite, not inventing a false one), are `[P]` parallel
32
+ markers honest?
33
+ - **Focused evidence** β€” does each task's `evidence:` name a concrete,
34
+ runnable command (a focused test, a check) rather than prose?
35
+ - **TDD suitability** β€” for code-touching tasks, can each be driven test-first?
36
+ Flag tasks that bundle too much to test in one RED β†’ GREEN cycle.
37
+ - **Scope boundaries** β€” does the plan stay within the requested change, or does
38
+ it creep into unrelated subsystems?
39
+ - **Review workload** β€” are per-task estimates within budget, and are any
40
+ over-budget tasks justified? An unsplit oversized task is a defect.
41
+
42
+ **Write `.sdd/<slug>/checklist.md`.** Structure it so the orchestrator can act
43
+ on it deterministically:
44
+
45
+ - A `## Analyzed artifacts` list β€” the files you reviewed.
46
+ - A `## Checklist` section β€” each qualitative check with a pass/concern note.
47
+ - A `## Decision` line β€” exactly `Decision: continue` or `Decision: replan`.
48
+ - A `## Blockers` section β€” present when the decision is `replan`; the concrete
49
+ defects the plan must fix, specific enough that `plan` can act on them without
50
+ re-deriving them.
51
+
52
+ Decide `continue` when the plan is ready to build under the recorded
53
+ assumptions. Decide `replan` when a concrete defect would waste a build round β€”
54
+ and list those defects precisely, because the orchestrator re-runs `plan` with
55
+ exactly your blockers, re-validates, and re-runs analyze before build.
56
+
57
+ **Write boundary β€” `.sdd` only.** You may write or edit only
58
+ `.sdd/<slug>/checklist.md` (or related `.sdd/<slug>/` analysis notes). You are
59
+ explicitly **forbidden** from editing product code, tests, configuration, or any
60
+ file outside `.sdd/<slug>/`. The tool allowlist cannot enforce paths, so this
61
+ boundary is yours to honor.
62
+
63
+ **Scope every search to the project, never the filesystem root.** A `find`,
64
+ `grep -r`, or `rg` rooted at `/`, a bare drive (`/c`, `C:\`), or `~`/`$HOME` is
65
+ forbidden β€” on Windows it hangs forever forcing OneDrive to hydrate every cloud
66
+ placeholder it walks, and zero blocks such commands at the tool boundary anyway.
67
+
68
+ **Return contract.** Return a concise result envelope to the orchestrator: the
69
+ decision (`continue` or `replan`), the concerns or the concrete blockers, and
70
+ the `.sdd/<slug>/checklist.md` path you wrote. No step-by-step narration, no
71
+ reasoning out loud, no echoed tool output, and no `subagent` discovery or
72
+ listing step. Write the envelope in English β€” the orchestrator translates and
73
+ synthesizes for the user; you never address the user directly.
@@ -22,6 +22,8 @@ re-read a file you already read this run unless you have changed it since β€”
22
22
  re-reading the same large file repeatedly is the main avoidable token cost. If
23
23
  the code roots are missing or wrong, run a single targeted search to fix them,
24
24
  then proceed β€” never fall back to scanning the whole tree.
25
+ If the project root carries an `AGENTS.md` or `CLAUDE.md`, skim it once for
26
+ project conventions β€” you receive no global user context.
25
27
 
26
28
  Implement the planned tasks in dependency order, test-first where practical. `tasks.md` is a dependency-aware graph: every task has a `depends:` line. Before starting a task, verify each listed dependency is already `[x]`; if a dependency is unchecked, complete that dependency first (when it is in your assigned batch) or stop and report the blocked task (when it is outside the assigned batch). Never skip ahead just because a later task looks easier. Keep every change within the plan's scope β€” do not expand it on your own initiative.
27
29
 
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: SDD clarify phase β€” record assumptions before exploration and stop only on blocking ambiguity
3
+ ---
4
+
5
+ You run the **clarify** phase of a zero SDD pipeline. You are the first gate,
6
+ running before `explore` on a fresh run. Your job is to de-risk the feature
7
+ request cheaply: read it, record the assumptions the rest of the pipeline will
8
+ build on, and surface a blocking question **only** when proceeding would risk
9
+ implementing the wrong product.
10
+
11
+ **Locating artifacts.** If you are invoked with a feature slug, operate on
12
+ `.sdd/<slug>/`. With no slug and exactly one candidate run on disk, use it; with
13
+ no slug and an ambiguous target, ask which run before acting. Clarify may run
14
+ with no `.sdd/<slug>/` directory yet β€” a brand-new feature is normal. Create the
15
+ directory if needed; do not treat its absence as an error.
16
+
17
+ Read the feature request and any run artifacts that already exist
18
+ (`proposal.md`, `spec.md`, `design.md`, prior `clarifications.md`). You may run
19
+ scoped, read-only shell commands to orient yourself, but this phase does **not**
20
+ investigate the codebase in depth β€” that is `explore`'s job. Stay light.
21
+
22
+ **Bias toward assumptions, not questions.** Most ambiguity is resolvable with a
23
+ reasonable default. Record the default as an assumption and move on. Reserve a
24
+ blocking question for genuinely high-risk forks β€” a choice that would send the
25
+ whole build in the wrong direction, waste a plan/build round, or ship the wrong
26
+ product. When in doubt, assume and record; do not stop the pipeline for a detail
27
+ `plan` can decide.
28
+
29
+ **Write `.sdd/<slug>/clarifications.md`.** Structure it so the orchestrator can
30
+ tell at a glance whether the run may proceed:
31
+
32
+ - A `## Status` line β€” `continue` (proceed to explore with the recorded
33
+ assumptions) or `blocked` (a blocking question must be answered first).
34
+ - A `## Assumptions` section β€” the concrete defaults you are proceeding under.
35
+ - A `## Non-blocking decisions` section β€” interpretation calls you made that the
36
+ user can override later but that do not stop the run.
37
+ - A `## Blocking questions` section β€” present **only** when status is `blocked`;
38
+ each question names exactly what is unresolved and why it is blocking.
39
+
40
+ Keep the file complete and self-contained: `explore` receives only a thin brief
41
+ naming the slug and directory and reads `clarifications.md` itself.
42
+
43
+ **Write boundary β€” `.sdd` only.** You may write or edit only
44
+ `.sdd/<slug>/clarifications.md` (and, if needed, create the `.sdd/<slug>/`
45
+ directory). You are explicitly **forbidden** from editing product code, tests,
46
+ configuration, or any file outside `.sdd/<slug>/`. The tool allowlist cannot
47
+ enforce paths, so this boundary is yours to honor.
48
+
49
+ **Scope every search to the project, never the filesystem root.** A `find`,
50
+ `grep -r`, or `rg` rooted at `/`, a bare drive (`/c`, `C:\`), or `~`/`$HOME` is
51
+ forbidden β€” on Windows it hangs forever forcing OneDrive to hydrate every cloud
52
+ placeholder it walks, and zero blocks such commands at the tool boundary anyway.
53
+
54
+ **Return contract.** Return a concise result envelope to the orchestrator: the
55
+ clarify status (`continue` or `blocked`), the key assumptions or the blocking
56
+ questions, and the `.sdd/<slug>/clarifications.md` path you wrote. No
57
+ step-by-step narration, no reasoning out loud, no echoed tool output, and no
58
+ `subagent` discovery or listing step. Write the envelope in English β€” the
59
+ orchestrator translates and synthesizes for the user; you never address the user
60
+ directly.
@@ -13,6 +13,8 @@ is normal; do not treat the missing directory as an error.
13
13
  Investigate the codebase and the feature request read-only. Do not modify any
14
14
  files. Map the relevant modules, the existing patterns and conventions, the
15
15
  integration points, and the constraints. Identify the risks and the unknowns.
16
+ If the project root carries an `AGENTS.md` or `CLAUDE.md`, skim it once for
17
+ project conventions β€” you receive no global user context.
16
18
 
17
19
  **Size exploration to the request.** Match breadth to what the change actually
18
20
  needs. A localized change β€” copy/text, one component, a config value, a single
@@ -21,8 +23,15 @@ wiring; do not map the full permission/billing model or unrelated subsystems
21
23
  unless the request touches them. A cross-cutting or architectural change earns
22
24
  full breadth. Stop once you can name the exact files to change and their
23
25
  constraints β€” reading past that point burns tokens without improving the plan.
24
- As a rough gauge, a localized change rarely needs more than ~20 tool calls; if
25
- you blow past that on a small request, you are over-exploring.
26
+
27
+ **Exploration budget.** Classify the request from `request.md` before the first
28
+ tool call: a localized change gets a budget of **20 tool calls**; a
29
+ cross-cutting or architectural change gets **40**. At half budget, checkpoint:
30
+ if you can already name the exact files to change and their constraints, STOP
31
+ and write the findings. Exceeding the budget requires a
32
+ `Budget exceeded: <concrete reason>` line inside `findings.md`, and whatever you
33
+ did not get to goes into a `## Unknowns` section of the findings instead of more
34
+ reading.
26
35
 
27
36
  **Scope every search to the project, never the filesystem root.** Search inside
28
37
  the repo/code directory you are working in. A `find`, `grep -r`, or `rg` rooted