@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.
- package/claude/refs/sd-code-conventions.md +11 -3
- package/claude/refs/sd-solid.md +11 -2
- package/claude/rules/sd-claude-rules.md +6 -10
- package/claude/sd-statusline.js +7 -7
- package/claude/skills/sd-api-name-review/SKILL.md +103 -17
- package/claude/skills/sd-brainstorm/SKILL.md +32 -47
- package/claude/skills/sd-check/SKILL.md +14 -16
- package/claude/skills/sd-commit/SKILL.md +1 -3
- package/claude/skills/sd-debug/SKILL.md +5 -11
- package/claude/skills/sd-debug/condition-based-waiting.md +5 -11
- package/claude/skills/sd-debug/root-cause-tracing.md +18 -33
- package/claude/skills/sd-explore/SKILL.md +86 -44
- package/claude/skills/sd-plan/SKILL.md +0 -1
- package/claude/skills/sd-plan-dev/SKILL.md +48 -82
- package/claude/skills/sd-review/SKILL.md +107 -80
- package/claude/skills/sd-review/api-reviewer-prompt.md +23 -43
- package/claude/skills/sd-review/code-reviewer-prompt.md +26 -35
- package/claude/skills/sd-review/convention-checker-prompt.md +23 -26
- package/claude/skills/sd-review/refactoring-analyzer-prompt.md +92 -0
- package/claude/skills/sd-skill/SKILL.md +10 -16
- package/claude/skills/sd-skill/writing-guide.md +7 -11
- package/claude/skills/sd-tdd/SKILL.md +15 -20
- package/claude/skills/sd-use/SKILL.md +3 -4
- package/claude/skills/sd-worktree/SKILL.md +58 -113
- package/package.json +1 -1
- package/claude/skills/sd-review/code-simplifier-prompt.md +0 -95
- package/claude/skills/sd-review/structure-analyzer-prompt.md +0 -97
- 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
|
|
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
|
-
|
|
8
|
+
## Overview
|
|
10
9
|
|
|
11
|
-
|
|
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
|
-
**
|
|
12
|
+
**Core principle:** Never read 30+ files in a single agent context. Split, parallelize, write to files.
|
|
14
13
|
|
|
15
|
-
|
|
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
|
-
|
|
16
|
+
## When to Use
|
|
21
17
|
|
|
22
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
26
|
+
## Input
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
The calling skill provides:
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
48
|
+
Split files into groups of **~30 files each**.
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
{1-3 sentence overview}
|
|
50
|
+
**Splitting strategy:**
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
48
|
-
{APIs, components, commands — with file:line references}
|
|
58
|
+
**Goal:** Balanced groups where related files stay together.
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
{Step-by-step execution traces}
|
|
60
|
+
### Step 3: Dispatch Parallel Agents
|
|
52
61
|
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
+
**Assigned files:**
|
|
70
|
+
[list of file paths for this group]
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
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).
|
|
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
|
|
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
|
|
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
|
|
37
|
-
| **API Reviewer** | `api-reviewer-prompt.md` | Usability & DX
|
|
38
|
-
| **Convention Checker** | `convention-checker-prompt.md` | Project rules — Grep-based
|
|
39
|
-
| **
|
|
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
|
|
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"
|
|
49
|
-
| "API", "naming", "types", "DX" | API Reviewer
|
|
50
|
-
| "conventions", "rules", "patterns" | Convention Checker
|
|
51
|
-
| "simplify", "complexity", "duplication", "
|
|
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" |
|
|
55
|
-
| (no specific focus) | All
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
112
|
+
Dispatch selected reviewers in parallel.
|
|
72
113
|
|
|
73
|
-
|
|
114
|
+
### Step 4: Verify & Deduplicate
|
|
74
115
|
|
|
75
|
-
**
|
|
116
|
+
This is the **orchestrator-level** verification. Reviewers already self-verify, but findings can still be invalid or overlap.
|
|
76
117
|
|
|
77
|
-
|
|
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
|
-
**
|
|
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
|
-
**
|
|
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
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
131
|
+
Read the code at both/all referenced locations, then check:
|
|
107
132
|
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
117
|
-
```
|
|
147
|
+
[grouped by rejection reason — brief, one line each]
|
|
118
148
|
|
|
119
|
-
|
|
149
|
+
### Valid Findings
|
|
150
|
+
[full details for each verified finding]
|
|
151
|
+
```
|
|
120
152
|
|
|
121
|
-
|
|
153
|
+
If no valid findings, report that and end here.
|
|
122
154
|
|
|
123
|
-
|
|
155
|
+
**If valid findings exist, you MUST proceed to Step 6. Do NOT ask the user whether to apply findings directly.**
|
|
124
156
|
|
|
125
|
-
|
|
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
|
-
|
|
159
|
+
Invoke **sd-brainstorm** with all valid findings as context:
|
|
160
|
+
_
|
|
161
|
+
"Design fixes for the following review findings.
|
|
131
162
|
|
|
132
|
-
|
|
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
|
-
|
|
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
|
-
|
|
171
|
+
<include all valid findings with their reviewer tag, file:line, problem description, and current code snippet>"
|
|
137
172
|
|
|
138
|
-
sd-brainstorm
|
|
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
|
|
145
|
-
| Skipping verification
|
|
146
|
-
|
|
|
147
|
-
|
|
|
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 |
|