@simplysm/sd-claude 13.0.76 → 13.0.78

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.
Files changed (28) hide show
  1. package/claude/refs/sd-code-conventions.md +11 -3
  2. package/claude/refs/sd-solid.md +11 -2
  3. package/claude/rules/sd-claude-rules.md +6 -10
  4. package/claude/sd-statusline.js +7 -7
  5. package/claude/skills/sd-api-name-review/SKILL.md +103 -17
  6. package/claude/skills/sd-brainstorm/SKILL.md +32 -47
  7. package/claude/skills/sd-check/SKILL.md +14 -16
  8. package/claude/skills/sd-commit/SKILL.md +1 -3
  9. package/claude/skills/sd-debug/SKILL.md +5 -11
  10. package/claude/skills/sd-debug/condition-based-waiting.md +5 -11
  11. package/claude/skills/sd-debug/root-cause-tracing.md +18 -33
  12. package/claude/skills/sd-explore/SKILL.md +86 -44
  13. package/claude/skills/sd-plan/SKILL.md +0 -1
  14. package/claude/skills/sd-plan-dev/SKILL.md +48 -82
  15. package/claude/skills/sd-review/SKILL.md +107 -80
  16. package/claude/skills/sd-review/api-reviewer-prompt.md +23 -43
  17. package/claude/skills/sd-review/code-reviewer-prompt.md +26 -35
  18. package/claude/skills/sd-review/convention-checker-prompt.md +23 -26
  19. package/claude/skills/sd-review/refactoring-analyzer-prompt.md +92 -0
  20. package/claude/skills/sd-skill/SKILL.md +10 -16
  21. package/claude/skills/sd-skill/writing-guide.md +7 -11
  22. package/claude/skills/sd-tdd/SKILL.md +15 -20
  23. package/claude/skills/sd-use/SKILL.md +3 -4
  24. package/claude/skills/sd-worktree/SKILL.md +58 -113
  25. package/package.json +1 -1
  26. package/claude/skills/sd-review/code-simplifier-prompt.md +0 -95
  27. package/claude/skills/sd-review/structure-analyzer-prompt.md +0 -97
  28. package/claude/skills/sd-worktree/sd-worktree.mjs +0 -152
@@ -1,76 +1,118 @@
1
1
  ---
2
2
  name: sd-explore
3
- description: "Use when the user asks to explore, analyze, trace, or understand code structure, architecture, or implementation flow. Triggers: 'explore this', 'how does this work', 'analyze this code', 'trace the flow', 'what does this package do', codebase understanding requests."
4
- model: sonnet
3
+ description: "Use when analyzing a large codebase (30+ files) that must be read comprehensively. Splits files into groups and dispatches parallel sub-agents to avoid context compaction and information loss."
5
4
  ---
6
5
 
7
6
  # sd-explore
8
7
 
9
- You are an expert code analyst. Trace implementations across codebases and save structured analysis to file.
8
+ ## Overview
10
9
 
11
- ## Target Selection
10
+ Split a large codebase into manageable groups and dispatch parallel sub-agents, each reading its assigned files and writing results to disk. The calling skill then reads result files instead of raw source — no context compaction, no information loss.
12
11
 
13
- **When invoked with `$ARGUMENTS`:**
12
+ **Core principle:** Never read 30+ files in a single agent context. Split, parallelize, write to files.
14
13
 
15
- - If path is provided **Immediately start analysis** (don't ask clarifying questions)
16
- - If path is a package directory → Trace all major features, architecture, and patterns
17
- - If path is a single file → Trace its role, dependencies, and usage
18
- - If no arguments provided → Ask the user what to explore
14
+ **Important:** This is a workflow the **orchestrator (main agent)** follows directly. Do NOT delegate the entire sd-explore workflow to a sub-agent — only the orchestrator has `Agent` tool access to dispatch parallel sub-agents. The orchestrator globs files, splits groups, and dispatches `Agent(Explore)` calls itself.
19
15
 
20
- **Analysis only no code modifications.**
16
+ ## When to Use
21
17
 
22
- ## Output Save to File
18
+ - Codebase analysis covering 30+ source files
19
+ - Called by other skills (sd-review, sd-brainstorm, sd-debug, sd-plan) that need comprehensive file reading
20
+ - Any task where reading all files sequentially would risk context compaction
23
21
 
24
- **All analysis results MUST be saved to `.tmp/explore/`.** Do NOT dump the full analysis into the conversation.
22
+ **When NOT to use:**
23
+ - < 30 files — a single agent can handle it directly
24
+ - Targeted search for a specific function/class — use Grep/Glob instead
25
25
 
26
- This prevents context loss from compaction and makes results available to subsequent skills/agents.
26
+ ## Input
27
27
 
28
- ### File Naming
28
+ The calling skill provides:
29
29
 
30
- - **Directory/package analysis:** `.tmp/explore/{package-name}.md` (e.g., `.tmp/explore/solid.md`)
31
- - **Single file analysis:** `.tmp/explore/{filename}.md` (e.g., `.tmp/explore/Dialog.md`)
32
- - **Sub-topic deep dive:** `.tmp/explore/{package-name}--{topic}.md` (e.g., `.tmp/explore/solid--form-controls.md`)
30
+ 1. **Target path** — directory to explore (e.g., `packages/solid/src`)
31
+ 2. **Name** caller identifier for output filenames (e.g., `review`, `debug`, `brainstorm`)
32
+ 3. **File patterns** glob patterns to match (default: `**/*.ts`, `**/*.tsx`; exclude `node_modules`, `dist`)
33
+ 4. **Analysis instructions** — free-form text describing what each sub-agent should do
33
34
 
34
- ### File Structure
35
+ The analysis instructions are passed verbatim to each sub-agent. They can request anything: tags, summaries, pattern searches, specific questions, etc.
35
36
 
36
- ```markdown
37
- # {Target Name} — Explore
37
+ ## Workflow
38
+
39
+ ### Step 1: Discover Files
40
+
41
+ Glob all matching files under the target path.
42
+
43
+ - **< 30 files**: Run a single `Agent(subagent_type=Explore)` with the analysis instructions. No splitting needed. Write result to `.tmp/explore/{dt}_{name}.md` (where `{dt}` is current datetime as `yyyyMMddHHmmss`).
44
+ - **>= 30 files**: Proceed to Step 2.
45
+
46
+ ### Step 2: Split Into Groups
38
47
 
39
- > Analyzed: {target path}
48
+ Split files into groups of **~30 files each**.
40
49
 
41
- ## Summary
42
- {1-3 sentence overview}
50
+ **Splitting strategy:**
43
51
 
44
- ## Architecture
45
- {Design patterns, layers, key abstractions}
52
+ 1. List all subdirectories under target
53
+ 2. Group files by subdirectory, keeping each group around 30 files
54
+ 3. If the target is mostly flat (few subdirectories), group by file proximity (alphabetical chunks)
55
+ 4. Adjacent small directories can be merged into one group
56
+ 5. A single large directory (40+ files) should be split into multiple groups
46
57
 
47
- ## Entry Points
48
- {APIs, components, commands — with file:line references}
58
+ **Goal:** Balanced groups where related files stay together.
49
59
 
50
- ## Code Flow
51
- {Step-by-step execution traces}
60
+ ### Step 3: Dispatch Parallel Agents
52
61
 
53
- ## Key Files
54
- {Essential files for understanding the target — with file:line references}
62
+ Launch one `Agent(subagent_type=Explore)` per group, **all in a single message** for true parallelism.
55
63
 
56
- ## Dependencies
57
- {Internal and external dependencies}
64
+ Each agent receives:
58
65
 
59
- ## Observations
60
- {Strengths, issues, opportunities}
61
66
  ```
67
+ You are exploring a section of a codebase. Read ALL assigned files and write your analysis to the output file.
62
68
 
63
- ### Workflow
69
+ **Assigned files:**
70
+ [list of file paths for this group]
64
71
 
65
- 1. Perform the analysis (read files, trace code, map architecture)
66
- 2. Write the full result to `.tmp/explore/{name}.md`
67
- 3. Output a **brief summary** to the conversation (3-5 lines max) with the file path
72
+ **Analysis instructions:**
73
+ [caller's free-form instructions, passed verbatim]
68
74
 
69
- **Example conversation output:**
75
+ **Output file:** .tmp/explore/{dt}_{name}-{group_index}.md
76
+
77
+ Read every assigned file. Write your complete analysis to the output file. Do NOT skip files.
70
78
  ```
71
- Analyzed `packages/solid/src/components/disclosure/` → saved to `.tmp/explore/solid--disclosure.md`
72
79
 
73
- - 4 components: Dialog, Dropdown, Collapse, Tabs
74
- - Shared pattern: portal + backdrop + animation via CSS transitions
75
- - Key file: Dialog.tsx:45 base implementation others extend
80
+ ### Step 4: Return Result Paths
81
+
82
+ After all agents complete, return the list of output file paths to the calling skill.
83
+
84
+ The calling skill reads these files to get the analysis results — the main context stays clean.
85
+
86
+ ## Output Format
87
+
88
+ Each sub-agent writes to its assigned output file. The format is determined by the caller's analysis instructions. If no specific format is requested, use:
89
+
90
+ ```markdown
91
+ # Explore: [directory names]
92
+
93
+ ## File Summaries
94
+ - `path/to/file.ts` — Brief description
95
+
96
+ ## Analysis
97
+ [Results per the caller's instructions]
76
98
  ```
99
+
100
+ ## Why Sub-Agents Matter
101
+
102
+ The value is **context isolation**, not just speed:
103
+
104
+ - **Without sub-agents**: Reading 100+ files in the main context causes compaction. Earlier file analyses get dropped, degrading quality of later analysis steps (review, planning, etc.)
105
+ - **With sub-agents**: Each sub-agent reads ~30 files in its own context, writes results to disk, and exits. The main context only reads the summary files — staying clean for subsequent work.
106
+
107
+ ## Common Mistakes
108
+
109
+ | Mistake | Fix |
110
+ |---------|-----|
111
+ | Delegating the entire workflow to a sub-agent | The orchestrator follows sd-explore directly — only it can dispatch parallel `Agent` calls |
112
+ | Reading all files in one agent | Split into groups of ~30, dispatch parallel agents |
113
+ | Not writing results to files | Each agent MUST write to its output file — this is what prevents context bloat |
114
+ | Groups too large (50+) | Keep groups around 30 files for reliable coverage |
115
+ | Groups too small (5-10) | Wastes agent overhead — merge small directories |
116
+ | Not passing analysis instructions verbatim | The caller's instructions go to each agent as-is |
117
+ | Running agents sequentially | Launch all agents in a single message for parallelism |
118
+ | Skipping Step 1 threshold check | < 30 files don't need splitting — avoid unnecessary overhead |
@@ -138,7 +138,6 @@ git commit -m "feat: add specific feature"
138
138
  ## Related Skills
139
139
 
140
140
  - **sd-brainstorm** — prerequisite: creates the design this skill plans from
141
- - **sd-explore** — for deeper codebase exploration when gathering context
142
141
  - **sd-plan-dev** — executes the plan this skill creates
143
142
 
144
143
  ## Execution Handoff
@@ -11,15 +11,11 @@ Execute plan tasks via parallel implementers with dependency-aware scheduling.
11
11
 
12
12
  ## When to Use
13
13
 
14
- ```dot
15
- digraph when_to_use {
16
- "Have implementation plan?" [shape=diamond];
17
- "sd-plan-dev" [shape=box];
18
- "Manual execution or brainstorm first" [shape=box];
19
-
20
- "Have implementation plan?" -> "sd-plan-dev" [label="yes"];
21
- "Have implementation plan?" -> "Manual execution or brainstorm first" [label="no"];
22
- }
14
+ ```mermaid
15
+ flowchart TD
16
+ A{Have implementation plan?}
17
+ A -->|yes| B[sd-plan-dev]
18
+ A -->|no| C[Manual execution or brainstorm first]
23
19
  ```
24
20
 
25
21
  ## Execution Method
@@ -41,78 +37,49 @@ Independent tasks run as **parallel Task calls in a single message**. After impl
41
37
 
42
38
  ## The Process
43
39
 
44
- ```dot
45
- digraph process {
46
- rankdir=TB;
47
-
48
- "Read plan, extract tasks, create TaskCreate" [shape=box];
49
- "Dependency analysis: identify files per task, build graph, group into batches" [shape=box];
50
-
51
- subgraph cluster_batch {
52
- label="Per Batch (independent tasks)";
53
-
54
- subgraph cluster_parallel_implementers {
55
- label="Parallel implementer Task calls (single message)";
56
- style=dashed;
57
-
58
- subgraph cluster_implementer {
59
- label="Each Implementer";
60
- "Implement the task" [shape=box];
61
- "Questions?" [shape=diamond];
62
- "Return questions to orchestrator" [shape=box];
63
- "Re-launch with answers" [shape=box];
64
- "Commit and report" [shape=box];
65
- }
66
- }
67
-
68
- subgraph cluster_review {
69
- label="Orchestrator review loop (per implementer)";
70
-
71
- subgraph cluster_parallel_reviewers {
72
- label="Parallel reviewer Task calls (single message)";
73
- style=dashed;
74
- "Task: spec reviewer" [shape=box];
75
- "Task: quality reviewer" [shape=box];
76
- }
77
-
78
- "Any issues?" [shape=diamond];
79
- "Task: implementer fix" [shape=box];
80
- "Re-review (parallel Task calls)" [shape=box];
81
- }
82
- }
83
-
84
- "More batches?" [shape=diamond];
85
- "Batch integration check (typecheck + lint)" [shape=box];
86
- "Task: final review for entire implementation" [shape=box];
87
- "Done" [shape=ellipse];
88
-
89
- "Read plan, extract tasks, create TaskCreate" -> "Dependency analysis: identify files per task, build graph, group into batches";
90
- "Dependency analysis: identify files per task, build graph, group into batches" -> "Implement the task";
91
- "Implement the task" -> "Questions?";
92
- "Questions?" -> "Return questions to orchestrator" [label="yes"];
93
- "Return questions to orchestrator" -> "Re-launch with answers";
94
- "Re-launch with answers" -> "Implement the task";
95
- "Questions?" -> "Commit and report" [label="no"];
96
- "Commit and report" -> "Task: spec reviewer";
97
- "Commit and report" -> "Task: quality reviewer";
98
- "Task: spec reviewer" -> "Any issues?";
99
- "Task: quality reviewer" -> "Any issues?";
100
- "Any issues?" -> "Task: implementer fix" [label="yes"];
101
- "Task: implementer fix" -> "Re-review (parallel Task calls)";
102
- "Re-review (parallel Task calls)" -> "Any issues?";
103
- "Any issues?" -> "Batch integration check (typecheck + lint)" [label="no"];
104
- "Batch integration check (typecheck + lint)" -> "More batches?";
105
- "More batches?" -> "Implement the task" [label="yes, next batch"];
106
- "More batches?" -> "Task: final review for entire implementation" [label="no"];
107
- "Run /simplify on all changed code" [shape=box];
108
- "Changes made?" [shape=diamond];
109
-
110
- "Task: final review for entire implementation" -> "Run /simplify on all changed code";
111
- "Run /simplify on all changed code" -> "Changes made?";
112
- "Changes made?" -> "Typecheck + lint affected packages" [label="yes"];
113
- "Typecheck + lint affected packages" -> "Done";
114
- "Changes made?" -> "Done" [label="no"];
115
- }
40
+ ```mermaid
41
+ flowchart TD
42
+ A["Read plan, extract tasks, create TaskCreate"] --> B["Dependency analysis: identify files per task, build graph, group into batches"]
43
+
44
+ subgraph BATCH["Per Batch (independent tasks)"]
45
+ subgraph PAR_IMPL["Parallel implementer Task calls (single message)"]
46
+ subgraph IMPL["Each Implementer"]
47
+ C["Implement the task"] --> D{"Questions?"}
48
+ D -->|yes| E["Return questions to orchestrator"]
49
+ E --> F["Re-launch with answers"]
50
+ F --> C
51
+ D -->|no| G["Commit and report"]
52
+ end
53
+ end
54
+
55
+ subgraph REVIEW["Orchestrator review loop (per implementer)"]
56
+ subgraph PAR_REV["Parallel reviewer Task calls (single message)"]
57
+ H["Task: spec reviewer"]
58
+ I["Task: quality reviewer"]
59
+ end
60
+ J{"Any issues?"}
61
+ K["Task: implementer fix"]
62
+ L["Re-review (parallel Task calls)"]
63
+ end
64
+ end
65
+
66
+ B --> C
67
+ G --> H
68
+ G --> I
69
+ H --> J
70
+ I --> J
71
+ J -->|yes| K
72
+ K --> L
73
+ L --> J
74
+ J -->|no| M["Batch integration check (typecheck + lint)"]
75
+ M --> N{"More batches?"}
76
+ N -->|"yes, next batch"| C
77
+ N -->|no| O["Task: final review for entire implementation"]
78
+ O --> P["Run /simplify on all changed code"]
79
+ P --> Q{"Changes made?"}
80
+ Q -->|yes| R["Typecheck + lint affected packages"]
81
+ R --> S(["Done"])
82
+ Q -->|no| S
116
83
  ```
117
84
 
118
85
  ## Dependency Analysis
@@ -323,6 +290,5 @@ After simplify completes (or is skipped), report to the user: number of tasks co
323
290
  **Related skills:**
324
291
 
325
292
  - **sd-plan** — creates the plan this skill executes
326
- - **sd-explore** — for codebase exploration when implementers need deeper context
327
293
  - **sd-tdd** — implementers follow TDD
328
294
  - **sd-worktree** — branch isolation for worktree-based workflows
@@ -7,18 +7,18 @@ description: "Use when the user explicitly requests code review, refactoring ana
7
7
 
8
8
  ## Overview
9
9
 
10
- Comprehensive code analysis combining **defect review** (correctness, safety, API, conventions) and **refactoring analysis** (structure, simplification). Dispatches up to 5 reviewer agents in parallel, verifies findings against actual code, and compiles a unified report.
10
+ Comprehensive code analysis combining **defect review** (correctness, safety, API, conventions) and **refactoring analysis** (structure, simplification). Uses **sd-explore** to minimize redundant file reads, then dispatches reviewers with pre-filtered context.
11
11
 
12
12
  **Analysis only — no code modifications.**
13
13
 
14
14
  ## Principles
15
15
 
16
- - **Breaking changes are irrelevant**: Reviewers must NOT dismiss, soften, or deprioritize findings because the suggested fix would cause a breaking change. Correctness, safety, usability, architecture, and maintainability always take priority over API stability. If something is wrong, report it — regardless of breaking change impact.
16
+ - **Breaking changes are irrelevant**: Reviewers must NOT dismiss findings because the fix would cause a breaking change.
17
17
 
18
18
  ## Usage
19
19
 
20
20
  - `/sd-review packages/solid` — full review (all perspectives)
21
- - `/sd-review packages/solid focus on bugs` — selective review based on request
21
+ - `/sd-review packages/solid focus on bugs` — selective review
22
22
  - `/sd-review packages/solid focus on refactoring` — structural analysis only
23
23
  - `/sd-review` — if no argument, ask the user for the target path
24
24
 
@@ -31,125 +31,152 @@ Comprehensive code analysis combining **defect review** (correctness, safety, AP
31
31
 
32
32
  ## Reviewer Perspectives
33
33
 
34
- | Reviewer | Prompt Template | Perspective |
35
- |----------|----------------|-------------|
36
- | **Code Reviewer** | `code-reviewer-prompt.md` | Correctness & Safety — bugs, security, logic errors, architectural defects (circular deps, boundary violations) |
37
- | **API Reviewer** | `api-reviewer-prompt.md` | Usability & DX — naming, types, consistency |
38
- | **Convention Checker** | `convention-checker-prompt.md` | Project rules — Grep-based systematic check against convention files (prohibited patterns, naming rules, export rules) |
39
- | **Code Simplifier** | `code-simplifier-prompt.md` | Simplification complexity, duplication, readability |
40
- | **Structure Analyzer** | `structure-analyzer-prompt.md` | Organization — responsibility separation, abstraction levels, module structure |
34
+ | Reviewer | Prompt Template | Tag | Perspective |
35
+ |----------|----------------|-----|-------------|
36
+ | **Code Reviewer** | `code-reviewer-prompt.md` | `[CORRECTNESS]` | Correctness & Safety |
37
+ | **API Reviewer** | `api-reviewer-prompt.md` | `[API]` | Usability & DX |
38
+ | **Convention Checker** | `convention-checker-prompt.md` | *(all files)* | Project rules — Grep-based |
39
+ | **Refactoring Analyzer** | `refactoring-analyzer-prompt.md` | `[REFACTOR]` | Structure & Simplification |
41
40
 
42
41
  ## Reviewer Selection
43
42
 
44
- By default, run **all 5 reviewers**. If the user specifies a focus in natural language, select only the relevant reviewer(s):
43
+ By default, run **all 4 reviewers**. If the user specifies a focus, select relevant reviewer(s):
45
44
 
46
45
  | User says | Run |
47
46
  |-----------|-----|
48
- | "bugs", "security", "safety", "architecture", "dependencies", "boundaries" | Code Reviewer only |
49
- | "API", "naming", "types", "DX" | API Reviewer only |
50
- | "conventions", "rules", "patterns" | Convention Checker only |
51
- | "simplify", "complexity", "duplication", "readability" | Code Simplifier only |
52
- | "structure", "responsibility", "module", "organization", "abstraction" | Structure Analyzer only |
47
+ | "bugs", "security", "safety", "architecture", "dependencies" | Code Reviewer |
48
+ | "API", "naming", "types", "DX" | API Reviewer |
49
+ | "conventions", "rules", "patterns" | Convention Checker |
50
+ | "simplify", "complexity", "duplication", "structure", "module" | Refactoring Analyzer |
53
51
  | "defects", "correctness" | Code + API + Convention |
54
- | "refactoring", "refactor", "maintainability" | Simplifier + Structure |
55
- | (no specific focus) | All 5 |
56
-
57
- Use judgment for ambiguous requests.
52
+ | "refactoring", "refactor", "maintainability" | Refactoring Analyzer |
53
+ | (no specific focus) | All 4 |
58
54
 
59
55
  ## Workflow
60
56
 
61
- ### Step 1: Dispatch Reviewers
57
+ ### Step 1: Prepare Context
58
+
59
+ Read these files:
60
+ - `CLAUDE.md` — project overview
61
+ - `.claude/rules/sd-refs-linker.md` — reference guide
62
+ - Target's `package.json` — version (v12/v13)
63
+
64
+ Based on version and target, read all applicable reference files (e.g., `sd-code-conventions.md`, `sd-solid.md`).
65
+
66
+ Keep the collected conventions in memory — they will be inlined into each reviewer's prompt in Step 3.
67
+
68
+ ### Step 2: Explore (via sd-explore)
69
+
70
+ Follow the **sd-explore** workflow to read all source files under the target.
71
+
72
+ **sd-explore input:**
62
73
 
63
- Read the prompt template files from this skill's directory. Replace `[TARGET_PATH]` with the actual target path. Then dispatch using `Agent(general-purpose)`:
74
+ - **Target path**: the review target directory
75
+ - **Name**: `review`
76
+ - **File patterns**: `**/*.ts`, `**/*.tsx` (exclude `node_modules`, `dist`)
77
+ - **Analysis instructions**:
64
78
 
79
+ "For each file:
80
+ 1. Write a 1-2 line summary of what it does
81
+ 2. Tag files that need deep review (~30-50% of files; a file can have multiple tags)
82
+
83
+ Tag criteria:
84
+ - [CORRECTNESS] — Unguarded null/! assertions, async races, DOM manipulation (SSR risks), resource lifecycle gaps, swallowed exceptions, mutable state for sync
85
+ - [API] — Public exports, complex type signatures/generics/overloads, props/options interfaces, naming inconsistency
86
+ - [REFACTOR] — File > 300 lines or function > 50 lines, deep nesting (> 3 levels), similar patterns across files, mixed abstraction levels, mixed responsibilities
87
+
88
+ Output format:
65
89
  ```
66
- Agent(subagent_type=general-purpose, prompt=<filled template>)
90
+ # Explore: [directory names]
91
+
92
+ ## File Summaries
93
+ - `path/to/file.ts` — Brief description
94
+
95
+ ## Tagged Files
96
+ ### CORRECTNESS
97
+ - `path/to/file.ts:42` — Suspected issue description
98
+ ### API
99
+ - `path/to/file.ts` — Why this needs API review
100
+ ### REFACTOR
101
+ - `path/to/file.ts` — Structural concern
67
102
  ```
68
103
 
69
- Run selected reviewers **in parallel** (multiple Agent calls in a single message).
104
+ Files not listed under Tagged Files are considered clean. Do NOT add tags in File Summaries — Tagged Files is the single source of truth."
105
+
106
+ ### Step 3: Dispatch Reviewers (Parallel)
107
+
108
+ Read each reviewer's prompt template. Replace:
109
+ - `[CONVENTIONS]` → the conventions text collected in Step 1 (inline, not a file path)
110
+ - `[EXPLORE_FILES]` → comma-separated list of explore output file paths
70
111
 
71
- ### Step 2: Verify Findings
112
+ Dispatch selected reviewers in parallel.
72
113
 
73
- After collecting results from all reviewers, **Read the actual code** for each finding and verify.
114
+ ### Step 4: Verify & Deduplicate
74
115
 
75
- **For defect findings (Code, API, Convention reviewers):**
116
+ This is the **orchestrator-level** verification. Reviewers already self-verify, but findings can still be invalid or overlap.
76
117
 
77
- - **Valid**: the issue is real AND within scope include in the report
78
- - **Invalid — self-contradicted**: the reviewer's own analysis shows the issue is mitigated (e.g., "exploitability is limited because..."). Drop it.
79
- - **Invalid — type-only**: reports a type definition as a runtime issue without showing actual runtime code that triggers it. Drop it.
80
- - **Invalid — out of scope**: the issue is about code outside the target path (e.g., how other packages use this code). Drop it.
81
- - **Invalid — duplicate**: another reviewer already reported the same issue. Keep only the one from the correct domain.
82
- - **Invalid — bikeshedding**: minor style preference on stable, well-commented code (magic numbers with clear comments, small interface field duplication, naming when used consistently). Drop it.
83
- - **Invalid — severity inflated**: downgrade or drop findings where the stated severity doesn't match the actual impact.
84
- - **Invalid — already handled**: handled elsewhere in the codebase (provide evidence)
85
- - **Invalid — intentional pattern**: by-design architectural decision
86
- - **Invalid — misread**: the reviewer misinterpreted the code
118
+ **MANDATORY: Read actual code for EVERY finding.** For each finding, you MUST `Read` the file at the referenced location before deciding keep/drop. Do NOT rely on reviewer descriptions alone — verify against the actual code. A finding that was not verified by reading the source code CANNOT pass this step.
87
119
 
88
- **For refactoring findings (Simplifier, Structure reviewers):**
120
+ **Deduplication**: If multiple reviewers flag the same code location, keep the finding under the most specific reviewer:
121
+ - Convention violation + correctness concern → Convention Checker owns it
122
+ - API issue + structural concern → API Reviewer owns it
123
+ - When unclear, keep the one with stronger evidence
89
124
 
90
- **Check 1 Scope**:
91
- - Is this about code structure? Not bugs, conventions, documentation, or performance → if not, drop (out of scope)
92
- - Is the issue within the target path? → if not, drop (out of target)
93
- - Already reported by another reviewer? → keep the better-scoped one (duplicate)
94
- - Minor style preference with no real structural impact? → drop (bikeshedding)
125
+ **For defect findings (Code, API, Convention):**
95
126
 
96
- **Check 2 Duplication reality** (for duplication findings):
97
- - Count actual duplicated lines. If < 30 lines total, drop — not worth extracting.
98
- - Compare side by side. If the "duplicates" have meaningful behavioral differences (different guards, parameters, error handling), drop — not true duplication.
99
- - Check if "similar types" are an intentional Input/Normalized pattern (optional props → required internal def with defaults applied, `children` → `cell` rename). If yes, drop — by design.
127
+ Read the code, then drop if: self-contradicted, type-only (no runtime trigger), out of scope, duplicate, bikeshedding, severity inflated, already handled, intentional pattern, misread, tradeoff-negative.
100
128
 
101
- **Check 3 — Separation benefit** (for "too big", "mixed responsibilities", "mixed abstraction" findings):
102
- - Is the piece proposed for extraction < ~150 lines AND directly depends on the rest of the file (renders, calls, or shares state)? If yes, drop — splitting adds overhead without benefit.
103
- - Do all the abstractions serve a single cohesive domain concept (all functions called from one entry point, all types used together)? If yes, drop — it's cohesion, not mixing.
104
- - Would a realistic consumer reuse the extracted piece independently? If no, drop.
129
+ **For refactoring findings:**
105
130
 
106
- **Check 4 — Not by design**: Is this an established pattern used consistently across the codebase? (Provider+Component, Factory+Product, Input/Output types) If yes, drop.
131
+ Read the code at both/all referenced locations, then check:
107
132
 
108
- ### Step 3: Invalid Findings Report
133
+ - **Scope**: structural issue? within target? not a duplicate?
134
+ - **Duplication reality**: count the actual shared lines (not the reviewer's estimate). < 30 lines → drop. Behavioral differences between the "duplicated" code → drop. Intentional Input/Normalized pattern → drop.
135
+ - **Separation benefit**: < ~150 lines AND tightly coupled → drop. Single cohesive domain → drop. Not independently reusable → drop.
136
+ - **By design**: established pattern used consistently → drop.
137
+ - **Tradeoff-negative**: introduces more complexity than it removes → drop.
109
138
 
110
- Present only the **filtered findings** to the user:
139
+ ### Step 5: Report
140
+
141
+ Present **both** invalid and valid findings:
111
142
 
112
143
  ```
113
144
  ## Review: <target-path>
114
145
 
115
146
  ### Invalid Findings
116
- [findings filtered outgrouped by rejection reason]
117
- ```
147
+ [grouped by rejection reason brief, one line each]
118
148
 
119
- If there are **no valid findings**, report that the review found no actionable issues and end.
149
+ ### Valid Findings
150
+ [full details for each verified finding]
151
+ ```
120
152
 
121
- ### Step 4: User Confirmation
153
+ If no valid findings, report that and end here.
122
154
 
123
- Present each verified finding to the user **one at a time**, ordered by severity (CRITICAL WARNING INFO → HIGH → MEDIUM → LOW).
155
+ **If valid findings exist, you MUST proceed to Step 6. Do NOT ask the user whether to apply findings directly.**
124
156
 
125
- For each finding, explain:
126
- 1. **What the problem is** — the current code behavior and why it's an issue
127
- 2. **How it could be fixed** — possible solution approaches (if multiple exist, list them briefly)
128
- 3. **Ask**: address this or skip?
157
+ ### Step 6: Brainstorm Handoff
129
158
 
130
- Collect only findings the user confirms. If the user skips all findings, report that and end.
159
+ Invoke **sd-brainstorm** with all valid findings as context:
160
+ _
161
+ "Design fixes for the following review findings.
131
162
 
132
- ### Step 5: Brainstorm Handoff
163
+ **For each finding, you MUST:**
164
+ 1. Review it thoroughly — examine the code, understand the context, assess the real impact
165
+ 2. If any aspect is unclear or ambiguous, ask the user (one question at a time, per brainstorm rules)
166
+ 3. If a finding has low cost-benefit (adds complexity for marginal gain, pure style preference, scope too small), drop it. After triage, briefly list all dropped findings with one-line reasons (no user confirmation needed).
167
+ 4. For findings worth fixing, explore approaches and design solutions
133
168
 
134
- Pass only the **user-confirmed findings** to **sd-brainstorm**.
169
+ Findings that survive your triage become the design scope. Apply your normal brainstorm process (gap review → approaches → design presentation) to the surviving findings as a group.
135
170
 
136
- Each finding includes: **source reviewer**, **file:line**, **evidence**, **issue**, and **suggestion**.
171
+ <include all valid findings with their reviewer tag, file:line, problem description, and current code snippet>"
137
172
 
138
- sd-brainstorm will handle prioritization, grouping, approach exploration, and design.
173
+ sd-brainstorm then owns the full cycle: triage (with user input as needed) → design.
139
174
 
140
175
  ## Common Mistakes
141
176
 
142
177
  | Mistake | Fix |
143
178
  |---------|-----|
144
- | Using git diff to limit review scope | Review ALL source files under target path |
145
- | Skipping verification step | Always verify reviewer findings against actual code |
146
- | Reporting unverified issues | Only include verified findings in final report |
147
- | Running all reviewers for focused requests | Match reviewer selection to user's request |
148
- | Reporting bugs as refactoring | Ask: "Is the behavior wrong?" If yes → defect, not refactoring |
149
- | Reporting style as refactoring | Ask: "Is this structural?" If no → lint, not refactoring |
150
- | Presenting valid findings as final report | Valid findings must be confirmed by user, then handed off to sd-brainstorm |
151
- | Dumping all findings at once for user confirmation | Present findings one at a time with problem explanation and solution approaches |
152
-
153
- ## Completion Criteria
154
-
155
- Report invalid findings, then hand off all valid findings to sd-brainstorm. No code modifications during review.
179
+ | Using git diff to limit scope | Review ALL source files under target |
180
+ | Skipping verification | Always verify against actual code |
181
+ | Running all reviewers for focused requests | Match selection to user's request |
182
+ | Building per-reviewer files from explore results | Reviewers read explore files directly no intermediate step |