@simplysm/sd-claude 13.0.72 → 13.0.74

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.
@@ -7,73 +7,59 @@ model: sonnet
7
7
 
8
8
  # sd-readme
9
9
 
10
- Sync package README.md source index with current exports from `index.ts`.
10
+ Sync package README.md with current source code by comparing exports against documentation.
11
11
 
12
12
  ## Purpose
13
13
 
14
- `@simplysm/*` packages ship `.ts` source and test files. Claude Code reads source files directly from `node_modules/` for API details (props, types, signatures, usage patterns).
14
+ README.md is the **sole API documentation source for Claude Code**. When Claude Code works in a consumer app using `@simplysm/*` packages, it reads README.md from `node_modules/` to understand the library API. Claude Code does NOT read JSDoc from source files.
15
15
 
16
- **README.md is a source file index** it tells Claude Code **which files to read**, not the API itself.
16
+ **Therefore: every exported symbol must be documented in README.**
17
17
 
18
18
  ## Modes
19
19
 
20
20
  - **Single package** (`$ARGUMENTS` = package name or path): Update one package's README
21
21
  - **Batch** (`$ARGUMENTS` empty): Discover and update all packages in parallel
22
22
 
23
- ## What Goes Where
23
+ ## README Writing Rules
24
24
 
25
- | In README | NOT in README (read from source) |
26
- |-----------|----------------------------------|
27
- | Package description (one-line) | Prop tables |
28
- | Installation + peer dependencies | Code examples |
29
- | Setup/configuration (Provider tree, Tailwind preset) | Type/interface definitions |
30
- | **Source index table** | API signatures |
31
- | License | Behavioral descriptions |
25
+ - Written in **English**
26
+ - All code examples must include **import paths**: `import { ... } from "@simplysm/..."`
27
+ - **Every export** from `index.ts` must be documented — including those with `@internal` JSDoc
28
+ - No changelog, version history, or "recently updated" sections
29
+ - Section organization follows `index.ts` `#region` structure
30
+ - Heading levels: `##` for major sections, `###` for sub-sections
32
31
 
33
- ## README Structure
32
+ ### Standard Structure
34
33
 
35
34
  ```markdown
36
35
  # @simplysm/{package-name}
37
36
 
38
- {One-line description from package.json}
37
+ {One-line description}
39
38
 
40
39
  ## Installation
41
40
 
42
- pnpm add @simplysm/{package-name}
43
-
44
- **Peer Dependencies:** (if any)
41
+ ## Main Modules
45
42
 
46
- ## Configuration
43
+ ### {Category matching index.ts #region}
47
44
 
48
- {Only for setup patterns Provider wrapping, Tailwind preset, etc.}
49
- {Include brief code snippets for wiring, NOT per-component API}
45
+ - Description + code examples per export
50
46
 
51
- ## Source Index
47
+ ## Types
52
48
 
53
- ### {Category matching index.ts #region}
49
+ ## Dependencies (only when peer deps exist)
50
+ ```
54
51
 
55
- | Source | Exports | Description | Test |
56
- |--------|---------|-------------|------|
57
- | `src/path/to/File.tsx` | `ComponentA`, `ComponentB` | Brief one-line description | `File.test.tsx` |
58
- | `src/path/to/types.ts` | `TypeA`, `TypeB` | Type definitions for X | - |
52
+ ### docs/ Subfolder Rules
59
53
 
60
- ## License
61
- ```
54
+ When README exceeds ~500 lines, split detailed documentation into `docs/`:
62
55
 
63
- **Source index table rules:**
64
- - One row per `export *` statement in `index.ts`
65
- - Exports column: list all exported symbols from that file
66
- - Description column: brief one-line summary of what the file provides (enough for Claude Code to decide whether to read the source)
67
- - Test column: test file name if exists, `-` if not
68
- - Source paths relative to package root
56
+ - README.md becomes an **overview/index** with links: `[functionName](docs/category.md#anchor)`
57
+ - docs/ files contain detailed descriptions, full code examples, parameter tables
58
+ - File organization follows index.ts `#region` (e.g., `docs/types.md`, `docs/utils.md`)
69
59
 
70
- ## General Rules
60
+ When README is under ~500 lines, keep everything inline.
71
61
 
72
- - Written in **English**
73
- - Sections follow `index.ts` `#region` structure
74
- - **Every `export *`** from `index.ts` must appear in source index
75
- - No changelog, version history, or "recently updated" sections
76
- - Configuration section: only setup/wiring patterns, NOT per-component API
62
+ **If docs/ already exists, maintain and update it. Do not remove an existing docs/ structure.**
77
63
 
78
64
  ## Single Package Mode
79
65
 
@@ -84,66 +70,62 @@ If not starting with `packages/`, prepend it.
84
70
 
85
71
  ### Step 2: Build Export Map (Source of Truth)
86
72
 
87
- 1. Read `<pkg-path>/src/index.ts` — get all `export *` statements and their `#region` grouping
88
- 2. For each `export * from "./path/to/file"`:
89
- - Resolve actual file path (`.ts`, `.tsx`)
90
- - Read file to extract exported symbol names
91
- - Write a brief one-line description of what the file provides
92
- - Check if test file exists (e.g., `File.test.tsx`, `File.spec.ts`)
73
+ 1. Read `<pkg-path>/src/index.ts` — get all exports and their `#region` grouping
74
+ 2. For each exported module, read the source file to extract:
75
+ - Function signatures (params, return type, overloads)
76
+ - Class public API (constructor, methods, properties)
77
+ - Type/interface definitions
78
+ - Default values, options objects
93
79
 
94
- ### Step 3: Build Index Map
80
+ ### Step 3: Build Documentation Map
95
81
 
96
- Read `<pkg-path>/README.md` (if exists).
97
- Extract existing source index table entries — map each source file to its row.
82
+ Read `<pkg-path>/README.md` (if exists). If docs/ exists, read those files too.
83
+ Map each documented item to its current documentation content.
98
84
 
99
85
  ### Step 4: Diff and Report
100
86
 
101
- Compare export map (Step 2) against index map (Step 3):
87
+ Compare export map (Step 2) against documentation map (Step 3):
102
88
 
103
- | Status | Meaning |
104
- |--------|---------|
105
- | **ADDED** | `export *` in index.ts but source file not in README index |
106
- | **REMOVED** | In README index but no longer in index.ts |
107
- | **CHANGED** | Same file, but exported symbols changed |
108
- | **OK** | Index entry matches source |
89
+ | Status | Meaning |
90
+ | ----------- | ------------------------------------ |
91
+ | **ADDED** | Exported in source but not in README |
92
+ | **REMOVED** | In README but no longer exported |
93
+ | **CHANGED** | Both exist but API signature differs |
94
+ | **OK** | Documentation matches source |
109
95
 
110
96
  **Report to user before editing:**
111
97
 
112
98
  ```
113
- ADDED (2):
114
- - src/providers/i18n/I18nContext.tsx (useI18n, useI18nOptional, I18nProvider)
115
- - src/providers/i18n/I18nContext.types.ts (I18nContextValue, I18nConfigureOptions, FlatDict)
99
+ ADDED (3):
100
+ - strToCamelCase (from utils/str.ts)
101
+ - objGetChainValueByDepth (from utils/obj.ts)
102
+ - ZipArchiveProgress type (from zip/sd-zip.ts)
116
103
 
117
104
  REMOVED (1):
118
- - src/components/SelectList.tsx (no longer exported)
105
+ - oldFunction (no longer exported)
119
106
 
120
- CHANGED (1):
121
- - src/features/shared-data/SharedDataSelectList.tsx: exports changed
107
+ CHANGED (2):
108
+ - objMerge: added `deep` parameter
109
+ - Set.toggle: added `addOrDel` optional parameter
122
110
 
123
- OK: 42 entries unchanged
111
+ OK: 45 items unchanged
124
112
  ```
125
113
 
126
114
  **Wait for user confirmation before proceeding to edit.**
127
115
 
128
116
  ### Step 5: Apply Updates
129
117
 
130
- - **ADDED**: Add row to source index table in the section matching the item's `#region` in index.ts.
131
- - **REMOVED**: Delete row from source index table.
132
- - **CHANGED**: Update exports column.
118
+ - **ADDED**: Write documentation matching existing style. Place in the section matching the item's `#region` in index.ts. Include description + code example with import path.
119
+ - **REMOVED**: Delete the documentation entry.
120
+ - **CHANGED**: Update existing entry to match current API. Preserve code examples if still valid.
133
121
  - **OK**: Do not touch.
134
122
 
135
- ### Step 6: Cleanup Check
123
+ **If README uses docs/ links**: update the corresponding docs/ file, not just README.
136
124
 
137
- If `docs/` subfolder exists from old full-documentation approach, report it:
138
-
139
- ```
140
- NOTE: docs/ subfolder exists with old-style full documentation.
141
- Source index approach makes docs/ redundant.
142
- Files: docs/form-controls.md, docs/providers.md, ...
143
- Remove docs/ folder? (requires user confirmation)
144
- ```
125
+ ### Step 6: Size Check
145
126
 
146
- **Do not auto-delete docs/ always ask user first.**
127
+ After updates, if README exceeds ~500 lines and no docs/ exists:
128
+ suggest splitting to the user (do not auto-split without confirmation).
147
129
 
148
130
  ## Batch Mode
149
131
 
@@ -155,33 +137,31 @@ When `$ARGUMENTS` is empty:
155
137
  **Per-package subagent prompt template:**
156
138
 
157
139
  ```
158
- Update README.md source index for package {pkg-name} at {pkg-path}.
140
+ Update README.md for package {pkg-name} at {pkg-path}.
159
141
 
160
- PURPOSE: README.md is a source file index. @simplysm/* packages ship .ts source + tests.
161
- Claude Code reads source files directly. README tells Claude WHICH files to read.
142
+ PURPOSE: README.md is the sole API documentation source for Claude Code.
143
+ Every exported symbol must be documented. Claude Code does NOT read JSDoc.
162
144
 
163
145
  STEPS:
164
- 1. Read {pkg-path}/src/index.ts — get all `export *` statements and #region grouping.
165
- 2. For each export, resolve source file path and find test file.
166
- 3. Read each source file to extract exported symbol names.
167
- 4. Read {pkg-path}/README.md (if exists).
168
- 5. Compare exports vs README source index:
169
- - ADDED: add row to source index table.
170
- - REMOVED: delete row.
171
- - CHANGED: update exports/description column.
146
+ 1. Read {pkg-path}/src/index.ts — get all exports and #region grouping.
147
+ 2. For each export, read the source file for signatures, classes, types.
148
+ 3. Read {pkg-path}/README.md (and docs/ if exists).
149
+ 4. Compare exports vs documentation:
150
+ - ADDED (in source, not in README): add documentation with description + code example.
151
+ Include import path: import { X } from "@simplysm/{pkg-name}"
152
+ - REMOVED (in README, not in source): delete documentation.
153
+ - CHANGED (both exist, API differs): update to match current API.
172
154
  - OK: don't touch.
173
- 6. Section organization follows index.ts #region structure.
174
- 7. Write in English. No changelog sections.
175
- 8. If README doesn't exist, create with structure:
155
+ 5. Section organization follows index.ts #region structure.
156
+ 6. Write in English. No changelog sections.
157
+ 7. If README doesn't exist, create with standard structure:
176
158
  # @simplysm/{pkg-name}
177
159
  {description from package.json}
178
160
  ## Installation
179
- ## Source Index (tables per #region)
180
- ## License
181
- 9. Do NOT write prop tables, code examples, or type definitions.
182
- Source index table only: Source | Exports | Description | Test
183
- Description: brief one-line summary of what the file provides.
184
- 10. Report: list of ADDED/REMOVED/CHANGED items.
161
+ ## Main Modules (sections per #region)
162
+ ## Types
163
+ 8. If docs/ subfolder exists, update those files too.
164
+ 9. Report: list of ADDED/REMOVED/CHANGED items.
185
165
  ```
186
166
 
187
167
  **Project root subagent prompt:**
@@ -198,14 +178,14 @@ Report what was changed.
198
178
 
199
179
  ## Common Mistakes
200
180
 
201
- | Mistake | Fix |
202
- |---------|-----|
203
- | Writing prop tables or code examples | README is a source index — Claude reads source files for API details |
204
- | Missing or vague Description | Each row needs a brief description so Claude can decide whether to read the file |
205
- | Skipping exports from index.ts | Every `export *` must appear in the source index |
206
- | Putting per-component API in Configuration | Configuration = setup patterns only (Provider tree, Tailwind preset) |
207
- | Arbitrary section reorganization | Follow index.ts `#region` structure |
208
- | Writing in Korean | README must be in English |
209
- | Adding changelog sections | Never add version history |
210
- | Editing before reporting diff | Always report and wait for confirmation |
211
- | Auto-deleting docs/ folder | Report docs/ existence, ask user before removing |
181
+ | Mistake | Fix |
182
+ | ------------------------------------- | ------------------------------------------------------------------- |
183
+ | Skipping exports with @internal JSDoc | Document ALL exports — Claude Code doesn't read JSDoc |
184
+ | Rewriting OK sections | Only touch ADDED/REMOVED/CHANGED items |
185
+ | Ignoring existing docs/ structure | If docs/ exists, update those files too |
186
+ | Arbitrary section reorganization | Follow index.ts `#region` structure |
187
+ | Missing import paths in examples | Always: `import { X } from "@simplysm/..."` |
188
+ | Writing in Korean | README must be in English |
189
+ | Adding changelog sections | Never add version history |
190
+ | Editing before reporting diff | Always report ADDED/REMOVED/CHANGED and wait for confirmation |
191
+ | Destroying docs/ link format | If README uses `[name](docs/file.md#anchor)`, preserve that pattern |
@@ -9,104 +9,100 @@ description: "Comprehensive multi-perspective code review (explicit invocation o
9
9
 
10
10
  Perform a multi-perspective code review of a package or specified path, producing a comprehensive report. **Analysis only — no code modifications.**
11
11
 
12
- Analyzes code via the built-in Explore agent, then runs up to 4 subagents in parallel for specialized review. Collects subagent results, verifies each finding against actual code, and writes the final report.
12
+ Dispatches up to 3 reviewer agents in parallel using prompt templates. Each agent independently explores the codebase from its own perspective. Collects results, verifies findings against actual code, and compiles the final report.
13
13
 
14
14
  ## Usage
15
15
 
16
- - `/sd-review packages/solid` — review source code at the given path
16
+ - `/sd-review packages/solid` — full review (all 3 perspectives)
17
+ - `/sd-review packages/solid focus on bugs` — selective review based on request
17
18
  - `/sd-review` — if no argument, ask the user for the target path
18
19
 
19
- ## When to Use
20
-
21
- - Before merging major features or after significant refactoring
22
- - When assessing overall code quality of a package
23
- - When onboarding to unfamiliar code and want a quality overview
24
-
25
- **When NOT to use:**
26
-
27
- - Single-file or trivial changes (typo, config tweak)
28
- - When you need code modifications (sd-review is analysis-only)
29
-
30
20
  ## Target Selection
31
21
 
32
- - With argument: `/sd-review packages/solid` — review source code at the given path
22
+ - With argument: review source code at the given path
33
23
  - Without argument: ask the user for the target path
34
24
 
35
25
  **Important:** Review ALL source files under the target path. Do not use git status or git diff to limit scope.
36
26
 
37
- ## Reviewer Agents
27
+ ## Reviewer Perspectives
38
28
 
39
- Run subagents in parallel via the Task tool:
29
+ | Reviewer | Prompt Template | Perspective |
30
+ |----------|----------------|-------------|
31
+ | **Code Reviewer** | `code-reviewer-prompt.md` | Correctness & Safety — bugs, security, logic errors |
32
+ | **API Reviewer** | `api-reviewer-prompt.md` | Usability & DX — naming, types, consistency |
33
+ | **Code Simplifier** | `code-simplifier-prompt.md` | Maintainability — complexity, duplication, structure |
40
34
 
41
- | Agent Type | Role | Condition |
42
- | ---------------------- | --------------------------------------------------- | ---------------------------------------------------------- |
43
- | `sd-code-reviewer` | Bugs, security, logic errors, convention issues | Always |
44
- | `sd-code-simplifier` | Complexity, duplication, readability issues | Always |
45
- | `sd-api-reviewer` | DX/usability, naming, type hints | Always |
46
- | `sd-security-reviewer` | ORM SQL injection, input validation vulnerabilities | When target path contains ORM queries or service endpoints |
35
+ ## Reviewer Selection
47
36
 
48
- ## Workflow
37
+ By default, run **all 3 reviewers**. If the user specifies a focus in natural language, select only the relevant reviewer(s):
49
38
 
50
- ### Step 1: Code Analysis via Explore Agent
39
+ | User says | Run |
40
+ |-----------|-----|
41
+ | "bugs", "security", "safety" | Code Reviewer only |
42
+ | "API", "naming", "types", "DX" | API Reviewer only |
43
+ | "complexity", "duplication", "structure", "maintainability" | Code Simplifier only |
44
+ | "bugs and API" | Code Reviewer + API Reviewer |
45
+ | (no specific focus) | All 3 |
51
46
 
52
- Invoke the built-in Explore agent via the Task tool to analyze the target path:
47
+ Use judgment for ambiguous requests. When in doubt, run all 3.
53
48
 
54
- ```
55
- Task(subagent_type=Explore)
56
- Prompt: "very thorough" analysis of <target-path>:
57
- - Entry points, core files, module boundaries
58
- - Call chains, data transformations, state changes
59
- - Abstraction layers, design patterns, dependency graph
60
- - Error handling, public API surface
61
- ```
49
+ ## Workflow
62
50
 
63
- This runs in a **separate context**, so it does not consume the main context window.
51
+ ### Step 1: Dispatch Reviewers
64
52
 
65
- ### Step 2: Dispatch Analysis to Reviewers
53
+ Read the prompt template files from this skill's directory. Replace `[TARGET_PATH]` with the actual target path. Then dispatch using `Agent(general-purpose)`:
66
54
 
67
- Run subagents **in parallel** via the Task tool. Include the Explore analysis results in each subagent's prompt:
55
+ ```
56
+ Agent(subagent_type=general-purpose, prompt=<filled template>)
57
+ ```
68
58
 
69
- - **sd-code-reviewer**: Based on the analysis, find bugs, security vulnerabilities, logic errors, and convention issues. Each finding must include **file:line** and **evidence**.
70
- - **sd-code-simplifier**: Based on the analysis, find unnecessary complexity, code duplication, and readability issues. Each finding must include **file:line** and **evidence**. **No code modifications.**
71
- - **sd-api-reviewer**: Based on the analysis, review API intuitiveness, naming consistency, type hints, error messages, and configuration complexity. Each finding must include **file:line** and **evidence**.
72
- - **sd-security-reviewer** _(conditional)_: If the Explore analysis reveals ORM queries (`orm-common`, `orm-node`, query builders, `expr.eq`, `.where()`, `.result()`) or service endpoints (`ServiceServer`, RPC handlers), also dispatch this agent. Based on the analysis, find SQL injection risks, missing input validation, and unvalidated user input reaching ORM queries. Each finding must include **file:line** and **evidence**.
59
+ Run selected reviewers **in parallel** (multiple Agent calls in a single message).
73
60
 
74
- ### Step 3: Verify Issues
61
+ ### Step 2: Verify Findings
75
62
 
76
- After collecting results from all 3 subagents, verify each issue against the actual code:
63
+ After collecting results from all reviewers, **Read the actual code** for each finding and verify:
77
64
 
78
- - **Valid**: the issue is real → include in the report
65
+ - **Valid**: the issue is real AND within scope → include in the report
66
+ - **Invalid — self-contradicted**: the reviewer's own analysis shows the issue is mitigated (e.g., "exploitability is limited because..."). Drop it.
67
+ - **Invalid — type-only**: reports a type definition as a runtime issue without showing actual runtime code that triggers it. Drop it.
68
+ - **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 (bugs→Code, API→API, structure→Simplifier).
70
+ - **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
+ - **Invalid — severity inflated**: downgrade or drop findings where the stated severity doesn't match the actual impact.
79
72
  - **Invalid — already handled**: handled elsewhere in the codebase (provide evidence)
80
73
  - **Invalid — intentional pattern**: by-design architectural decision
81
74
  - **Invalid — misread**: the reviewer misinterpreted the code
82
75
 
83
- ### Step 4: Final Report
76
+ ### Step 3: Final Report
84
77
 
85
- Compile only **verified findings** into a comprehensive report.
78
+ Compile only **verified findings** grouped by severity (not by reviewer):
86
79
 
87
- ### Report Structure
80
+ ```
81
+ ## Review Report: <target-path>
88
82
 
89
- | Section | Priority | Source |
90
- | -------------------------------- | -------- | --------------------------------------------------------------- |
91
- | **Architecture Summary** | — | Explore analysis |
92
- | **Critical Issues** | P0 | Bugs, security vulnerabilities |
93
- | **Security Issues** | P0 | SQL injection, input validation (when sd-security-reviewer ran) |
94
- | **Quality Issues** | P1 | Logic errors, missing error handling, performance |
95
- | **DX/Usability Issues** | P2 | API intuitiveness, naming, type hints |
96
- | **Simplification Opportunities** | P3 | Complexity removal, duplicate code, abstractions |
97
- | **Convention Issues** | P4 | Project convention mismatches |
83
+ ### CRITICAL
84
+ [verified critical findings from all reviewers]
98
85
 
99
- Each issue includes **file:line**, **description**, and **suggestion**.
86
+ ### WARNING
87
+ [verified warning findings from all reviewers]
88
+
89
+ ### INFO
90
+ [verified info findings from all reviewers]
91
+
92
+ ### Invalid Findings Summary (optional)
93
+ [findings filtered out and why]
94
+ ```
100
95
 
101
- Optionally include an **Invalid Findings Summary** appendix showing which findings were filtered out and why.
96
+ Each finding includes: **source reviewer**, **file:line**, **evidence**, **issue**, and **suggestion**.
102
97
 
103
98
  ## Common Mistakes
104
99
 
105
- | Mistake | Fix |
106
- | ------------------------------------ | --------------------------------------------------- |
107
- | Using git diff to limit review scope | Review ALL source files under target path |
108
- | Skipping verification step | Always verify subagent findings against actual code |
109
- | Reporting unverified issues | Only include verified findings in final report |
100
+ | Mistake | Fix |
101
+ |---------|-----|
102
+ | Using git diff to limit review scope | Review ALL source files under target path |
103
+ | Skipping verification step | Always verify reviewer findings against actual code |
104
+ | Reporting unverified issues | Only include verified findings in final report |
105
+ | Running all reviewers for focused requests | Match reviewer selection to user's request |
110
106
 
111
107
  ## Completion Criteria
112
108
 
@@ -0,0 +1,90 @@
1
+ # API Reviewer Prompt
2
+
3
+ Template for `Agent(general-purpose)`. Fill in `[TARGET_PATH]`.
4
+
5
+ ```
6
+ You are reviewing a library's public API for developer experience (DX).
7
+ Your question: "Would a first-time developer be confused or make mistakes using this API?"
8
+
9
+ ## Target
10
+
11
+ Review ALL source files at [TARGET_PATH].
12
+
13
+ ## Step 1: List all source files
14
+
15
+ Use Glob to list all .ts files under the target path (exclude node_modules, dist).
16
+
17
+ ## Step 2: Map the public API surface
18
+
19
+ - Read index.ts to list all exports (types, functions, constants)
20
+ - Read each exported type/interface/function definition
21
+ - Read test files and consumer code to see actual usage patterns
22
+
23
+ ## Step 3: Find issues
24
+
25
+ Look for:
26
+ - Naming consistency: same concept with different names, inconsistent prefix/suffix
27
+ - Intuitiveness: behavior can't be predicted from the name alone
28
+ - Type design: insufficient types for autocompletion, `any` in public interfaces, generic inference failures
29
+ - Defaults: basic use cases requiring excessive configuration
30
+ - Pattern consistency: similar tasks requiring different patterns
31
+
32
+ Important: Internal consistency takes priority over external standards.
33
+ Before suggesting a naming change, verify the existing pattern across ALL similar
34
+ components in the library. Do NOT suggest external conventions that break internal consistency.
35
+
36
+ Do NOT report:
37
+ - Bugs, security, logic errors, race conditions
38
+ - Code complexity, duplication, readability
39
+ - Do NOT use WebSearch to compare with external libraries
40
+ - TypeScript type system limitations that require workarounds (e.g., discriminated unions not narrowing due to template literals) — these are language constraints, not API design flaws
41
+ - Naming preferences where the current name is used consistently across the codebase — consistency > personal preference
42
+ - Minor field duplication in small interfaces (< 10 fields) where extraction adds indirection without real benefit
43
+
44
+ ## Step 4: Self-verify before reporting
45
+
46
+ Before including ANY finding, verify:
47
+
48
+ 1. **Severity check**: CRITICAL = developers WILL write wrong code because of this API. Not "could theoretically be confusing."
49
+ 2. **Consistency check**: Before suggesting a rename, search ALL usages. If the name is used consistently everywhere, it's NOT a finding.
50
+ 3. **Scope check**: Only report on the PUBLIC API of the target package. Do not report on how consumers should use it differently.
51
+
52
+ **Quality over quantity: 3 verified findings > 10 maybe-findings.**
53
+
54
+ ## Constraints
55
+
56
+ - Analysis only. Do NOT modify any files.
57
+ - Only report issues with real evidence from the code.
58
+ - CRITICAL severity requires proof that the current API actively misleads — not just "could be better."
59
+
60
+ ## Output Format
61
+
62
+ Use this exact format for every finding:
63
+
64
+ ### [CRITICAL|WARNING|INFO] title
65
+
66
+ - **File**: path/to/file.ts:42
67
+ - **Evidence**: what you observed (include code snippet)
68
+ - **Issue**: what the problem is
69
+ - **Suggestion**: how to improve it
70
+
71
+ Severity:
72
+ - CRITICAL: API misleads developers or types are insufficient for correct usage
73
+ - WARNING: Significant DX friction — unnecessary complexity or inconsistency
74
+ - INFO: Minor improvement — better naming or defaults exist
75
+
76
+ Start your report with:
77
+
78
+ ## API Review Results
79
+
80
+ ### Summary
81
+ - Files reviewed: N
82
+ - Public API surface: brief description
83
+ - Findings: X CRITICAL, Y WARNING, Z INFO
84
+
85
+ ### Findings
86
+ [findings here]
87
+
88
+ ### Positive Observations
89
+ [what's already well-designed — keep these]
90
+ ```
@@ -0,0 +1,85 @@
1
+ # Code Reviewer Prompt
2
+
3
+ Template for `Agent(general-purpose)`. Fill in `[TARGET_PATH]`.
4
+
5
+ ```
6
+ You are reviewing code for correctness and safety.
7
+ Your question: "Does this code produce wrong results or pose risks?"
8
+
9
+ ## Target
10
+
11
+ Review ALL source files at [TARGET_PATH].
12
+
13
+ ## Step 1: List all source files
14
+
15
+ Use Glob to list all .ts files under the target path (exclude node_modules, dist).
16
+ This is your review scope — every file in this list must be examined.
17
+
18
+ ## Step 2: Understand the codebase
19
+
20
+ Read the project's CLAUDE.md for conventions. Then:
21
+ - Read index.ts to map the module structure
22
+ - Read each source file to understand logic flows, data transformations, error paths
23
+
24
+ ## Step 3: Find issues
25
+
26
+ Look for:
27
+ - Bugs: null/undefined risks, off-by-one, wrong conditions, missing return values
28
+ - Security: injection, XSS, auth/authz gaps, sensitive data exposure, input validation
29
+ - Race conditions: async ordering, shared state without synchronization
30
+ - Resource leaks: uncleared subscriptions/listeners, unclosed handles
31
+ - Error handling: swallowed exceptions, wrong fallbacks, missing propagation
32
+
33
+ Do NOT report:
34
+ - Naming consistency, API design, type quality (including `any` types)
35
+ - Code complexity, duplication, readability improvements
36
+ - Style preferences unless they cause actual bugs
37
+ - Type definitions alone — a type allowing `stack?: string` is NOT a security issue unless the runtime code actually sends it unsanitized
38
+ - Speculative future risks — "if config were changed to X, this would break" is not a finding
39
+ - Issues in code OUTSIDE the target path (e.g., how other packages consume these types)
40
+
41
+ ## Step 4: Self-verify before reporting
42
+
43
+ Before including ANY finding, ask yourself:
44
+
45
+ 1. **Is there runtime code here that actually triggers this?** (Not just a type definition)
46
+ 2. **Does the evidence contradict my conclusion?** (If you find a bound/limit that prevents the issue, drop it)
47
+ 3. **Is this within the target scope?** (Not about how other packages use this code)
48
+
49
+ If you write "in practice this is unlikely because..." or "exploitability is limited because..." — that means it's NOT a real finding. Drop it.
50
+
51
+ **Quality over quantity: 3 verified findings > 10 maybe-findings.**
52
+
53
+ ## Constraints
54
+
55
+ - Analysis only. Do NOT modify any files.
56
+ - Only report issues where the runtime behavior is demonstrably wrong or risky.
57
+ - If your own analysis shows the issue is mitigated, do NOT report it.
58
+
59
+ ## Output Format
60
+
61
+ Use this exact format for every finding:
62
+
63
+ ### [CRITICAL|WARNING|INFO] title
64
+
65
+ - **File**: path/to/file.ts:42
66
+ - **Evidence**: what you observed (include code snippet)
67
+ - **Issue**: what the problem is
68
+ - **Suggestion**: how to fix it
69
+
70
+ Severity:
71
+ - CRITICAL: Will cause bugs, outages, or security breaches
72
+ - WARNING: Real problem that can occur in practice
73
+ - INFO: Defensive improvement, low risk
74
+
75
+ Start your report with:
76
+
77
+ ## Code Review Results
78
+
79
+ ### Summary
80
+ - Files reviewed: N
81
+ - Findings: X CRITICAL, Y WARNING, Z INFO
82
+
83
+ ### Findings
84
+ [findings here]
85
+ ```