@simplysm/sd-claude 13.0.74 → 13.0.76
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 +92 -2
- package/claude/refs/sd-solid.md +2 -0
- package/claude/refs/sd-workflow.md +2 -1
- package/claude/rules/sd-claude-rules.md +21 -0
- package/claude/rules/sd-refs-linker.md +1 -1
- package/claude/sd-statusline.js +53 -11
- package/claude/skills/sd-api-name-review/SKILL.md +22 -3
- package/claude/skills/sd-brainstorm/SKILL.md +90 -1
- package/claude/skills/sd-check/SKILL.md +30 -14
- package/claude/skills/sd-commit/SKILL.md +0 -1
- package/claude/skills/sd-debug/SKILL.md +14 -13
- package/claude/skills/sd-explore/SKILL.md +76 -0
- package/claude/skills/sd-plan/SKILL.md +32 -0
- package/claude/skills/sd-plan-dev/SKILL.md +53 -2
- package/claude/skills/sd-plan-dev/code-quality-reviewer-prompt.md +1 -3
- package/claude/skills/sd-plan-dev/implementer-prompt.md +10 -1
- package/claude/skills/sd-readme/SKILL.md +1 -1
- package/claude/skills/sd-review/SKILL.md +73 -27
- package/claude/skills/sd-review/api-reviewer-prompt.md +6 -1
- package/claude/skills/sd-review/code-reviewer-prompt.md +9 -3
- package/claude/skills/sd-review/code-simplifier-prompt.md +43 -36
- package/claude/skills/sd-review/convention-checker-prompt.md +64 -0
- package/claude/skills/sd-review/structure-analyzer-prompt.md +97 -0
- package/claude/skills/sd-skill/SKILL.md +23 -0
- package/claude/skills/sd-skill/anthropic-best-practices.md +71 -1091
- package/claude/skills/sd-skill/testing-skills-with-subagents.md +9 -5
- package/claude/skills/sd-use/SKILL.md +19 -27
- package/package.json +1 -1
- package/claude/skills/sd-check/baseline-analysis.md +0 -150
- package/claude/skills/sd-check/test-scenarios.md +0 -205
- package/claude/skills/sd-debug/test-baseline-pressure.md +0 -61
|
@@ -18,6 +18,8 @@ Write comprehensive implementation plans assuming the engineer has zero context
|
|
|
18
18
|
|
|
19
19
|
Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well.
|
|
20
20
|
|
|
21
|
+
When a task uses a codebase-specific utility (hook, helper, style token) or test pattern, add a one-line explanation of what it does and the source file path. Example: "`createMountTransition(open)` — manages mount/unmount with CSS transitions (`packages/solid/src/hooks/createMountTransition.ts`)". This applies to test utilities and patterns too — if a test uses a framework-specific pattern (e.g., SolidJS `createRoot` for reactive context), explain why that pattern is needed.
|
|
22
|
+
|
|
21
23
|
**Announce at start:** "I'm using the sd-plan skill to create the implementation plan."
|
|
22
24
|
|
|
23
25
|
**Save plans to:** `docs/plans/YYYY-MM-DD-<feature-name>.md`
|
|
@@ -31,6 +33,18 @@ Assume they are a skilled developer, but know almost nothing about our toolset o
|
|
|
31
33
|
- "Run the tests and make sure they pass" - step
|
|
32
34
|
- "Commit" - step
|
|
33
35
|
|
|
36
|
+
**Step size limit:** If a single step produces more than ~30 lines of code, it is too large. Split it into multiple steps (e.g., "Define types and interfaces" → "Create context and hook" → "Implement provider component").
|
|
37
|
+
|
|
38
|
+
**TDD means YAGNI per step:** Step 3 ("Write minimal implementation") must implement ONLY what's needed to pass Step 1's test — nothing more. If the component needs additional behavior (e.g., FIFO eviction, remove), that behavior goes in a SUBSEQUENT task with its own failing test first. Do NOT implement the full component in one task and then test it after the fact.
|
|
39
|
+
|
|
40
|
+
## Task Ordering
|
|
41
|
+
|
|
42
|
+
**Shared resources BEFORE consumers.** Tasks must be ordered so that every file a task imports already exists from a prior task.
|
|
43
|
+
|
|
44
|
+
- Types, config, i18n entries → before components that use them
|
|
45
|
+
- Provider → before components that call useX() hooks
|
|
46
|
+
- If Task B imports from Task A's file → Task A must come first
|
|
47
|
+
|
|
34
48
|
## Plan Document Header
|
|
35
49
|
|
|
36
50
|
**Every plan MUST start with this header:**
|
|
@@ -103,12 +117,30 @@ git commit -m "feat: add specific feature"
|
|
|
103
117
|
```
|
|
104
118
|
```
|
|
105
119
|
|
|
120
|
+
## Test Requirement
|
|
121
|
+
|
|
122
|
+
**Every task that creates or modifies logic MUST include a test.** No exceptions.
|
|
123
|
+
|
|
124
|
+
- If the logic is testable with unit tests → write a vitest test file. This includes: pure functions, state management, timers/lifecycle logic (use `vi.useFakeTimers()`), event handlers, and state transitions.
|
|
125
|
+
- If the logic is UI-only (visual rendering, Portal placement, CSS animation) → include a manual verification step with exact instructions ("Open the browser, click X, expect Y")
|
|
126
|
+
- The **Files:** section must list the test file: `Test: exact/path/to/tests/file.spec.ts`
|
|
127
|
+
- If you find yourself writing a task with no test step → **STOP and add one**
|
|
128
|
+
|
|
106
129
|
## Remember
|
|
107
130
|
- Exact file paths always
|
|
131
|
+
- Cross-check the design document's file structure — every file listed in the design MUST appear in the plan (create or modify)
|
|
108
132
|
- Complete code in plan (not "add validation")
|
|
133
|
+
- When modifying an existing file, show ALL necessary import additions/changes — not just the appended code
|
|
134
|
+
- Code must compile cleanly — no unused imports or variables
|
|
109
135
|
- Exact commands with expected output
|
|
110
136
|
- DRY, YAGNI, TDD, frequent commits
|
|
111
137
|
|
|
138
|
+
## Related Skills
|
|
139
|
+
|
|
140
|
+
- **sd-brainstorm** — prerequisite: creates the design this skill plans from
|
|
141
|
+
- **sd-explore** — for deeper codebase exploration when gathering context
|
|
142
|
+
- **sd-plan-dev** — executes the plan this skill creates
|
|
143
|
+
|
|
112
144
|
## Execution Handoff
|
|
113
145
|
|
|
114
146
|
After saving the plan, **commit the plan document to git** before proceeding.
|
|
@@ -37,7 +37,7 @@ All execution uses `Task(general-purpose)` for parallel execution.
|
|
|
37
37
|
|
|
38
38
|
Independent tasks run as **parallel Task calls in a single message**. After implementers complete, spec and quality reviews run as **parallel Task calls**.
|
|
39
39
|
|
|
40
|
-
**CRITICAL:
|
|
40
|
+
**CRITICAL: Always launch parallel tasks as multiple Task calls in a single message (foreground parallel).** Never set `run_in_background: true` — it causes Stop hooks to fire prematurely. This rule applies regardless of permission mode (yolo, plan, etc.).
|
|
41
41
|
|
|
42
42
|
## The Process
|
|
43
43
|
|
|
@@ -104,7 +104,14 @@ digraph process {
|
|
|
104
104
|
"Batch integration check (typecheck + lint)" -> "More batches?";
|
|
105
105
|
"More batches?" -> "Implement the task" [label="yes, next batch"];
|
|
106
106
|
"More batches?" -> "Task: final review for entire implementation" [label="no"];
|
|
107
|
-
"
|
|
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"];
|
|
108
115
|
}
|
|
109
116
|
```
|
|
110
117
|
|
|
@@ -216,9 +223,18 @@ You: Using sd-plan-dev to execute this plan.
|
|
|
216
223
|
[Task: final review for entire implementation]
|
|
217
224
|
Final reviewer: All requirements met, ready to merge
|
|
218
225
|
|
|
226
|
+
[Run /simplify on all changed code]
|
|
227
|
+
Simplify: extracted shared validation helper, removed 2 duplicate imports
|
|
228
|
+
[typecheck + lint → pass]
|
|
229
|
+
[Commit: refactor: simplify changed code]
|
|
230
|
+
|
|
219
231
|
Done!
|
|
220
232
|
```
|
|
221
233
|
|
|
234
|
+
## Verification-Only Tasks
|
|
235
|
+
|
|
236
|
+
If a task is purely verification (no code changes — just running tests, typecheck, or manual checks), merge its checks into the batch integration check or final review rather than dispatching an implementer. These tasks exist in the plan for documentation purposes but don't need the full implementer → reviewer cycle.
|
|
237
|
+
|
|
222
238
|
## Batch Integration Check
|
|
223
239
|
|
|
224
240
|
Between batches, run targeted verification on affected packages before starting the next batch.
|
|
@@ -232,6 +248,39 @@ $PM run lint [affected packages]
|
|
|
232
248
|
|
|
233
249
|
This catches cross-task integration issues early — especially when the next batch depends on the current batch's output. Do NOT skip this even if individual task reviews passed.
|
|
234
250
|
|
|
251
|
+
If typecheck or lint fails, treat the errors as review issues: re-dispatch the implementer(s) whose changes caused the failure with the error output. After fix, re-run the integration check. Do NOT start the next batch until integration passes.
|
|
252
|
+
|
|
253
|
+
## Final Review Dispatch
|
|
254
|
+
|
|
255
|
+
After all batches complete and pass integration checks, dispatch the final reviewer:
|
|
256
|
+
|
|
257
|
+
1. Locate the original design document from `docs/plans/` — it shares the same date and topic as the plan file (e.g., plan `2026-03-04-dialog-confirm.md` → design `2026-03-04-dialog-confirm-design.md`)
|
|
258
|
+
2. Fill `./final-review-prompt.md` with:
|
|
259
|
+
- The full text of the original design document
|
|
260
|
+
- The full text of the implementation plan
|
|
261
|
+
- Summaries of all completed tasks (commit SHAs, files changed, test results)
|
|
262
|
+
3. Dispatch as `Task(general-purpose)`
|
|
263
|
+
4. If the final reviewer returns **APPROVED** → done
|
|
264
|
+
5. If the final reviewer returns **ISSUES**:
|
|
265
|
+
- For cross-task integration issues: create a fix task targeting specific files, run through implementer → review cycle
|
|
266
|
+
- For missing design requirements: create new implementation tasks and run through the full batch cycle
|
|
267
|
+
- Re-run final review after all fixes
|
|
268
|
+
|
|
269
|
+
## Simplify
|
|
270
|
+
|
|
271
|
+
After the final review passes, run `/simplify` to review all changed code for reuse, quality, and efficiency. This catches cross-task cleanup opportunities that individual reviewers miss.
|
|
272
|
+
|
|
273
|
+
1. Orchestrator runs `/simplify` via the Skill tool
|
|
274
|
+
2. If simplify made changes:
|
|
275
|
+
- Run typecheck/lint on affected packages
|
|
276
|
+
- If typecheck/lint fails → fix the issues and re-run typecheck/lint until it passes
|
|
277
|
+
- Commit simplify changes as a separate commit (`refactor: simplify changed code`)
|
|
278
|
+
3. If simplify made no changes → skip to completion
|
|
279
|
+
|
|
280
|
+
## Completion
|
|
281
|
+
|
|
282
|
+
After simplify completes (or is skipped), report to the user: number of tasks completed, total files changed, and final review outcome.
|
|
283
|
+
|
|
235
284
|
## Red Flags
|
|
236
285
|
|
|
237
286
|
**Never:**
|
|
@@ -246,6 +295,7 @@ This catches cross-task integration issues early — especially when the next ba
|
|
|
246
295
|
- Accept "close enough" on spec compliance
|
|
247
296
|
- Skip review loops (issue found → fix → re-review)
|
|
248
297
|
- Skip batch integration checks between batches
|
|
298
|
+
- Skip `/simplify` after final review
|
|
249
299
|
- Use `run_in_background: true` on Task calls (use foreground parallel instead)
|
|
250
300
|
|
|
251
301
|
**If implementer returns questions:**
|
|
@@ -273,5 +323,6 @@ This catches cross-task integration issues early — especially when the next ba
|
|
|
273
323
|
**Related skills:**
|
|
274
324
|
|
|
275
325
|
- **sd-plan** — creates the plan this skill executes
|
|
326
|
+
- **sd-explore** — for codebase exploration when implementers need deeper context
|
|
276
327
|
- **sd-tdd** — implementers follow TDD
|
|
277
328
|
- **sd-worktree** — branch isolation for worktree-based workflows
|
|
@@ -13,11 +13,9 @@ You are reviewing code quality for a completed implementation.
|
|
|
13
13
|
## Review Scope
|
|
14
14
|
|
|
15
15
|
Use git diff to review only what changed:
|
|
16
|
-
```
|
|
17
16
|
|
|
18
|
-
git diff [BASE_SHA]..[HEAD_SHA]
|
|
17
|
+
git diff [BASE_SHA]..[HEAD_SHA]
|
|
19
18
|
|
|
20
|
-
```
|
|
21
19
|
BASE_SHA: [commit before task started]
|
|
22
20
|
HEAD_SHA: [implementer's commit SHA from report]
|
|
23
21
|
|
|
@@ -20,12 +20,20 @@ You are implementing Task [N]: [task name]
|
|
|
20
20
|
|
|
21
21
|
If anything is unclear about requirements or approach, return your questions under a `## Questions` heading and STOP. Do not guess — do not implement.
|
|
22
22
|
|
|
23
|
+
## Plan Deviations
|
|
24
|
+
|
|
25
|
+
Plans may contain minor inaccuracies (wrong file paths, outdated API signatures, incorrect line numbers). Handle deviations by severity:
|
|
26
|
+
|
|
27
|
+
- **Minor** (file path renamed, import path different, line numbers shifted): Adapt to the actual codebase and note the deviation in your report.
|
|
28
|
+
- **Major** (API doesn't exist, approach fundamentally different, missing dependency): Return your questions under `## Questions` and STOP.
|
|
29
|
+
|
|
23
30
|
## While You Work
|
|
24
31
|
|
|
25
32
|
If you encounter something unexpected mid-implementation (missing APIs, unexpected patterns, ambiguous behavior), **ask questions rather than guess**. Return your questions under `## Questions` and STOP. It's always OK to pause and clarify.
|
|
26
33
|
|
|
27
34
|
## Your Job
|
|
28
35
|
|
|
36
|
+
0. **Before writing any code**: Read `.claude/refs/sd-code-conventions.md` and check `.claude/rules/sd-refs-linker.md` for additional refs relevant to the code you'll touch (e.g., `sd-solid.md` for SolidJS, `sd-orm.md` for ORM). Follow all project conventions — implementing a task does NOT exempt you from conventions.
|
|
29
37
|
1. Implement exactly what the task specifies — nothing more, nothing less
|
|
30
38
|
2. Write tests (follow TDD if the plan says to)
|
|
31
39
|
3. Verify: tests pass, no type errors
|
|
@@ -35,7 +43,7 @@ If you encounter something unexpected mid-implementation (missing APIs, unexpect
|
|
|
35
43
|
- **Discipline**: Nothing overbuilt (YAGNI)? Only what was requested?
|
|
36
44
|
- **Testing**: Tests verify behavior (not implementation)? Comprehensive?
|
|
37
45
|
5. Fix anything found in self-review
|
|
38
|
-
6. Commit
|
|
46
|
+
6. Commit using conventional commit format: `type(scope): description` (e.g., `feat(solid): add ConfirmDialog component`)
|
|
39
47
|
7. Report back
|
|
40
48
|
|
|
41
49
|
Work from: [directory path]
|
|
@@ -45,6 +53,7 @@ Work from: [directory path]
|
|
|
45
53
|
When done, provide:
|
|
46
54
|
- Commit SHA (from step 6)
|
|
47
55
|
- Files created/modified (with brief description of changes)
|
|
56
|
+
- Plan deviations (if any — what the plan said vs. what you did and why)
|
|
48
57
|
- Test results
|
|
49
58
|
- Self-review findings (if any were fixed)
|
|
50
59
|
- Open concerns (if any)
|
|
@@ -185,7 +185,7 @@ Report what was changed.
|
|
|
185
185
|
| Ignoring existing docs/ structure | If docs/ exists, update those files too |
|
|
186
186
|
| Arbitrary section reorganization | Follow index.ts `#region` structure |
|
|
187
187
|
| Missing import paths in examples | Always: `import { X } from "@simplysm/..."` |
|
|
188
|
-
| Writing in
|
|
188
|
+
| Writing in non-English languages | README must be in English |
|
|
189
189
|
| Adding changelog sections | Never add version history |
|
|
190
190
|
| Editing before reporting diff | Always report ADDED/REMOVED/CHANGED and wait for confirmation |
|
|
191
191
|
| Destroying docs/ link format | If README uses `[name](docs/file.md#anchor)`, preserve that pattern |
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: sd-review
|
|
3
|
-
description: "
|
|
3
|
+
description: "Use when the user explicitly requests code review, refactoring analysis, or structural improvement. Covers correctness, safety, API design, conventions, complexity, duplication, and code structure. Explicit invocation only."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# sd-review
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
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.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
**Analysis only — no code modifications.**
|
|
13
|
+
|
|
14
|
+
## Principles
|
|
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.
|
|
13
17
|
|
|
14
18
|
## Usage
|
|
15
19
|
|
|
16
|
-
- `/sd-review packages/solid` — full review (all
|
|
20
|
+
- `/sd-review packages/solid` — full review (all perspectives)
|
|
17
21
|
- `/sd-review packages/solid focus on bugs` — selective review based on request
|
|
22
|
+
- `/sd-review packages/solid focus on refactoring` — structural analysis only
|
|
18
23
|
- `/sd-review` — if no argument, ask the user for the target path
|
|
19
24
|
|
|
20
25
|
## Target Selection
|
|
@@ -28,23 +33,28 @@ Dispatches up to 3 reviewer agents in parallel using prompt templates. Each agen
|
|
|
28
33
|
|
|
29
34
|
| Reviewer | Prompt Template | Perspective |
|
|
30
35
|
|----------|----------------|-------------|
|
|
31
|
-
| **Code Reviewer** | `code-reviewer-prompt.md` | Correctness & Safety — bugs, security, logic errors |
|
|
36
|
+
| **Code Reviewer** | `code-reviewer-prompt.md` | Correctness & Safety — bugs, security, logic errors, architectural defects (circular deps, boundary violations) |
|
|
32
37
|
| **API Reviewer** | `api-reviewer-prompt.md` | Usability & DX — naming, types, consistency |
|
|
33
|
-
| **
|
|
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
41
|
|
|
35
42
|
## Reviewer Selection
|
|
36
43
|
|
|
37
|
-
By default, run **all
|
|
44
|
+
By default, run **all 5 reviewers**. If the user specifies a focus in natural language, select only the relevant reviewer(s):
|
|
38
45
|
|
|
39
46
|
| User says | Run |
|
|
40
47
|
|-----------|-----|
|
|
41
|
-
| "bugs", "security", "safety" | Code Reviewer only |
|
|
48
|
+
| "bugs", "security", "safety", "architecture", "dependencies", "boundaries" | Code Reviewer only |
|
|
42
49
|
| "API", "naming", "types", "DX" | API Reviewer only |
|
|
43
|
-
| "
|
|
44
|
-
| "
|
|
45
|
-
|
|
|
50
|
+
| "conventions", "rules", "patterns" | Convention Checker only |
|
|
51
|
+
| "simplify", "complexity", "duplication", "readability" | Code Simplifier only |
|
|
52
|
+
| "structure", "responsibility", "module", "organization", "abstraction" | Structure Analyzer only |
|
|
53
|
+
| "defects", "correctness" | Code + API + Convention |
|
|
54
|
+
| "refactoring", "refactor", "maintainability" | Simplifier + Structure |
|
|
55
|
+
| (no specific focus) | All 5 |
|
|
46
56
|
|
|
47
|
-
Use judgment for ambiguous requests.
|
|
57
|
+
Use judgment for ambiguous requests.
|
|
48
58
|
|
|
49
59
|
## Workflow
|
|
50
60
|
|
|
@@ -60,41 +70,73 @@ Run selected reviewers **in parallel** (multiple Agent calls in a single message
|
|
|
60
70
|
|
|
61
71
|
### Step 2: Verify Findings
|
|
62
72
|
|
|
63
|
-
After collecting results from all reviewers, **Read the actual code** for each finding and verify
|
|
73
|
+
After collecting results from all reviewers, **Read the actual code** for each finding and verify.
|
|
74
|
+
|
|
75
|
+
**For defect findings (Code, API, Convention reviewers):**
|
|
64
76
|
|
|
65
77
|
- **Valid**: the issue is real AND within scope → include in the report
|
|
66
78
|
- **Invalid — self-contradicted**: the reviewer's own analysis shows the issue is mitigated (e.g., "exploitability is limited because..."). Drop it.
|
|
67
79
|
- **Invalid — type-only**: reports a type definition as a runtime issue without showing actual runtime code that triggers it. Drop it.
|
|
68
80
|
- **Invalid — out of scope**: the issue is about code outside the target path (e.g., how other packages use this code). Drop it.
|
|
69
|
-
- **Invalid — duplicate**: another reviewer already reported the same issue. Keep only the one from the correct domain
|
|
81
|
+
- **Invalid — duplicate**: another reviewer already reported the same issue. Keep only the one from the correct domain.
|
|
70
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.
|
|
71
83
|
- **Invalid — severity inflated**: downgrade or drop findings where the stated severity doesn't match the actual impact.
|
|
72
84
|
- **Invalid — already handled**: handled elsewhere in the codebase (provide evidence)
|
|
73
85
|
- **Invalid — intentional pattern**: by-design architectural decision
|
|
74
86
|
- **Invalid — misread**: the reviewer misinterpreted the code
|
|
75
87
|
|
|
76
|
-
|
|
88
|
+
**For refactoring findings (Simplifier, Structure reviewers):**
|
|
77
89
|
|
|
78
|
-
|
|
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)
|
|
79
95
|
|
|
80
|
-
|
|
81
|
-
|
|
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.
|
|
82
100
|
|
|
83
|
-
|
|
84
|
-
|
|
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.
|
|
85
105
|
|
|
86
|
-
|
|
87
|
-
[verified warning findings from all reviewers]
|
|
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.
|
|
88
107
|
|
|
89
|
-
###
|
|
90
|
-
[verified info findings from all reviewers]
|
|
108
|
+
### Step 3: Invalid Findings Report
|
|
91
109
|
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
Present only the **filtered findings** to the user:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
## Review: <target-path>
|
|
114
|
+
|
|
115
|
+
### Invalid Findings
|
|
116
|
+
[findings filtered out — grouped by rejection reason]
|
|
94
117
|
```
|
|
95
118
|
|
|
119
|
+
If there are **no valid findings**, report that the review found no actionable issues and end.
|
|
120
|
+
|
|
121
|
+
### Step 4: User Confirmation
|
|
122
|
+
|
|
123
|
+
Present each verified finding to the user **one at a time**, ordered by severity (CRITICAL → WARNING → INFO → HIGH → MEDIUM → LOW).
|
|
124
|
+
|
|
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?
|
|
129
|
+
|
|
130
|
+
Collect only findings the user confirms. If the user skips all findings, report that and end.
|
|
131
|
+
|
|
132
|
+
### Step 5: Brainstorm Handoff
|
|
133
|
+
|
|
134
|
+
Pass only the **user-confirmed findings** to **sd-brainstorm**.
|
|
135
|
+
|
|
96
136
|
Each finding includes: **source reviewer**, **file:line**, **evidence**, **issue**, and **suggestion**.
|
|
97
137
|
|
|
138
|
+
sd-brainstorm will handle prioritization, grouping, approach exploration, and design.
|
|
139
|
+
|
|
98
140
|
## Common Mistakes
|
|
99
141
|
|
|
100
142
|
| Mistake | Fix |
|
|
@@ -103,7 +145,11 @@ Each finding includes: **source reviewer**, **file:line**, **evidence**, **issue
|
|
|
103
145
|
| Skipping verification step | Always verify reviewer findings against actual code |
|
|
104
146
|
| Reporting unverified issues | Only include verified findings in final report |
|
|
105
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 |
|
|
106
152
|
|
|
107
153
|
## Completion Criteria
|
|
108
154
|
|
|
109
|
-
|
|
155
|
+
Report invalid findings, then hand off all valid findings to sd-brainstorm. No code modifications during review.
|
|
@@ -12,10 +12,15 @@ Review ALL source files at [TARGET_PATH].
|
|
|
12
12
|
|
|
13
13
|
## Step 1: List all source files
|
|
14
14
|
|
|
15
|
-
Use Glob to list all .ts files under the target path (exclude node_modules, dist).
|
|
15
|
+
Use Glob to list all .ts/.tsx files under the target path (exclude node_modules, dist).
|
|
16
16
|
|
|
17
17
|
## Step 2: Map the public API surface
|
|
18
18
|
|
|
19
|
+
Read the following reference files for project conventions:
|
|
20
|
+
- `CLAUDE.md` — project overview and conventions
|
|
21
|
+
- `.claude/rules/sd-refs-linker.md` — reference guide linking to detailed docs per topic (read relevant refs based on the target code)
|
|
22
|
+
|
|
23
|
+
Then:
|
|
19
24
|
- Read index.ts to list all exports (types, functions, constants)
|
|
20
25
|
- Read each exported type/interface/function definition
|
|
21
26
|
- Read test files and consumer code to see actual usage patterns
|
|
@@ -12,12 +12,16 @@ Review ALL source files at [TARGET_PATH].
|
|
|
12
12
|
|
|
13
13
|
## Step 1: List all source files
|
|
14
14
|
|
|
15
|
-
Use Glob to list all .ts files under the target path (exclude node_modules, dist).
|
|
15
|
+
Use Glob to list all .ts/.tsx files under the target path (exclude node_modules, dist).
|
|
16
16
|
This is your review scope — every file in this list must be examined.
|
|
17
17
|
|
|
18
18
|
## Step 2: Understand the codebase
|
|
19
19
|
|
|
20
|
-
Read the
|
|
20
|
+
Read the following reference files for project conventions:
|
|
21
|
+
- `CLAUDE.md` — project overview and conventions
|
|
22
|
+
- `.claude/rules/sd-refs-linker.md` — reference guide linking to detailed docs per topic (read relevant refs based on the target code)
|
|
23
|
+
|
|
24
|
+
Then:
|
|
21
25
|
- Read index.ts to map the module structure
|
|
22
26
|
- Read each source file to understand logic flows, data transformations, error paths
|
|
23
27
|
|
|
@@ -29,10 +33,12 @@ Look for:
|
|
|
29
33
|
- Race conditions: async ordering, shared state without synchronization
|
|
30
34
|
- Resource leaks: uncleared subscriptions/listeners, unclosed handles
|
|
31
35
|
- Error handling: swallowed exceptions, wrong fallbacks, missing propagation
|
|
36
|
+
- Architectural defects: circular dependencies, boundary violations (reaching into another package's internals), wrong dependency direction (higher-level packages imported by lower-level ones)
|
|
32
37
|
|
|
33
38
|
Do NOT report:
|
|
34
39
|
- Naming consistency, API design, type quality (including `any` types)
|
|
35
|
-
- Code complexity, duplication, readability improvements
|
|
40
|
+
- Code complexity, duplication, readability improvements (handled by Code Simplifier)
|
|
41
|
+
- Structural improvement suggestions (handled by Structure Analyzer)
|
|
36
42
|
- Style preferences unless they cause actual bugs
|
|
37
43
|
- Type definitions alone — a type allowing `stack?: string` is NOT a security issue unless the runtime code actually sends it unsanitized
|
|
38
44
|
- Speculative future risks — "if config were changed to X, this would break" is not a finding
|
|
@@ -3,85 +3,92 @@
|
|
|
3
3
|
Template for `Agent(general-purpose)`. Fill in `[TARGET_PATH]`.
|
|
4
4
|
|
|
5
5
|
```
|
|
6
|
-
You are
|
|
7
|
-
Your question: "
|
|
6
|
+
You are analyzing code for structural simplification opportunities.
|
|
7
|
+
Your question: "Can this code be simpler without changing its behavior?"
|
|
8
8
|
|
|
9
9
|
## Target
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Analyze ALL source files at [TARGET_PATH].
|
|
12
12
|
|
|
13
13
|
## Step 1: List all source files
|
|
14
14
|
|
|
15
|
-
Use Glob to list all .ts files under the target path (exclude node_modules, dist).
|
|
15
|
+
Use Glob to list all .ts/.tsx files under the target path (exclude node_modules, dist).
|
|
16
16
|
|
|
17
17
|
## Step 2: Understand the structure
|
|
18
18
|
|
|
19
|
+
Read the following reference files for project conventions:
|
|
20
|
+
- `CLAUDE.md` — project overview and conventions
|
|
21
|
+
- `.claude/rules/sd-refs-linker.md` — reference guide linking to detailed docs per topic (read relevant refs based on the target code)
|
|
22
|
+
|
|
23
|
+
Then:
|
|
19
24
|
- Map module dependencies and abstraction layers
|
|
20
25
|
- Compare whether similar-role files use consistent patterns
|
|
21
26
|
- Identify complexity hotspots: deep nesting, long functions, complex conditionals
|
|
22
27
|
|
|
23
|
-
## Step 3: Find
|
|
28
|
+
## Step 3: Find refactoring opportunities
|
|
24
29
|
|
|
25
30
|
Look for:
|
|
26
|
-
- Unnecessary complexity: over-abstraction, needless indirection, complex generics
|
|
27
|
-
- Duplication: same logic repeated, similar functions that could be unified
|
|
31
|
+
- Unnecessary complexity: over-abstraction, needless indirection, complex generics that could be simpler
|
|
32
|
+
- Duplication: same logic repeated across files, similar functions that could be unified
|
|
28
33
|
- Readability: hard-to-follow control flow, unclear variable names, implicit behavior
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
- `
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
34
|
+
- File structure: too many files for simple concepts, or too many responsibilities in one file
|
|
35
|
+
- Coupling: changes that would cascade widely, tightly coupled modules
|
|
36
|
+
|
|
37
|
+
## CRITICAL — Scope boundaries
|
|
38
|
+
|
|
39
|
+
Do NOT report ANY of the following. These are OUT OF SCOPE:
|
|
40
|
+
- Bugs, security issues, logic errors, race conditions → that's code review
|
|
41
|
+
- Naming consistency, API design, type quality (including `any` types) → that's API review
|
|
42
|
+
- Code language violations (Korean comments, non-English strings) → that's lint
|
|
43
|
+
- Documentation gaps (missing JSDoc, missing comments, undocumented behavior) → that's documentation
|
|
44
|
+
- Style preferences (property shorthand, `else` after `return`, import ordering, formatting)
|
|
45
|
+
- Performance optimization (unless the fix is ALSO a structural improvement)
|
|
46
|
+
- Magic numbers with clear adjacent comments
|
|
47
|
+
- Small interface duplication (< 10 fields) where extraction adds indirection without real benefit
|
|
48
|
+
- Issues in code OUTSIDE the target path
|
|
49
|
+
|
|
50
|
+
**Test each finding:** "Is this about CODE STRUCTURE, or about something else (bugs, conventions, docs, performance)?" If something else → drop it.
|
|
43
51
|
|
|
44
52
|
## Step 4: Self-verify before reporting
|
|
45
53
|
|
|
46
54
|
Before including ANY finding:
|
|
47
55
|
|
|
48
|
-
1. **
|
|
49
|
-
2. **
|
|
50
|
-
3. **
|
|
56
|
+
1. **Structure test**: Is this genuinely about code structure? Or is it a bug, convention, or documentation issue disguised as refactoring?
|
|
57
|
+
2. **Impact test**: Would a developer actually struggle with this structure? Or is it just "could be slightly different"?
|
|
58
|
+
3. **Scope check**: Is the issue IN the target code, or in how other code uses it?
|
|
51
59
|
|
|
52
|
-
**Quality over quantity: 3 verified findings > 10
|
|
60
|
+
**Quality over quantity: 3 verified structural findings > 10 mixed findings.**
|
|
53
61
|
|
|
54
62
|
## Constraints
|
|
55
63
|
|
|
56
64
|
- Analysis only. Do NOT modify any files.
|
|
57
65
|
- Do NOT provide corrected code blocks. Describe issues and suggestions in words only.
|
|
58
|
-
- Only report issues with real evidence from the code.
|
|
59
|
-
- Focus on substance: structural
|
|
60
|
-
- Do NOT report findings that belong to other reviewers' scope.
|
|
66
|
+
- Only report structural issues with real evidence from the code.
|
|
67
|
+
- Focus on substance: structural problems that genuinely make the code harder to understand or modify.
|
|
61
68
|
|
|
62
69
|
## Output Format
|
|
63
70
|
|
|
64
71
|
Use this exact format for every finding:
|
|
65
72
|
|
|
66
|
-
### [
|
|
73
|
+
### [HIGH|MEDIUM|LOW] title
|
|
67
74
|
|
|
68
75
|
- **File**: path/to/file.ts:42
|
|
69
76
|
- **Evidence**: what you observed (include code snippet)
|
|
70
|
-
- **Issue**: what the problem is
|
|
77
|
+
- **Issue**: what the structural problem is
|
|
71
78
|
- **Suggestion**: how to improve it (in words, not code)
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
80
|
+
Impact levels:
|
|
81
|
+
- HIGH: Major structural problem. Significantly harder to understand or modify safely.
|
|
82
|
+
- MEDIUM: Notable structural concern. Unnecessary complexity or meaningful duplication.
|
|
83
|
+
- LOW: Improvement opportunity. Cleaner structure exists but current code is workable.
|
|
77
84
|
|
|
78
85
|
Start your report with:
|
|
79
86
|
|
|
80
|
-
##
|
|
87
|
+
## Code Simplification Results
|
|
81
88
|
|
|
82
89
|
### Summary
|
|
83
90
|
- Files reviewed: N
|
|
84
|
-
- Findings: X
|
|
91
|
+
- Findings: X HIGH, Y MEDIUM, Z LOW
|
|
85
92
|
|
|
86
93
|
### Findings
|
|
87
94
|
[findings here]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Convention Checker Prompt
|
|
2
|
+
|
|
3
|
+
Template for `Agent(general-purpose)`. Fill in `[TARGET_PATH]`.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
You are checking code against project conventions.
|
|
7
|
+
Your question: "Does this code violate any project-defined rules?"
|
|
8
|
+
|
|
9
|
+
## Target
|
|
10
|
+
|
|
11
|
+
Check ALL source files at [TARGET_PATH].
|
|
12
|
+
|
|
13
|
+
## Step 1: Read convention files
|
|
14
|
+
|
|
15
|
+
Read `.claude/rules/sd-refs-linker.md` to find ALL convention files that apply to the target code. Then read each referenced convention file.
|
|
16
|
+
|
|
17
|
+
At minimum, always read:
|
|
18
|
+
- `.claude/refs/sd-code-conventions.md` — applies to all code
|
|
19
|
+
|
|
20
|
+
Also read topic-specific refs based on the target code (e.g., `sd-solid.md` for SolidJS, `sd-orm.md` for ORM).
|
|
21
|
+
|
|
22
|
+
## Step 2: Extract prohibited patterns
|
|
23
|
+
|
|
24
|
+
From each convention file, extract rules that define prohibited or required patterns. Build a checklist of Grep-searchable patterns.
|
|
25
|
+
|
|
26
|
+
Example from `sd-code-conventions.md`:
|
|
27
|
+
- `as unknown as` — prohibited
|
|
28
|
+
- `as any` — prohibited in public-facing types
|
|
29
|
+
- `export * from` or `export { } from` outside `src/index.ts` — prohibited
|
|
30
|
+
|
|
31
|
+
## Step 3: Grep for each pattern
|
|
32
|
+
|
|
33
|
+
For each prohibited pattern, run a Grep search across all target files. Report every match.
|
|
34
|
+
|
|
35
|
+
Do NOT skip, downgrade, or dismiss matches for any reason:
|
|
36
|
+
- "Widespread usage" is NOT an exception — it means widespread violation
|
|
37
|
+
- "No alternative" is NOT an exception — the convention file lists alternatives
|
|
38
|
+
- "Codebase pattern" is NOT an exception — the convention defines what's correct, not current usage
|
|
39
|
+
|
|
40
|
+
## Step 4: Report
|
|
41
|
+
|
|
42
|
+
Use this exact format for every finding:
|
|
43
|
+
|
|
44
|
+
### [WARNING] title
|
|
45
|
+
|
|
46
|
+
- **File**: path/to/file.ts:42
|
|
47
|
+
- **Convention**: which rule from which convention file
|
|
48
|
+
- **Evidence**: the matching code (include snippet)
|
|
49
|
+
- **Suggestion**: the fix recommended by the convention file
|
|
50
|
+
|
|
51
|
+
All convention violations are WARNING severity. Use CRITICAL only if the violation causes an immediate runtime bug.
|
|
52
|
+
|
|
53
|
+
Start your report with:
|
|
54
|
+
|
|
55
|
+
## Convention Check Results
|
|
56
|
+
|
|
57
|
+
### Summary
|
|
58
|
+
- Files checked: N
|
|
59
|
+
- Convention files referenced: [list]
|
|
60
|
+
- Violations found: N
|
|
61
|
+
|
|
62
|
+
### Violations
|
|
63
|
+
[findings here]
|
|
64
|
+
```
|