ts-reviewer 1.2.1 → 2.0.0
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/README.md +39 -5
- package/dist/cli.js +10 -12
- package/dist/cli.js.map +1 -1
- package/dist/hash.js +3 -9
- package/dist/hash.js.map +1 -1
- package/dist/incoming.js +9 -15
- package/dist/incoming.js.map +1 -1
- package/dist/index.js +24 -30
- package/dist/index.js.map +1 -1
- package/dist/io.js +12 -20
- package/dist/io.js.map +1 -1
- package/dist/meta.js +5 -12
- package/dist/meta.js.map +1 -1
- package/dist/paths.js +17 -24
- package/dist/paths.js.map +1 -1
- package/dist/prompt.js +17 -23
- package/dist/prompt.js.map +1 -1
- package/dist/updatePolicy.js +1 -4
- package/dist/updatePolicy.js.map +1 -1
- package/package.json +6 -5
- package/ts-reviewer/SKILL.md +177 -318
- package/ts-reviewer/references/architecture.md +84 -140
- package/ts-reviewer/references/async-patterns.md +46 -106
- package/ts-reviewer/references/boundary-validation.md +29 -56
- package/ts-reviewer/references/code-quality.md +63 -112
- package/ts-reviewer/references/dependency-hygiene.md +31 -47
- package/ts-reviewer/references/error-handling.md +27 -49
- package/ts-reviewer/references/fix-workflow.md +92 -295
- package/ts-reviewer/references/modernization.md +58 -138
- package/ts-reviewer/references/security.md +56 -118
- package/ts-reviewer/references/tsconfig.md +42 -92
- package/ts-reviewer/references/type-safety.md +66 -148
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-reviewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Install the TypeScript Code Reviewer skill for Claude Code, Codex, or Antigravity",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "https://github.com/VirtualMaestro/ts-reviewer"
|
|
@@ -15,12 +16,12 @@
|
|
|
15
16
|
"ts-reviewer/**"
|
|
16
17
|
],
|
|
17
18
|
"engines": {
|
|
18
|
-
"node": "
|
|
19
|
+
"node": "^24.0.0"
|
|
19
20
|
},
|
|
20
21
|
"scripts": {
|
|
21
22
|
"build": "tsc -p tsconfig.json",
|
|
22
23
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
-
"test": "npm run typecheck",
|
|
24
|
+
"test": "npm run typecheck && node --test cnlp/skill-format.test.js",
|
|
24
25
|
"dev": "npm run build && node --enable-source-maps dist/cli.js"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"ts-reviewer"
|
|
34
35
|
],
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"typescript": "
|
|
37
|
+
"@types/node": "^24.13.3",
|
|
38
|
+
"typescript": "~5.9.0"
|
|
38
39
|
}
|
|
39
40
|
}
|
package/ts-reviewer/SKILL.md
CHANGED
|
@@ -6,190 +6,206 @@ description: >
|
|
|
6
6
|
find issues, find bugs, fix issues, fix code smells, auto-fix, review and fix,
|
|
7
7
|
clean up code, tech debt, code health, security audit, modernize, review my changes,
|
|
8
8
|
review my PR, review last commit. Architecture review: --arch, --full, review architecture,
|
|
9
|
-
find refactoring opportunities, full audit. Pure TypeScript 5.9
|
|
9
|
+
find refactoring opportunities, full audit. Pure TypeScript 5.9.x, ES2024, Node 24 only.
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
mode: typescript_code_review
|
|
13
|
+
|
|
14
|
+
purpose:
|
|
15
|
+
- review a pure TypeScript codebase against `target_stack` in multiple passes, and write what it finds to a report
|
|
16
|
+
- apply the fixes named in that report, with compiler, linter, and test verification after each
|
|
17
|
+
|
|
18
|
+
target_stack:
|
|
19
|
+
- TypeScript 5.9.x
|
|
20
|
+
- `target` and `lib` ES2024
|
|
21
|
+
- Node 24, ESM, `module` and `moduleResolution` `nodenext`
|
|
22
|
+
- `tsc` emits to an output directory and Node runs the emitted JavaScript: a relative import carries the `.js` extension, and Node type-stripping is out of the model
|
|
23
|
+
- a pattern below this stack is a finding, and a feature above it is never recommended
|
|
24
|
+
|
|
25
|
+
inputs:
|
|
26
|
+
- the request, which carries the run mode, the domain set, and the scope mode
|
|
27
|
+
- the project `tsconfig.json`, `package.json`, and linter config
|
|
28
|
+
- the reference checklists under `references/`
|
|
29
|
+
|
|
30
|
+
preconditions:
|
|
31
|
+
- `code-smells.md` exists before fix mode runs: it is the work plan, and fix stops with an error when it is absent
|
|
32
|
+
|
|
33
|
+
scope:
|
|
34
|
+
- `.ts`, `.mts`, and `.cts` files are reviewed alike
|
|
35
|
+
- `.d.ts` files are reviewed by the Type Safety and Config domains only: a declaration has no runtime behavior
|
|
36
|
+
- `.tsx` is out of scope
|
|
37
|
+
- the analysis scope in a scoped mode is the diff file list, and the reading scope is wider
|
|
38
|
+
- read as read-only context: `tsconfig.json`, the configs it extends, and `package.json`
|
|
39
|
+
- read as read-only context: the files the scoped files import 1 level deep, and the shared types in `types.ts`, `*.d.ts`, `interfaces/`, `shared/`
|
|
40
|
+
|
|
41
|
+
forbidden_behaviors:
|
|
42
|
+
- do not write the report under `.claude/`: it stays visible when no Claude tooling is present
|
|
43
|
+
- do not commit and do not stage: the operator reviews the fixes and decides
|
|
44
|
+
- do not check framework code: the scope is pure TypeScript
|
|
45
|
+
- do not require `CONTEXT.md` or any other domain-doc file
|
|
46
|
+
- do not report an issue found in a context file
|
|
47
|
+
- do not improvise a suppression-directive severity: `references/type-safety.md` owns them
|
|
48
|
+
- do not flag a consistent project convention unless it is harmful
|
|
49
|
+
- do not report a finding without a snippet and a concrete fix: "Consider refactoring" is not a fix
|
|
50
|
+
- do not report a finding whose snippet is absent at the stated line, give or take 2 lines: re-locate it or drop it
|
|
51
|
+
- do not downgrade a finding the enclosing function or module already guards, validates, narrows, or comments: drop it
|
|
52
|
+
- do not report a finding you cannot defend from the code in front of you
|
|
53
|
+
- do not cite a link outside typescriptlang.org, developer.mozilla.org, and nodejs.org, or a path inside this skill: omit the `reference` field instead
|
|
54
|
+
- do not build a link from memory
|
|
55
|
+
- do not recommend anything outside `target_stack`
|
|
56
|
+
- do not justify a ban by naming the version that introduced the replacement: the stack is fixed
|
|
57
|
+
- do not emit the same file and line twice
|
|
58
|
+
- do not boost severity in `full` scope mode: all code is treated alike
|
|
59
|
+
- do not flag a config issue in a scoped mode unless `tsconfig.json` is in the diff
|
|
60
|
+
|
|
61
|
+
outputs:
|
|
62
|
+
- `code-smells.md` in the project root: the scan report, and the work plan fix reads
|
|
63
|
+
- the `## Architecture Opportunities` section of that report, only when Architecture is active and at least 1 candidate is found
|
|
64
|
+
- the audit trail in `code-smells.md` when any issue remains: BEFORE/AFTER for each fixed issue, a status tag for each failed, reverted, or skipped issue, the original entry for each untouched issue
|
|
65
|
+
- a regression test for each fix that is testable
|
|
66
|
+
|
|
67
|
+
run_modes:
|
|
68
|
+
|
|
69
|
+
| Run mode | The request says | What runs |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `scan` | review, find issues, audit, scan, check | the analysis, then the report |
|
|
72
|
+
| `fix` | fix issues, fix the report, apply fixes, fix code smells | the fixes named in the report, with verification |
|
|
73
|
+
| `auto` | review and fix, auto-fix, scan and fix, clean up | scan, then fix, then a re-scan |
|
|
31
74
|
|
|
32
|
-
|
|
75
|
+
domain_sets:
|
|
76
|
+
- read the explicit `--arch`, `--full`, and `--no-arch` flags in the request first, then the phrases below, then fall back to the default set
|
|
77
|
+
- Architecture is off in a default scan, and loads `references/architecture.md` only when it is active
|
|
33
78
|
|
|
34
|
-
| Flag
|
|
79
|
+
| Flag or phrase | Active domains |
|
|
35
80
|
|---|---|
|
|
36
|
-
|
|
|
37
|
-
| `--arch
|
|
38
|
-
| `--full
|
|
39
|
-
|
|
40
|
-
Parse order: check for explicit `--arch` / `--full` / `--no-arch` flags in the user's message first.
|
|
41
|
-
Fall back to phrase detection. If no flag or phrase matches → default domain set (no architecture).
|
|
42
|
-
|
|
43
|
-
Architecture domain is **off** in default scans. It loads `references/architecture.md` and adds
|
|
44
|
-
an `## Architecture Opportunities` section to `code-smells.md` only when active.
|
|
45
|
-
|
|
46
|
-
## Report File Location
|
|
47
|
-
|
|
48
|
-
- Always write to `code-smells.md` in the project root (not in `.claude/`)
|
|
49
|
-
This ensures the skill works in non-Claude environments and the file is visible regardless of tooling.
|
|
50
|
-
- Recommend the user adds `code-smells.md` to `.gitignore` — it's a review artifact
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## High-Level Workflows
|
|
55
|
-
|
|
56
|
-
### scan
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
Phase 1: Discovery -> understand project structure, config, scope
|
|
60
|
-
Phase 2: Diagnostics -> run tsc, linters, collect machine-reported issues
|
|
61
|
-
Phase 3: Analysis -> spin up specialized sub-agents (or run sequentially)
|
|
62
|
-
Phase 4: Report -> deduplicate, rank, write code-smells.md
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### fix
|
|
66
|
-
|
|
67
|
-
Read `references/fix-workflow.md` before executing fix mode.
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
Step 1: Read code-smells.md (must exist — error if missing)
|
|
71
|
-
Step 2: Detect test runner, run baseline tests
|
|
72
|
-
Step 3: Fix issues file-by-file, write regression tests, run tsc after each file
|
|
73
|
-
Step 4: Run linter, fix lint errors
|
|
74
|
-
Step 5: Run full test suite, compare with baseline, fix regressions
|
|
75
|
-
Step 6: Verification loop — repeat tsc + lint + tests up to 5 iterations
|
|
76
|
-
Step 7: Update code-smells.md (remove fixed, mark failed)
|
|
77
|
-
Do NOT commit, do NOT stage
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### auto
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
1. Run scan -> writes code-smells.md
|
|
84
|
-
2. Show summary to user, ask "proceed with fix?"
|
|
85
|
-
3. If yes -> run fix (reads references/fix-workflow.md for full protocol)
|
|
86
|
-
4. If ALL issues fixed -> delete code-smells.md, report success
|
|
87
|
-
5. If some remain -> code-smells.md stays as audit trail (fixed + remaining)
|
|
88
|
-
Max 2 full scan-fix cycles. If issues persist after 2 cycles, stop.
|
|
89
|
-
```
|
|
81
|
+
| none | the 9 default domains: Type Safety, Security, Async Patterns, Modernization, Code Quality, Config, Boundary Validation, Error Handling, Dependency Hygiene |
|
|
82
|
+
| `--arch`, review architecture, find refactoring opportunities, deepening review | Architecture only |
|
|
83
|
+
| `--full`, full audit, full review, review everything | all 10 domains |
|
|
84
|
+
| `--no-arch` | the 9 default domains, and it wins over any flag or phrase above |
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
## Scope Modes
|
|
86
|
+
scope_modes:
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
If not specified, default to **full codebase**.
|
|
97
|
-
|
|
98
|
-
| User says | Scope mode |
|
|
88
|
+
| Scope mode | The request says |
|
|
99
89
|
|---|---|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
90
|
+
| `full` | review my code, audit the project, find issues, with no qualifier |
|
|
91
|
+
| `uncommitted` | review my changes, check uncommitted, what I changed |
|
|
92
|
+
| `branch` | review my PR, review my branch, diff against main |
|
|
93
|
+
| `commits:N` | review last commit, check last 3 commits, what did I break |
|
|
104
94
|
|
|
105
|
-
|
|
95
|
+
domains:
|
|
106
96
|
|
|
107
|
-
|
|
97
|
+
| Domain | Reference file | Focus |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| Type Safety | `references/type-safety.md` | `any`, casts, `!`, exhaustiveness, generics |
|
|
100
|
+
| Security | `references/security.md` | injection, prototype pollution, ReDoS, path traversal |
|
|
101
|
+
| Async Patterns | `references/async-patterns.md` | floating promises, race conditions, error propagation |
|
|
102
|
+
| Modernization | `references/modernization.md` | patterns below `target_stack` |
|
|
103
|
+
| Code Quality | `references/code-quality.md` | complexity, duplication, naming, dead code, testability |
|
|
104
|
+
| Config | `references/tsconfig.md` | `tsconfig.json` flags and module setup |
|
|
105
|
+
| Boundary Validation | `references/boundary-validation.md` | runtime validation at system edges, DTO and domain separation |
|
|
106
|
+
| Error Handling | `references/error-handling.md` | silent failures, throw hygiene, failure design |
|
|
107
|
+
| Dependency Hygiene | `references/dependency-hygiene.md` | `package.json`, versions, lockfiles, supply chain |
|
|
108
|
+
| Architecture | `references/architecture.md` | shallow modules, scattered concepts, coupling, dependency seams, layering |
|
|
109
|
+
|
|
110
|
+
workflow:
|
|
111
|
+
1. identify the run mode from `run_modes`
|
|
112
|
+
2. identify the active domain set from `domain_sets`
|
|
113
|
+
3. identify the scope mode from `scope_modes`, and default to `full` when the request names none
|
|
114
|
+
4. build the file list with the command in `scope_commands` for that scope mode
|
|
115
|
+
5. ask whether to fall back to `full` when a scoped mode yields 0 files
|
|
116
|
+
6. map the project tree in full, whatever the scope mode
|
|
117
|
+
7. read `tsconfig.json` and `references/tsconfig.md`, then audit the config flags
|
|
118
|
+
8. detect monorepo workspaces in `package.json` and `pnpm-workspace.yaml`, and every further tsconfig
|
|
119
|
+
9. audit the config that governs the files in scope, and name that config in the summary
|
|
120
|
+
10. read the linter config: `eslint.config.*`, `.eslintrc.*`, `biome.json`, `deno.json`
|
|
121
|
+
11. read `package.json` for the dependencies and the module type, and verify the TypeScript version, `engines.node`, and `@types/node` against `target_stack`
|
|
122
|
+
12. identify the entry points: `index.ts`, `main.ts`, the `exports` of `package.json`
|
|
123
|
+
13. collect the context files named in `scope:` when the scope mode is scoped
|
|
124
|
+
14. map the module relationships when Architecture is active: circular imports, deep relative imports, barrel-file cycles, feature slices, public entry points
|
|
125
|
+
15. scan `docs/adr/` for architectural decisions before proposing a change, and skip it silently when the directory is absent
|
|
126
|
+
16. report the discovery summary in the shape of `discovery_summary`
|
|
127
|
+
17. run `npx tsc --noEmit 2>&1 | head -200` over the full project, and report only the errors in the scoped files
|
|
128
|
+
18. run the linter: `npx eslint [files] --format json` or `npx biome check [files] --reporter json`
|
|
129
|
+
19. query the TypeScript LSP over MCP when it is reachable, then merge and deduplicate against the compiler output
|
|
130
|
+
20. triage every compiler and linter diagnostic through `severity_mapping`
|
|
131
|
+
21. read the reference file named in `domains` before each analysis pass
|
|
132
|
+
22. run only the passes whose domain is in the active domain set, as sub-agents shaped by `subagent_template` or one domain at a time
|
|
133
|
+
23. give every agent all the scoped files when scoped files <= 20, and split by directory above that, with the shared types visible to every agent
|
|
134
|
+
24. re-read the exact lines in the current file state before a finding enters the report
|
|
135
|
+
25. read the callers to verify a data flow a finding rests on, or mark its problem statement with "if <condition>" and cap its severity at Medium
|
|
136
|
+
26. downgrade a flagged non-High pattern that appears 5+ times across the codebase by 1 level, and report it once as a Recurring Pattern
|
|
137
|
+
27. boost a finding carrying `in_diff: true` by 1 level in a scoped mode, and mark it `High [boosted, was Medium — new code]`
|
|
138
|
+
28. deduplicate the findings on the same file, line, and issue, keeping 1
|
|
139
|
+
29. merge the findings 2 domains raise on the same file and line into 1 entry attributing both categories, at the higher severity
|
|
140
|
+
30. consolidate 3+ identical issues into 1 Recurring Pattern entry
|
|
141
|
+
31. keep the top 15 by severity and impact when a single domain produces more than 25 Medium or Low findings, and consolidate the rest into Recurring Pattern entries with their counts
|
|
142
|
+
32. write `code-smells.md` in the shape of `report_format`
|
|
143
|
+
33. sort by severity group, then category, then file path, and place `in_diff: true` before pre-existing in a scoped mode
|
|
144
|
+
34. show the top 10 and summarize the rest in a table when Medium and Low together hold more than 15 issues
|
|
145
|
+
35. recommend that the operator adds `code-smells.md` to `.gitignore`: it is a review artifact
|
|
146
|
+
36. read `references/fix-workflow.md` before fix mode executes: it holds the complete protocol
|
|
147
|
+
37. detect the test runner and run the baseline tests
|
|
148
|
+
38. fix the issues file by file, and run `tsc --noEmit` after each file
|
|
149
|
+
39. run the linter and fix the lint errors it reports
|
|
150
|
+
40. run the full test suite, compare it against the baseline, and fix the regressions
|
|
151
|
+
41. repeat the compiler, linter, and test verification with verification iterations <= 5
|
|
152
|
+
42. update `code-smells.md`: remove what is fixed, mark what failed
|
|
153
|
+
43. show the scan summary in auto mode, and ask the operator whether to proceed with the fix
|
|
154
|
+
44. re-scan after the fix in auto mode with full scan-fix cycles <= 2, and stop when issues persist after the second
|
|
155
|
+
45. delete `code-smells.md` and report success when every issue is fixed
|
|
156
|
+
|
|
157
|
+
scope_commands:
|
|
108
158
|
```bash
|
|
159
|
+
# full — every TypeScript file
|
|
109
160
|
npx glob '**/*.{ts,mts,cts}' --ignore '**/node_modules/**'
|
|
110
161
|
# or: git ls-files '*.ts' '*.mts' '*.cts'
|
|
111
|
-
```
|
|
112
162
|
|
|
113
|
-
|
|
114
|
-
```bash
|
|
163
|
+
# uncommitted — staged, unstaged, and untracked
|
|
115
164
|
git diff --name-only HEAD -- '*.ts' '*.mts' '*.cts'
|
|
116
165
|
git ls-files --others --exclude-standard -- '*.ts' '*.mts' '*.cts'
|
|
117
|
-
```
|
|
118
166
|
|
|
119
|
-
|
|
120
|
-
```bash
|
|
167
|
+
# branch — the current branch against its base
|
|
121
168
|
BASE=$(git rev-parse --verify main 2>/dev/null && echo main || echo master)
|
|
122
169
|
git diff --name-only "$BASE"...HEAD -- '*.ts' '*.mts' '*.cts'
|
|
123
170
|
git diff --name-only HEAD -- '*.ts' '*.mts' '*.cts'
|
|
124
|
-
```
|
|
125
171
|
|
|
126
|
-
|
|
127
|
-
```bash
|
|
172
|
+
# commits:N — the last N commits
|
|
128
173
|
git diff --name-only HEAD~N..HEAD -- '*.ts' '*.mts' '*.cts'
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
**File type policy:** `.mts`/`.cts` are reviewed like `.ts`. `.d.ts` files are reviewed
|
|
132
|
-
only by the Type Safety and Config domains (declarations have no runtime behavior).
|
|
133
|
-
`.tsx` is out of scope — pure TypeScript only, no frameworks.
|
|
134
|
-
|
|
135
|
-
### Context files (scoped reviews)
|
|
136
174
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
1. `tsconfig.json` (and extended configs)
|
|
140
|
-
2. Files imported by scoped files (one level deep)
|
|
141
|
-
3. Shared type definitions (`types.ts`, `*.d.ts`, `interfaces/`, `shared/`)
|
|
142
|
-
4. `package.json`
|
|
143
|
-
|
|
144
|
-
Context files are NOT analyzed for issues.
|
|
145
|
-
|
|
146
|
-
### Diff-aware severity boost (scoped modes only)
|
|
147
|
-
|
|
148
|
-
Collect changed hunks:
|
|
149
|
-
```bash
|
|
150
|
-
git diff -U0 [appropriate range] -- '*.ts' '*.mts' '*.cts' | grep '^@@'
|
|
175
|
+
# the changed hunks, for the severity boost in a scoped mode
|
|
176
|
+
git diff -U0 <range> -- '*.ts' '*.mts' '*.cts' | grep '^@@'
|
|
151
177
|
```
|
|
152
178
|
|
|
153
|
-
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Phase 1 — Discovery (scan mode)
|
|
161
|
-
|
|
162
|
-
1. **Detect domain set** from flags and phrases (see Domain Set section above).
|
|
163
|
-
|
|
164
|
-
2. **Detect scope mode** from user's request. Build file list.
|
|
165
|
-
If scoped mode yields 0 files, ask whether to fall back to full.
|
|
166
|
-
|
|
167
|
-
3. **Map project tree** — full structure regardless of scope.
|
|
168
|
-
|
|
169
|
-
4. **Read `tsconfig.json`**. Load `references/tsconfig.md` and audit config flags.
|
|
170
|
-
In scoped modes: only flag config if `tsconfig.json` is in diff or if full review.
|
|
171
|
-
Monorepos: detect workspaces (`workspaces` in package.json, `pnpm-workspace.yaml`) and
|
|
172
|
-
multiple tsconfigs (`tsconfig.build.json`, per-package configs, `references`). Audit the
|
|
173
|
-
config that actually governs the files in scope; note which config applies in the summary.
|
|
174
|
-
|
|
175
|
-
5. **Check for linter configs** — `eslint.config.*`, `.eslintrc.*`, `biome.json`, `deno.json`.
|
|
176
|
-
|
|
177
|
-
6. **Read `package.json`** — TS version, dependencies, module type.
|
|
179
|
+
severity_scale:
|
|
180
|
+
- these are the base severities in a scoped mode, before the boost
|
|
181
|
+
- a finding on an unchanged line keeps its severity: it is pre-existing tech debt, and it is informational
|
|
182
|
+
- an Architecture finding uses this scale with the criteria in the `severity_mapping` block of `references/architecture.md`
|
|
178
183
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
| Severity | Criteria | Examples |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| Highest | active bugs, security vulnerabilities, data loss | SQL injection, uncaught rejection, lying type predicate |
|
|
187
|
+
| High | bugs waiting to happen, edge-case failures | missing null check, `as` hiding a mismatch, floating promise |
|
|
188
|
+
| Medium | tech debt to clean up in context | `any` internally, missing exhaustive check, complex function |
|
|
189
|
+
| Low | style, to improve when convenient | naming, missing `readonly`, verbose type |
|
|
182
190
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
- Do NOT require `CONTEXT.md` or any domain-doc files.
|
|
191
|
+
severity_mapping:
|
|
192
|
+
- every compiler output line is an error: the TypeScript compiler emits no warnings
|
|
193
|
+
- map the linter severities conservatively: a project configures stylistic rules as `error`
|
|
187
194
|
|
|
188
|
-
|
|
195
|
+
| Diagnostic | Severity |
|
|
196
|
+
|---|---|
|
|
197
|
+
| a compiler error naming a runtime hazard: null or undefined access, wrong argument shape, missing property | Highest |
|
|
198
|
+
| a compiler hygiene error: unused local, unreachable code, implicit `any` on an internal | High |
|
|
199
|
+
| a linter rule matching a checklist item in a reference file | the checklist severity |
|
|
200
|
+
| a correctness-class linter rule: `no-floating-promises`, `no-misused-promises`, `no-unsafe-*` | High |
|
|
201
|
+
| any other linter `error` | Medium |
|
|
202
|
+
| any other linter `warning` or `info` | Low |
|
|
203
|
+
|
|
204
|
+
discovery_summary:
|
|
189
205
|
```
|
|
190
206
|
Project: <n>
|
|
191
207
|
Scope: full / uncommitted / branch (vs <base>) / commits:<N>
|
|
192
|
-
|
|
208
|
+
Stack: matches target_stack / deviates: <every pinned value that differs, of TS version, target, lib, module, moduleResolution, engines.node>
|
|
193
209
|
Module system: ESM / CJS
|
|
194
210
|
Strict mode: yes / partial / no
|
|
195
211
|
Linter: eslint / biome / none
|
|
@@ -197,63 +213,10 @@ Test runner: vitest / jest / mocha / node:test / none
|
|
|
197
213
|
Files in scope: <N> .ts files (+ <M> context files)
|
|
198
214
|
```
|
|
199
215
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
## Phase 2 — Diagnostics (scan mode)
|
|
203
|
-
|
|
204
|
-
### 2a. TypeScript compiler
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
npx tsc --noEmit 2>&1 | head -200
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
All output lines are errors (tsc emits no warnings). Triage each error:
|
|
211
|
-
- Indicates a runtime hazard (null/undefined access, wrong argument shape,
|
|
212
|
-
missing property) -> **Highest**
|
|
213
|
-
- Hygiene errors (unused locals, unreachable code, implicit any on internals) -> **High**
|
|
214
|
-
|
|
215
|
-
In scoped modes: run on full project, report only errors in scoped files.
|
|
216
|
-
|
|
217
|
-
### 2b. Linter
|
|
218
|
-
|
|
219
|
-
ESLint: `npx eslint [files] --format json 2>/dev/null | head -500`
|
|
220
|
-
Biome: `npx biome check [files] --reporter json 2>/dev/null | head -500`
|
|
221
|
-
|
|
222
|
-
Map linter severities conservatively — projects configure stylistic rules as `error`:
|
|
223
|
-
- Rule matches a checklist item in a reference file -> use the checklist severity
|
|
224
|
-
- Correctness-class rule (`no-floating-promises`, `no-misused-promises`,
|
|
225
|
-
`no-unsafe-*`) -> **High**
|
|
226
|
-
- Anything else: `error` -> **Medium**, `warning` -> **Low**, `info` -> **Low**
|
|
227
|
-
|
|
228
|
-
### 2c. LSP diagnostics (if available)
|
|
229
|
-
|
|
230
|
-
Query TypeScript LSP via MCP if accessible. Merge with compiler output, deduplicate.
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
## Phase 3 — Analysis (scan mode)
|
|
235
|
-
|
|
236
|
-
Read the corresponding reference file before each analysis pass.
|
|
237
|
-
|
|
238
|
-
Run only the agents whose domain is in the active domain set (see Domain Set section).
|
|
239
|
-
|
|
240
|
-
| Agent | Reference file | Focus |
|
|
241
|
-
|---|---|---|
|
|
242
|
-
| Type Safety | `references/type-safety.md` | `any`, casts, `!`, exhaustiveness, generics |
|
|
243
|
-
| Security | `references/security.md` | Injection, prototype pollution, ReDoS, path traversal |
|
|
244
|
-
| Async Patterns | `references/async-patterns.md` | Floating promises, race conditions, error propagation |
|
|
245
|
-
| Modernization | `references/modernization.md` | Outdated patterns vs TS 5.9+ idioms |
|
|
246
|
-
| Code Quality | `references/code-quality.md` | Complexity, duplication, naming, dead code, testability |
|
|
247
|
-
| Config | `references/tsconfig.md` | tsconfig.json flags and module setup |
|
|
248
|
-
| Boundary Validation | `references/boundary-validation.md` | Runtime validation at system edges, DTO/domain separation |
|
|
249
|
-
| Error Handling | `references/error-handling.md` | Silent failures, throw hygiene, failure design |
|
|
250
|
-
| Dependency Hygiene | `references/dependency-hygiene.md` | package.json, versions, lockfiles, supply chain |
|
|
251
|
-
| Architecture | `references/architecture.md` | Shallow modules, scattered concepts, coupling, dependency seams, layering |
|
|
252
|
-
|
|
253
|
-
### Sub-agent template (Claude Code)
|
|
254
|
-
|
|
216
|
+
subagent_template:
|
|
255
217
|
```
|
|
256
218
|
You are a specialized TypeScript reviewer focused on [DOMAIN].
|
|
219
|
+
Target stack: TypeScript 5.9.x, target and lib ES2024, Node 24, ESM under nodenext, tsc emitting JavaScript that Node runs — never recommend anything outside it.
|
|
257
220
|
Read the reference checklist: [REFERENCE_PATH]
|
|
258
221
|
Review these files: [FILE_LIST]
|
|
259
222
|
Context files (read-only, do NOT report issues): [CONTEXT_FILE_LIST]
|
|
@@ -271,43 +234,17 @@ Output JSONL, one object per line:
|
|
|
271
234
|
"fix": "Concrete recommendation with code example",
|
|
272
235
|
"auto_fixable": true|false,
|
|
273
236
|
"in_diff": true|false,
|
|
274
|
-
"reference": "optional — omit unless
|
|
237
|
+
"reference": "optional — omit unless the forbidden_behaviors allow it"
|
|
275
238
|
}
|
|
276
239
|
```
|
|
277
240
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
Go through each domain one at a time. Same JSON structure.
|
|
281
|
-
|
|
282
|
-
### File batching
|
|
283
|
-
|
|
284
|
-
- <= 20 scoped files: each agent reviews all files
|
|
285
|
-
- > 20 files: split by directory, ensure shared types visible to all agents
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Phase 4 — Report (scan mode)
|
|
290
|
-
|
|
291
|
-
### Processing
|
|
292
|
-
|
|
293
|
-
1. Apply severity boost (scoped modes only): `in_diff: true` -> boost +1 level.
|
|
294
|
-
2. Deduplicate: same file + line + issue -> keep one.
|
|
295
|
-
3. Merge overlapping: keep higher severity, note overlap. If two domains flag the same
|
|
296
|
-
file + line, merge into one entry attributing both categories — never emit twice.
|
|
297
|
-
4. Consolidate patterns: 3+ identical issues -> one "Recurring Pattern" entry.
|
|
298
|
-
5. Noise budget: if a single domain produces > 25 Medium/Low findings, keep its top 15
|
|
299
|
-
by severity and impact, consolidate the rest into Recurring Pattern entries with counts.
|
|
300
|
-
|
|
301
|
-
### Report structure
|
|
302
|
-
|
|
303
|
-
Write to `code-smells.md`:
|
|
304
|
-
|
|
241
|
+
report_format:
|
|
305
242
|
````markdown
|
|
306
243
|
# TypeScript Code Review Report
|
|
307
244
|
|
|
308
245
|
**Project:** <n>
|
|
309
246
|
**Reviewed:** <date>
|
|
310
|
-
**TypeScript
|
|
247
|
+
**Stack:** TypeScript 5.9.x / ES2024 / Node 24 — matches / <deviation>
|
|
311
248
|
**Scope:** Full / Uncommitted / Branch `x` vs `y` / Last N commits
|
|
312
249
|
**Files analyzed:** N (+ M context)
|
|
313
250
|
**Total issues:** N (X highest, Y high, Z medium, W low)
|
|
@@ -340,7 +277,6 @@ Write to `code-smells.md`:
|
|
|
340
277
|
## Pre-existing Issues (scoped modes only)
|
|
341
278
|
|
|
342
279
|
## Architecture Opportunities
|
|
343
|
-
(only when Architecture is in active domain set AND at least one candidate found — omit entirely otherwise)
|
|
344
280
|
|
|
345
281
|
### TITLE — Severity
|
|
346
282
|
|
|
@@ -357,83 +293,6 @@ Write to `code-smells.md`:
|
|
|
357
293
|
---
|
|
358
294
|
````
|
|
359
295
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
2. In scoped modes: `in_diff=true` sorts before pre-existing.
|
|
364
|
-
3. If > 15 issues in Medium/Low: show top 10, summarize rest in table.
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
## Fix Mode
|
|
369
|
-
|
|
370
|
-
**Read `references/fix-workflow.md` before executing.** It contains the complete
|
|
371
|
-
fix protocol: test runner detection, baseline capture, file-by-file fix strategy,
|
|
372
|
-
regression test writing, verification loop, and failure handling.
|
|
373
|
-
|
|
374
|
-
Key principles:
|
|
375
|
-
- Fix reads `code-smells.md` as its work plan (Terraform plan/apply pattern)
|
|
376
|
-
- Fixes are applied file-by-file with `tsc --noEmit` after each file
|
|
377
|
-
- Regression tests are written for each fix where testable
|
|
378
|
-
- Full test suite runs after all fixes, compared against baseline
|
|
379
|
-
- Max 5 verification iterations (tsc + lint + tests)
|
|
380
|
-
- NEVER commit, NEVER stage — user reviews and decides
|
|
381
|
-
- ALL fixed -> delete `code-smells.md` (clean slate)
|
|
382
|
-
- Some remain -> keep `code-smells.md` as audit trail with BEFORE/AFTER for fixed issues,
|
|
383
|
-
status tags for failed/reverted/skipped, and original entries for untouched issues
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## Severity Scale
|
|
388
|
-
|
|
389
|
-
| Level | Criteria | Examples |
|
|
390
|
-
|---|---|---|
|
|
391
|
-
| Highest | Active bugs, security vulns, data loss | SQL injection, uncaught rejection, lying type predicate |
|
|
392
|
-
| High | Bugs waiting to happen, edge-case failures | Missing null check, `as` hiding mismatch, floating promise |
|
|
393
|
-
| Medium | Tech debt to clean up in-context | `any` internally, missing exhaustive check, complex function |
|
|
394
|
-
| Low | Style — improve when convenient | Naming, missing readonly, verbose type |
|
|
395
|
-
|
|
396
|
-
In scoped modes: these are base severities before diff-aware boost.
|
|
397
|
-
|
|
398
|
-
Architecture findings use the same severity scale with domain-specific criteria.
|
|
399
|
-
See `references/architecture.md` → Severity Mapping for Architecture.
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
## Evidence Protocol
|
|
404
|
-
|
|
405
|
-
Every finding must survive verification before it enters the report:
|
|
406
|
-
|
|
407
|
-
1. **Re-read before reporting.** After drafting a finding, re-read the exact lines in the
|
|
408
|
-
current file state. The `snippet` must appear verbatim at the stated `line` (±2 lines).
|
|
409
|
-
If it doesn't, re-locate or drop the finding.
|
|
410
|
-
2. **Check the surrounding context.** If a guard, validation, type narrowing, or comment
|
|
411
|
-
within the enclosing function/module already handles the case, the finding is a false
|
|
412
|
-
positive — drop it, don't downgrade it.
|
|
413
|
-
3. **Confidence gate.** Report only findings you can defend with the code in front of you.
|
|
414
|
-
If a finding depends on runtime behavior you cannot see (external input actually reaching
|
|
415
|
-
a sink, concurrent callers actually existing), either verify the data flow by reading the
|
|
416
|
-
callers, or mark the finding's problem statement with "if <condition>" and cap severity
|
|
417
|
-
at Medium.
|
|
418
|
-
4. **References must be real.** The `reference` field is optional. Only cite
|
|
419
|
-
typescriptlang.org, developer.mozilla.org, nodejs.org, or a file path inside this skill.
|
|
420
|
-
Never construct URLs from memory for anything else — omit the field instead.
|
|
421
|
-
5. **Convention override.** If a flagged non-High pattern appears consistently 5+ times
|
|
422
|
-
across the codebase, treat it as an intentional convention: downgrade one severity level
|
|
423
|
-
and report it once as a Recurring Pattern, not per occurrence.
|
|
424
|
-
6. **Version gate.** Every finding that recommends newer syntax or APIs must state the
|
|
425
|
-
minimum TS/runtime version required, verified against the project's actual TS version,
|
|
426
|
-
`target`/`lib`, and runtime. Never recommend a feature the project cannot use.
|
|
427
|
-
|
|
428
|
-
---
|
|
429
|
-
|
|
430
|
-
## Important Guidelines
|
|
431
|
-
|
|
432
|
-
- **No framework checks.** Pure TypeScript only.
|
|
433
|
-
- **No false positives from intentional patterns.** Suppression-directive severities are
|
|
434
|
-
owned by `references/type-safety.md` (Suppression Directives) — follow it, don't improvise.
|
|
435
|
-
- **Respect project conventions.** Don't flag consistent patterns unless harmful.
|
|
436
|
-
- **Be concrete.** Every issue needs a snippet and a fix recommendation.
|
|
437
|
-
"Consider refactoring" is not a valid fix.
|
|
438
|
-
- **Don't flood with noise.** Consolidate identical issues into Recurring Patterns.
|
|
439
|
-
- **Scoped mode focus.** Prioritize diff issues. Pre-existing = informational only.
|
|
296
|
+
invocation:
|
|
297
|
+
- any agent: state the request in plain language, for example `review my TypeScript code` or `fix the report`
|
|
298
|
+
- add `--arch` or `--full` to that request to change the domain set
|