@@ -9,8 +9,8 @@ description: |
99 branch does". Produces a structured markdown spec covering problem statement, product requirements,
1010 architecture, technical design, file inventories, testing strategy, rollout plan, and risks.
1111author : Codex
12- version : 1.0 .0
13- date : 2026-02-15
12+ version : 1.1 .0
13+ date : 2026-02-16
1414tags : [documentation, git, branch-analysis, spec, reverse-engineering]
1515---
1616
@@ -46,8 +46,16 @@ git diff --stat <base>...HEAD
4646
4747# 3. Count the scale
4848git diff --stat < base> ...HEAD | tail -1
49+
50+ # 4. Estimate diff token budget (chars / 4 ≈ tokens)
51+ git diff < base> ...HEAD | wc -c
4952```
5053
54+ ** Agent scaling by token budget:**
55+ - ** <50k tokens** → single agent (read all diffs directly)
56+ - ** 50k–200k tokens** → 2–3 agents
57+ - ** 200k+ tokens** → 3–4 agents, max ~ 150k tokens per agent
58+
5159From the diff stats, categorize files into groups:
5260- ** Core implementation** (new modules, business logic)
5361- ** Integration points** (modified selectors, reducers, hooks, components)
@@ -60,6 +68,11 @@ From the diff stats, categorize files into groups:
6068Launch 2-4 parallel exploration agents, each focused on a different file group. This is
6169critical for efficiency — reading 50+ files sequentially is too slow.
6270
71+ ** Model allocation:** Use ` subagent_type: "Explore" ` with ` model: "sonnet" ` for all
72+ exploration agents. Sonnet handles file reading and analysis (best cost/capability ratio).
73+ The orchestrating model (Opus) plans assignments, synthesizes reports, and infers product
74+ motivation — it should never read diff files directly.
75+
6376** Agent 1: Core Implementation**
6477- All new files (the heart of the feature)
6578- Focus on: purpose, key types, exported functions, data flow, inter-module connections
@@ -87,8 +100,8 @@ Each agent prompt should ask for:
87100After agents return, diff the analyzed files against the full file list:
88101
89102``` bash
90- # List all non-test changed files
91- git diff --stat < base> ...HEAD -- ' *.ts ' ' *.tsx ' | awk ' {print $1} ' | sort
103+ # List all changed files (language-agnostic)
104+ git diff --name-only < base> ...HEAD | sort
92105
93106# Show small diffs for any files not yet analyzed
94107git diff < base> ...HEAD -- < uncovered-files>
@@ -128,10 +141,12 @@ What is and isn't included.
128141
129142## 4. Architecture
130143### 4.1 System Diagram
131- ASCII diagram showing component relationships and data flow.
144+ Mermaid ` graph TB ` diagram showing component relationships and data flow.
145+ (Mermaid renders natively on GitHub/GitLab — prefer over ASCII.)
132146
133147### 4.2 Data Lifecycle
134- Step-by-step flow from initial state through steady state.
148+ Mermaid ` sequenceDiagram ` or step-by-step description showing flow
149+ from initial state through steady state.
135150
136151## 5. Technical Design
137152Subsections for each major design decision:
0 commit comments