deepflow 0.1.87 → 0.1.89

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.
@@ -6,225 +6,70 @@ allowed-tools: [Read, Write, Bash]
6
6
 
7
7
  # /df:report — Session Cost Report
8
8
 
9
+ > **DEPRECATED:** Use `/df:dashboard` instead to view deepflow metrics and status.
10
+
9
11
  ## Orchestrator Role
10
12
 
11
- You aggregate token usage data from multiple sources and produce a structured report.
13
+ Aggregate token usage data and produce a structured report.
12
14
 
13
- **NEVER:** Spawn agents, use Task tool, use AskUserQuestion, run git, use EnterPlanMode, use ExitPlanMode
15
+ **NEVER:** Spawn agents, use Task tool, use AskUserQuestion, run git, EnterPlanMode, ExitPlanMode
14
16
 
15
17
  **ONLY:** Read data files, compute aggregates, write `.deepflow/report.json` and `.deepflow/report.md`
16
18
 
17
- ---
18
-
19
- ## Purpose
20
-
21
- Produce a cost and context report for the current session. Reads token-history.jsonl, quota-history.jsonl, per-task YAML result files, and auto-memory.yaml. Outputs a machine-readable JSON report and a human-readable Markdown summary.
22
-
23
- ## Usage
24
-
25
- ```
26
- /df:report
27
- ```
28
-
29
- No arguments. Operates on `.deepflow/` data written by the statusline hook, execute command, and quota logger.
30
-
31
- ---
32
-
33
19
  ## Behavior
34
20
 
35
21
  ### 1. LOAD DATA SOURCES
36
22
 
37
- Read each source gracefully — if a file does not exist, treat it as empty and continue.
38
-
39
- **a. Token history** — `.deepflow/token-history.jsonl`
40
-
41
- Parse each newline-delimited JSON object. Each line has fields:
42
- `timestamp`, `input_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens`, `context_window_size`, `used_percentage`, `model`, `session_id`
43
-
44
- Shell injection (use output directly):
45
- - `` !`cat .deepflow/token-history.jsonl 2>/dev/null || echo ''` ``
46
-
47
- Aggregate across all lines:
48
- - `total_input_tokens` = sum of `input_tokens`
49
- - `total_cache_creation` = sum of `cache_creation_input_tokens`
50
- - `total_cache_read` = sum of `cache_read_input_tokens`
51
- - `cache_hit_ratio` = `total_cache_read / (total_input_tokens + total_cache_creation + total_cache_read)` — clamp to `[0, 1]`, default `0` if denominator is 0
52
- - `peak_context_percentage` = max of `used_percentage` across all lines
53
- - `model` = value from the most recent line (last line)
54
-
55
- **b. Quota history** — `~/.claude/quota-history.jsonl`
56
-
57
- Parse the last 5 lines. Each line has `timestamp`, `event`, and API response payload fields.
58
-
59
- Shell injection:
60
- - `` !`tail -5 ~/.claude/quota-history.jsonl 2>/dev/null || echo ''` ``
61
-
62
- Extract the most recent quota entry. If the file does not exist or is empty, set `quota.available = false`.
63
-
64
- **c. Per-task results** — `.deepflow/results/T*.yaml`
65
-
66
- Shell injection:
67
- - `` !`ls .deepflow/results/T*.yaml 2>/dev/null || echo ''` ``
68
-
69
- For each YAML file found, read and extract the `tokens` block:
70
- ```yaml
71
- tokens:
72
- start_percentage: N
73
- end_percentage: N
74
- delta_percentage: N
75
- input_tokens: N
76
- cache_creation_input_tokens: N
77
- cache_read_input_tokens: N
78
- ```
79
-
80
- Derive `task_id` from the filename (e.g., `T3.yaml` → `"T3"`).
81
-
82
- If a file has no `tokens` block, skip it without error.
83
-
84
- **d. Session metadata** — `.deepflow/auto-memory.yaml`
85
-
86
- Shell injection:
87
- - `` !`cat .deepflow/auto-memory.yaml 2>/dev/null || echo ''` ``
23
+ Read each source gracefully — missing files yield zero/empty values, never error out.
88
24
 
89
- Read for context (session_id, start time, etc.) if available. Optional — do not fail if absent.
25
+ | Source | Path | Shell injection | Key fields |
26
+ |--------|------|-----------------|------------|
27
+ | Token history | `.deepflow/token-history.jsonl` | `` !`cat .deepflow/token-history.jsonl 2>/dev/null \|\| echo ''` `` | `timestamp`, `input_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens`, `used_percentage`, `model`, `session_id` |
28
+ | Quota history | `~/.claude/quota-history.jsonl` | `` !`tail -5 ~/.claude/quota-history.jsonl 2>/dev/null \|\| echo ''` `` | `timestamp`, `event`, API payload |
29
+ | Task results | `.deepflow/results/T*.yaml` | `` !`ls .deepflow/results/T*.yaml 2>/dev/null \|\| echo ''` `` | `tokens` block: `start_percentage`, `end_percentage`, `delta_percentage`, `input_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens` |
30
+ | Session metadata | `.deepflow/auto-memory.yaml` | `` !`cat .deepflow/auto-memory.yaml 2>/dev/null \|\| echo ''` `` | session_id, start time (optional) |
90
31
 
91
32
  ### 2. COMPUTE AGGREGATES
92
33
 
93
- Using data from step 1:
94
-
95
34
  ```
96
- total_tokens_all = total_input_tokens + total_cache_creation + total_cache_read
97
- cache_hit_ratio = total_cache_read / total_tokens_all (0 if total_tokens_all == 0)
35
+ total_input_tokens = sum(input_tokens)
36
+ total_cache_creation = sum(cache_creation_input_tokens)
37
+ total_cache_read = sum(cache_read_input_tokens)
38
+ total_tokens_all = total_input_tokens + total_cache_creation + total_cache_read
39
+ cache_hit_ratio = total_cache_read / total_tokens_all (0 if denominator=0, clamp [0,1], round 4 decimals)
40
+ peak_context_percentage = max(used_percentage)
41
+ model = most recent line's model
98
42
  ```
99
43
 
100
- Round `cache_hit_ratio` to 4 decimal places.
101
-
102
44
  ### 3. WRITE `.deepflow/report.json`
103
45
 
104
- Generate an ISO 8601 timestamp for the `generated` field (current time).
105
-
106
- Schema:
107
- ```json
108
- {
109
- "version": 1,
110
- "generated": "2026-03-17T12:00:00Z",
111
- "session_summary": {
112
- "total_input_tokens": 0,
113
- "total_cache_creation": 0,
114
- "total_cache_read": 0,
115
- "cache_hit_ratio": 0.0,
116
- "peak_context_percentage": 0,
117
- "model": "claude-sonnet-4-5"
118
- },
119
- "tasks": [
120
- {
121
- "task_id": "T1",
122
- "start_percentage": 0,
123
- "end_percentage": 0,
124
- "delta_percentage": 0,
125
- "input_tokens": 0,
126
- "cache_creation": 0,
127
- "cache_read": 0
128
- }
129
- ],
130
- "quota": {
131
- "available": false
132
- }
133
- }
134
- ```
46
+ Structure: `{ version: 1, generated: ISO-8601-UTC, session_summary: {total_input_tokens, total_cache_creation, total_cache_read, cache_hit_ratio, peak_context_percentage, model}, tasks: [{task_id, start_percentage, end_percentage, delta_percentage, input_tokens, cache_creation, cache_read}], quota: {available: bool, ...API fields if available} }`
135
47
 
136
- Rules:
137
- - `version` is always `1`
138
- - `tasks` is an empty array `[]` if no task result files were found or none had a `tokens` block
139
- - `quota.available` is `false` if quota data is missing or could not be read; `true` with additional fields from the API payload if data was found
140
- - All token fields are integers >= 0
141
- - `cache_hit_ratio` is a float in `[0, 1]`
48
+ Rules: `version` always 1. `tasks` = `[]` if no results found. `quota.available` = false if missing. All token fields integers >= 0. `cache_hit_ratio` float in [0,1].
142
49
 
143
50
  ### 4. WRITE `.deepflow/report.md`
144
51
 
145
- Generate a human-readable Markdown report. Use actual values from step 2.
146
-
147
- Required section headings (exact text):
148
-
149
- ```markdown
150
- ## Session Summary
151
-
152
- | Metric | Value |
153
- |--------|-------|
154
- | Model | {model} |
155
- | Total Input Tokens | {total_input_tokens} |
156
- | Cache Creation Tokens | {total_cache_creation} |
157
- | Cache Read Tokens | {total_cache_read} |
158
- | Cache Hit Ratio | {cache_hit_ratio} ({percentage}%) |
159
- | Peak Context Usage | {peak_context_percentage}% |
160
-
161
- ## Per-Task Costs
52
+ Required sections with exact headings:
162
53
 
163
- | Task | Start % | End % | Delta % | Input Tokens | Cache Creation | Cache Read |
164
- |------|---------|-------|---------|-------------|----------------|------------|
165
- | T1 | 0 | 5 | 5 | 12000 | 3000 | 1000 |
54
+ **## Session Summary** Table: Model, Total Input Tokens, Cache Creation Tokens, Cache Read Tokens, Cache Hit Ratio (with %), Peak Context Usage %.
166
55
 
167
- _(No task data available)_ if tasks array is empty
56
+ **## Per-Task Costs** — Table: Task, Start %, End %, Delta %, Input Tokens, Cache Creation, Cache Read. Show `_(No task data available)_` if empty.
168
57
 
169
- ## Quota Impact
170
-
171
- {quota data table or "Not available (non-macOS or no token)"}
172
- ```
173
-
174
- For **Quota Impact**:
175
- - If `quota.available = true`: render a table with the quota fields from the API payload
176
- - If `quota.available = false`: write exactly `Not available (non-macOS or no token)`
58
+ **## Quota Impact** — Quota fields table if `quota.available=true`, else exactly: `Not available (non-macOS or no token)`.
177
59
 
178
60
  ### 5. CONFIRM
179
61
 
180
- Report to the user:
181
-
182
62
  ```
183
63
  Report generated:
184
64
  .deepflow/report.json — machine-readable (version=1)
185
65
  .deepflow/report.md — human-readable summary
186
66
  ```
187
67
 
188
- If any data source was missing, list them as a note:
189
- ```
190
- Note: Missing data sources: token-history.jsonl, quota-history.jsonl
191
- ```
192
-
193
- ---
68
+ List missing data sources as a note if any were absent.
194
69
 
195
70
  ## Rules
196
71
 
197
- - **Graceful degradation**any missing file yields zero/empty values for that source; never error out
198
- - **No hallucination** — only write values derived from actual file contents; use 0 for missing numeric fields
199
- - **Idempotent** — re-running overwrites `.deepflow/report.json` and `.deepflow/report.md` with fresh data
200
- - **cache_hit_ratio always in [0,1]** clamp if arithmetic produces out-of-range value
201
- - **ISO 8601 timestamps** — `generated` field uses UTC
202
-
203
- ---
204
-
205
- ## Example
206
-
207
- ```
208
- USER: /df:report
209
-
210
- CLAUDE: [Reads .deepflow/token-history.jsonl — 42 lines found]
211
- [Reads ~/.claude/quota-history.jsonl — last 5 lines found]
212
- [Reads .deepflow/results/T1.yaml, T2.yaml, T3.yaml — tokens blocks extracted]
213
- [Reads .deepflow/auto-memory.yaml — session metadata found]
214
-
215
- [Computes:
216
- total_input_tokens = 185000
217
- total_cache_creation = 45000
218
- total_cache_read = 320000
219
- cache_hit_ratio = 320000 / (185000 + 45000 + 320000) = 0.5818
220
- peak_context_percentage = 73
221
- model = claude-sonnet-4-5
222
- ]
223
-
224
- [Writes .deepflow/report.json]
225
- [Writes .deepflow/report.md]
226
-
227
- Report generated:
228
- .deepflow/report.json — machine-readable (version=1)
229
- .deepflow/report.md — human-readable summary
230
- ```
72
+ - Graceful degradation — missing files yield zero/empty, never error
73
+ - No hallucination — only values from actual file contents; 0 for missing fields
74
+ - Idempotent — re-running overwrites both files with fresh data
75
+ - ISO 8601 UTC timestamps for `generated` field
@@ -8,123 +8,40 @@ allowed-tools: [Read, Grep, Glob, Bash]
8
8
 
9
9
  ## Orchestrator Role
10
10
 
11
- You are a context synthesizer. Your ONLY job is to read project state from multiple sources and produce a concise, structured briefing so developers can resume work after a break.
11
+ Read project state from multiple sources, produce a concise briefing for resuming work. Pure read-only.
12
12
 
13
- **NEVER:** Write files, create files, modify files, append to files, run git with write operations, use AskUserQuestion, spawn agents, use TaskOutput, use EnterPlanMode, use ExitPlanMode
13
+ **NEVER:** Write/create/modify files, run git write ops, use AskUserQuestion, spawn agents, use TaskOutput, EnterPlanMode, ExitPlanMode
14
14
 
15
- **ONLY:** Read files (Bash read-only git commands, Read tool, Glob, Grep), write briefing to stdout
16
-
17
- ---
18
-
19
- ## Purpose
20
-
21
- Synthesize project state into a 200-500 word briefing covering what happened, what decisions are live, and what to do next. Pure read-only — writes nothing.
22
-
23
- ## Usage
24
-
25
- ```
26
- /df:resume
27
- ```
15
+ **ONLY:** Read files (Bash read-only git commands, Read, Glob, Grep), write briefing to stdout
28
16
 
29
17
  ## Behavior
30
18
 
31
- ### 1. GATHER SOURCES
32
-
33
- Read these sources in parallel (all reads, no writes):
19
+ ### 1. GATHER SOURCES (parallel, all reads)
34
20
 
35
21
  | Source | Command/Path | Purpose |
36
22
  |--------|-------------|---------|
37
- | Git timeline | `!`git log --oneline -20`` | What changed and when |
38
- | Decisions | `!`cat .deepflow/decisions.md 2>/dev/null \|\| echo 'NOT_FOUND'`` | Current [APPROACH], [PROVISIONAL], [ASSUMPTION] entries |
39
- | Plan | `!`cat PLAN.md 2>/dev/null \|\| echo 'NOT_FOUND'`` | Task status (checked vs unchecked) |
40
- | Spec headers | `!`head -20 specs/doing-*.md 2>/dev/null \|\| echo 'NOT_FOUND'`` | What features are in-flight |
41
- | Experiments | `!`ls .deepflow/experiments/ 2>/dev/null \|\| echo 'NOT_FOUND'`` | Validated and failed approaches |
42
-
43
- **Token budget:** Read only what's needed — ~2500 tokens total across all sources.
44
-
45
- If a source does not exist, skip it silently (do not error or warn).
46
-
47
- ### 2. SYNTHESIZE BRIEFING
48
-
49
- Produce a 200-500 word briefing with exactly three sections:
50
-
51
- ---
52
-
53
- **## Timeline**
54
-
55
- Summarize what happened and when, derived from `git log --oneline -20` and spec/PLAN.md state. Describe the arc of work: what was completed, what is in-flight, notable milestones. Reference dates or commit messages where informative. Aim for 3-6 sentences.
56
-
57
- **## Live Decisions**
23
+ | Git timeline | `` !`git log --oneline -20` `` | What changed and when |
24
+ | Decisions | `` !`cat .deepflow/decisions.md 2>/dev/null \|\| echo 'NOT_FOUND'` `` | Live [APPROACH], [PROVISIONAL], [ASSUMPTION] entries |
25
+ | Plan | `` !`cat PLAN.md 2>/dev/null \|\| echo 'NOT_FOUND'` `` | Task status (checked vs unchecked) |
26
+ | Spec headers | `` !`head -20 specs/doing-*.md 2>/dev/null \|\| echo 'NOT_FOUND'` `` | In-flight features |
27
+ | Experiments | `` !`ls .deepflow/experiments/ 2>/dev/null \|\| echo 'NOT_FOUND'` `` | Validated/failed approaches |
58
28
 
59
- List all current `[APPROACH]`, `[PROVISIONAL]`, and `[ASSUMPTION]` entries from `.deepflow/decisions.md`. Present each as a bullet with its tag, the decision text, and a brief rationale if available.
29
+ Token budget: ~2500 tokens input. Skip missing sources silently.
60
30
 
61
- If `.deepflow/decisions.md` does not exist or is empty: state "No decisions recorded yet."
31
+ ### 2. SYNTHESIZE BRIEFING (200-500 words, 3 sections)
62
32
 
63
- Do not filter or editorialize report all live decision entries as found. If a decision has been contradicted (a newer entry supersedes it), show only the newest entry for that topic.
33
+ **## Timeline**3-6 sentences: arc of work from git log + spec/PLAN state. What completed, in-flight, notable milestones. Reference dates/commits where informative.
64
34
 
65
- **## Next Steps**
35
+ **## Live Decisions** — All `[APPROACH]`, `[PROVISIONAL]`, `[ASSUMPTION]` from `.deepflow/decisions.md` as bullets with tag + text + rationale. Show newest entry per topic if contradictions exist. State "No decisions recorded yet." if absent/empty.
66
36
 
67
- Derive next steps from `PLAN.md` task status:
68
- - List unchecked tasks (`- [ ]`) that are not blocked
69
- - Note blocked tasks and what they are blocked by
70
- - If no PLAN.md exists: suggest running `/df:plan` to generate tasks
71
-
72
- Prioritize: unblocked tasks first, then blocked tasks with their blockers, then any tasks with no explicit status.
73
-
74
- ---
37
+ **## Next Steps** From PLAN.md: unblocked `- [ ]` tasks first, then blocked tasks with blockers. If no PLAN.md: suggest `/df:plan`.
75
38
 
76
39
  ### 3. OUTPUT
77
40
 
78
- Print the briefing directly to stdout. No file writes. No file creation.
79
-
80
- Format:
81
-
82
- ```
83
- ## Timeline
84
- [3-6 sentences on what happened]
85
-
86
- ## Live Decisions
87
- - [APPROACH] ...
88
- - [PROVISIONAL] ...
89
- - [ASSUMPTION] ...
90
-
91
- ## Next Steps
92
- - T1: ... (ready)
93
- - T2: ... (blocked by T1)
94
- ```
95
-
96
- Word count target: 200-500 words. Do not pad. Do not truncate important information to hit limits.
97
-
98
- ---
41
+ Print briefing to stdout. No file writes.
99
42
 
100
43
  ## Rules
101
44
 
102
- - Read sources in a single pass — do not loop or re-read
103
- - Contradicted decisions: show newest entry per topic only
104
- - Token budget: stay within ~2500 tokens of input to produce ~500 words of output
105
-
106
- ## Example
107
-
108
- ```
109
- USER: /df:resume
110
-
111
- CLAUDE:
112
-
113
- ## Timeline
114
- Work began on the session-continuity feature on 2026-02-20, with the spec
115
- formalized after a discover and debate phase. The plan was generated with
116
- 5 tasks across two areas: decision capture in existing commands and two new
117
- commands (note, resume). Tasks T1-T3 are complete (decisions.md format,
118
- discover capture, plan capture). T4 (execute capture) and T5 (resume command)
119
- remain in progress.
120
-
121
- ## Live Decisions
122
- - [APPROACH] Store decisions in .deepflow/decisions.md as append-only markdown — chosen over database to keep diffs readable and avoid new dependencies
123
- - [PROVISIONAL] Max 4 candidates per AskUserQuestion call — matches tool limit, revisit if UX feels too chunked
124
- - [ASSUMPTION] Worktree execute writes to main tree .deepflow/ path — valid as long as main tree is always the parent
125
-
126
- ## Next Steps
127
- - T4: Add decision capture to /df:execute (ready — unblocked)
128
- - T5: Create /df:resume command (ready — unblocked)
129
- - T6: Add decision capture to /df:verify (blocked by T4)
130
- ```
45
+ - Read sources in a single pass — no re-reads
46
+ - Contradicted decisions: show newest per topic only
47
+ - Token budget: ~2500 input tokens to produce ~500 words output
@@ -7,98 +7,61 @@ description: Transform conversation context into a structured specification file
7
7
 
8
8
  ## Orchestrator Role
9
9
 
10
- You coordinate agents and ask questions. You never search code directly.
10
+ Coordinate agents and ask questions. Never search code directly.
11
11
 
12
- **NEVER:** Read source files, use Glob/Grep directly, run git, use TaskOutput, use EnterPlanMode, use ExitPlanMode
12
+ **NEVER:** Read source files, use Glob/Grep directly, run git, use TaskOutput, EnterPlanMode, ExitPlanMode
13
13
 
14
14
  **ONLY:** Spawn agents (non-background), ask user questions, write spec file
15
15
 
16
- ---
17
-
18
- ## Purpose
19
- Transform conversation context into a structured specification file.
16
+ ## Agents
20
17
 
21
- ## Usage
22
- ```
23
- /df:spec <name>
24
- ```
18
+ | Agent | subagent_type | model | Count | Purpose |
19
+ |-------|---------------|-------|-------|---------|
20
+ | Explore | `Explore` | `haiku` | 2-3 (<20 files), 5-8 (20-100), 10-15 (100+) | Find related code, patterns |
21
+ | Reasoner | `reasoner` | `opus` | 1 | Synthesize into requirements |
25
22
 
26
- ## Skills & Agents
27
- - Skill: `gap-discovery` — Proactive requirement gap identification
23
+ Skill: `gap-discovery` Proactive requirement gap identification
28
24
 
29
- **Use Task tool to spawn agents:**
30
- | Agent | subagent_type | model | Purpose |
31
- |-------|---------------|-------|---------|
32
- | Context | `Explore` | `haiku` | Codebase context gathering |
33
- | Synthesizer | `reasoner` | `opus` | Synthesize findings into requirements |
25
+ **IMPORTANT**: Always use `Task` tool with explicit `subagent_type` and `model` parameters.
34
26
 
35
27
  ## Behavior
36
28
 
37
29
  ### 1. GATHER CODEBASE CONTEXT
38
30
 
39
- **Check for debate file first:** If `specs/.debate-{name}.md` exists, read it using the Read tool. Pass its content (especially the Synthesis section) to the reasoner agent in step 3 as additional context.
40
-
41
- Follow `templates/explore-agent.md` for spawn rules, prompt structure, and scope restrictions.
42
-
43
- Find: related implementations, code patterns/conventions, integration points, existing TODOs.
44
-
45
- | Codebase Size | Agents |
46
- |---------------|--------|
47
- | <20 files | 2-3 |
48
- | 20-100 | 5-8 |
49
- | 100+ | 10-15 |
50
-
51
- ### 2. GAP CHECK
52
- Use the `gap-discovery` skill to analyze conversation + agent findings.
53
-
54
- **Required clarity:**
55
- - [ ] Core objective clear
56
- - [ ] Scope boundaries defined (what's in/out)
57
- - [ ] Key constraints identified
58
- - [ ] Success criteria stated
59
-
60
- **If gaps exist**, use the `AskUserQuestion` tool to ask structured questions:
61
-
62
- ```json
63
- {
64
- "questions": [
65
- {
66
- "question": "Clear, specific question ending with ?",
67
- "header": "Short label",
68
- "multiSelect": false,
69
- "options": [
70
- {"label": "Option 1", "description": "What this means"},
71
- {"label": "Option 2", "description": "What this means"}
72
- ]
73
- }
74
- ]
75
- }
76
- ```
31
+ Check for `specs/.debate-{name}.md` first — if exists, read it and pass Synthesis section to reasoner in step 3.
77
32
 
78
- Max 4 questions per tool call. Wait for answers before proceeding.
33
+ Follow `templates/explore-agent.md` for spawn rules, prompt structure, scope restrictions. Find: related implementations, code patterns/conventions, integration points, existing TODOs.
79
34
 
80
- ### 3. SYNTHESIZE FINDINGS
35
+ ### 2. GAP CHECK (layer-aware)
81
36
 
82
- **Use Task tool to spawn reasoner agent:**
83
- ```
84
- Task tool parameters:
85
- - subagent_type: "reasoner"
86
- - model: "opus"
87
- ```
37
+ Use `gap-discovery` skill. Gaps determine spec layer — they do NOT block spec creation.
38
+
39
+ **Clarity checklist (maps to layers):**
40
+ - Core objective clear → L0
41
+ - Requirements enumerated → L1
42
+ - Testable ACs stated → L2
43
+ - Scope boundaries + constraints + technical context → L3
44
+
45
+ **L0-L1 gaps** (no objective/requirements): Use `AskUserQuestion` tool (max 4 questions per call, wait for answers). See `gap-discovery` skill for format.
46
+
47
+ **L2-L3 gaps**: Do NOT block. Write spec at current layer — spikes will discover what's missing.
48
+
49
+ ### 3. SYNTHESIZE FINDINGS
88
50
 
89
- The reasoner will:
90
- - Analyze codebase context from Explore agents
91
- - Identify constraints from existing architecture
92
- - Suggest requirements based on patterns found
93
- - Flag potential conflicts with existing code
94
- - Verify every REQ-N has at least one corresponding Acceptance Criterion; flag any uncovered requirements
95
- - Identify and flag vague or untestable requirements before finalizing (e.g., "should be fast" without a metric)
51
+ Spawn reasoner agent (`subagent_type: "reasoner"`, `model: "opus"`). The reasoner:
52
+ - Analyzes codebase context from Explore agents
53
+ - Identifies constraints from existing architecture
54
+ - Suggests requirements based on patterns found
55
+ - Flags conflicts with existing code
56
+ - Verifies every REQ-N has a corresponding AC; flags uncovered requirements
57
+ - Flags vague/untestable requirements (e.g., "should be fast" without a metric)
96
58
 
97
59
  ### 4. GENERATE SPEC
98
60
 
99
- Once gaps covered and context gathered, run `validateSpec` on the generated content **before** writing the file.
100
- - **Hard failure:** Do NOT write the file. Show errors to the user with actionable fix suggestions and re-synthesize.
101
- - **Advisory warnings:** Write the file but display the warnings to the user after confirmation.
61
+ Run `validateSpec` on generated content **before** writing.
62
+ - **Hard failure:** Do NOT write. Show errors with fix suggestions, re-synthesize.
63
+ - **Advisory warnings:** Write file, display warnings after confirmation.
64
+ - **Layer < 2:** Expected when info incomplete. Write the spec.
102
65
 
103
66
  Create `specs/{name}.md`:
104
67
 
@@ -111,19 +74,15 @@ Create `specs/{name}.md`:
111
74
  ## Requirements
112
75
  - REQ-1: [Requirement]
113
76
  - REQ-2: [Requirement]
114
- - REQ-3: [Requirement]
115
77
 
116
78
  ## Constraints
117
- - [Constraint 1]
118
- - [Constraint 2]
79
+ - [Constraint]
119
80
 
120
81
  ## Out of Scope
121
82
  - [Explicitly excluded item]
122
83
 
123
84
  ## Acceptance Criteria
124
- - [ ] [Testable criterion 1]
125
- - [ ] [Testable criterion 2]
126
- - [ ] [Testable criterion 3]
85
+ - [ ] [Testable criterion]
127
86
 
128
87
  ## Technical Notes
129
88
  [Implementation hints from codebase analysis — patterns, integration points, constraints discovered by agents]
@@ -131,9 +90,8 @@ Create `specs/{name}.md`:
131
90
 
132
91
  ### 5. CONFIRM
133
92
 
134
- After writing:
135
93
  ```
136
- ✓ Created specs/{name}.md
94
+ ✓ Created specs/{name}.md — Layer {N} ({label})
137
95
 
138
96
  Requirements: {count}
139
97
  Acceptance criteria: {count}
@@ -141,70 +99,16 @@ Acceptance criteria: {count}
141
99
  Next: Run /df:plan to generate tasks
142
100
  ```
143
101
 
144
- ## Rules
145
- - **Orchestrator never searches** — Spawn agents for all codebase exploration
146
- - Do NOT generate spec if critical gaps remain
147
- - Ask maximum 4 questions per tool call (not overwhelming)
148
- - Requirements must be testable
149
- - Acceptance criteria must be verifiable
150
- - Include agent-discovered context in Technical Notes
151
- - Keep specs concise (<100 lines)
152
-
153
- ## Agent Scaling
154
-
155
- | Agent | subagent_type | model | Base | Purpose |
156
- |-------|---------------|-------|------|---------|
157
- | Explore | `Explore` | `haiku` | 3-5 | Find related code, patterns |
158
- | Reasoner | `reasoner` | `opus` | 1 | Synthesize into requirements |
159
-
160
- **IMPORTANT**: Always use the `Task` tool with explicit `subagent_type` and `model` parameters.
102
+ **Layer labels:** L0="problem defined", L1="requirements known", L2="verifiable", L3="fully constrained"
161
103
 
162
- ## Example
104
+ If layer < 2: `ℹ Spec is at L{N} — /df:plan will generate spikes to discover what's missing. To deepen: add {missing sections for next layer}.`
163
105
 
164
- ```
165
- USER: I want to add image upload
166
-
167
- CLAUDE: [Spawns 3 Explore agents in parallel]
168
- - "Find existing file handling patterns"
169
- - "Find API endpoint conventions"
170
- - "Find storage service implementations"
171
-
172
- [Agents return: Express multer middleware, REST conventions, no cloud storage yet]
173
-
174
- CLAUDE: [Uses AskUserQuestion tool]
175
- {
176
- "questions": [
177
- {
178
- "question": "What file types should be supported?",
179
- "header": "File types",
180
- "multiSelect": true,
181
- "options": [
182
- {"label": "JPG/PNG only", "description": "Standard formats"},
183
- {"label": "Include WebP", "description": "Modern compression"}
184
- ]
185
- },
186
- {
187
- "question": "Where should files be stored?",
188
- "header": "Storage",
189
- "multiSelect": false,
190
- "options": [
191
- {"label": "S3 (Recommended)", "description": "Scalable cloud storage"},
192
- {"label": "Local filesystem", "description": "Simple, matches current setup"}
193
- ]
194
- }
195
- ]
196
- }
197
-
198
- USER: [Selects: JPG/PNG + WebP, S3]
199
-
200
- CLAUDE: [Spawns reasoner agent]
201
- - Synthesize: multer + S3 + existing API patterns
202
-
203
- CLAUDE: ✓ Created specs/image-upload.md
204
-
205
- Requirements: 4
206
- Acceptance criteria: 5
207
- Technical notes: Express/multer pattern, REST conventions from existing API
106
+ ## Rules
208
107
 
209
- Next: Run /df:plan to generate tasks
210
- ```
108
+ - Orchestrator never searches spawn agents for all codebase exploration
109
+ - Do NOT generate spec if L0 gaps remain (no clear objective)
110
+ - L2+ gaps do NOT block spec creation
111
+ - Max 4 questions per AskUserQuestion call
112
+ - Requirements must be testable; ACs must be verifiable (when present)
113
+ - Include agent-discovered context in Technical Notes
114
+ - Keep specs concise (<100 lines)