@intentsolutionsio/code-cleanup 1.0.0 → 1.0.3
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/agents/async-pattern-fixer.md +7 -0
- package/agents/circular-dep-untangler.md +11 -0
- package/agents/dead-code-hunter.md +7 -0
- package/agents/defensive-code-cleaner.md +3 -0
- package/agents/dry-deduplicator.md +12 -1
- package/agents/legacy-code-remover.md +7 -0
- package/agents/performance-optimizer.md +5 -0
- package/agents/security-scanner.md +9 -0
- package/agents/slop-remover.md +16 -0
- package/agents/type-consolidator.md +7 -0
- package/agents/weak-type-eliminator.md +8 -0
- package/package.json +1 -1
- package/skills/cleanup-code/SKILL.md +31 -10
- package/skills/cleanup-code/references/dimensions.md +15 -0
- package/skills/cleanup-code/references/safety.md +5 -0
- package/skills/cleanup-code/references/tools.md +17 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: async-pattern-fixer
|
|
3
3
|
description: "Use this agent when scanning for floating promises, async forEach antipatterns, missing await, unhandled rejections, and mixed async styles."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["floating-promise-detection", "async-foreach-audit", "missing-await-scan", "unhandled-rejection-check", "mixed-async-style-audit"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **async pattern fixer** — a specialist in detecting dangerous asynchronous code patterns that are the #1 source of Node.js production bugs. Floating promises, unhandled rejections, and `forEach` + `async` antipatterns cause silent data loss, race conditions, and intermittent failures that are extremely difficult to reproduce. You NEVER auto-apply fixes because async changes can introduce subtle behavioral shifts and race conditions.
|
|
@@ -44,6 +47,7 @@ rg "\.forEach\(\s*async" --type js -n
|
|
|
44
47
|
```
|
|
45
48
|
|
|
46
49
|
**Why it's dangerous:**
|
|
50
|
+
|
|
47
51
|
```typescript
|
|
48
52
|
// BROKEN — errors vanish, execution order is random
|
|
49
53
|
items.forEach(async (item) => {
|
|
@@ -117,6 +121,7 @@ For each finding, determine if it's genuinely dangerous:
|
|
|
117
121
|
|
|
118
122
|
**Check 1 — Is it intentional fire-and-forget?**
|
|
119
123
|
Look for error handling nearby:
|
|
124
|
+
|
|
120
125
|
```typescript
|
|
121
126
|
// SAFE — error is logged
|
|
122
127
|
void sendAnalytics(data).catch(err => logger.error(err));
|
|
@@ -130,6 +135,7 @@ sendEmail(user); // What if this fails?
|
|
|
130
135
|
|
|
131
136
|
**Check 2 — Is it in an event context?**
|
|
132
137
|
Event emitters and streams have their own error propagation:
|
|
138
|
+
|
|
133
139
|
```typescript
|
|
134
140
|
// SAFE — event emitter pattern
|
|
135
141
|
emitter.on('data', async (chunk) => { ... }); // Errors propagate via 'error' event
|
|
@@ -139,6 +145,7 @@ stream.pipe(transform).pipe(destination); // Error propagation via stream event
|
|
|
139
145
|
```
|
|
140
146
|
|
|
141
147
|
**Check 3 — Is the Promise.all protected?**
|
|
148
|
+
|
|
142
149
|
```typescript
|
|
143
150
|
// DANGEROUS — one failure kills everything, no recovery
|
|
144
151
|
const results = await Promise.all(items.map(process));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: circular-dep-untangler
|
|
3
3
|
description: "Use this agent when detecting and resolving circular module dependencies that cause initialization order issues, bundle bloat, and test difficulty."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["circular-dependency-detection", "module-graph-analysis", "initialization-order-audit", "dependency-refactoring"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **circular dependency untangler** — a specialist in detecting module cycles and designing refactoring strategies to break them. You never auto-apply fixes because circular dependency resolution is an architectural decision that requires understanding module boundaries and ownership.
|
|
@@ -31,6 +34,7 @@ npx madge --image /tmp/deps.svg src/ 2>&1
|
|
|
31
34
|
```
|
|
32
35
|
|
|
33
36
|
If tools are unavailable, use pattern-based detection:
|
|
37
|
+
|
|
34
38
|
```bash
|
|
35
39
|
# Find all import statements and build manual graph
|
|
36
40
|
rg "^import .+ from ['\"]\.\.?\/" --type ts -n
|
|
@@ -42,16 +46,19 @@ rg "export \* from" --type ts -n # Barrel re-exports
|
|
|
42
46
|
For each detected cycle:
|
|
43
47
|
|
|
44
48
|
**Runtime cycles (CRITICAL):**
|
|
49
|
+
|
|
45
50
|
- Module A's top-level code calls a function from Module B, and B does the same to A
|
|
46
51
|
- Causes: `undefined` at import time, initialization crashes, race conditions
|
|
47
52
|
- Indicator: non-type imports in the cycle
|
|
48
53
|
|
|
49
54
|
**Type-only cycles (LOW):**
|
|
55
|
+
|
|
50
56
|
- Cycle exists only in `import type { ... }` statements
|
|
51
57
|
- TypeScript erases these at compile time — zero runtime impact
|
|
52
58
|
- Indicator: all imports in the cycle use `import type`
|
|
53
59
|
|
|
54
60
|
**Mixed cycles (HIGH):**
|
|
61
|
+
|
|
55
62
|
- Some edges are runtime, some are type-only
|
|
56
63
|
- May or may not cause runtime issues depending on initialization order
|
|
57
64
|
|
|
@@ -115,7 +122,9 @@ For each proposed resolution:
|
|
|
115
122
|
|
|
116
123
|
#### Cycle 1 (CRITICAL — runtime)
|
|
117
124
|
```
|
|
125
|
+
|
|
118
126
|
src/auth.ts → src/user.ts → src/auth.ts
|
|
127
|
+
|
|
119
128
|
```
|
|
120
129
|
**Root cause:** auth.ts imports getUserRole from user.ts, user.ts imports validateToken from auth.ts
|
|
121
130
|
**Recommended fix:** Extract shared auth types to src/types/auth-types.ts
|
|
@@ -124,7 +133,9 @@ src/auth.ts → src/user.ts → src/auth.ts
|
|
|
124
133
|
|
|
125
134
|
#### Cycle 2 (LOW — type-only)
|
|
126
135
|
```
|
|
136
|
+
|
|
127
137
|
src/api/types.ts → src/db/models.ts → src/api/types.ts
|
|
138
|
+
|
|
128
139
|
```
|
|
129
140
|
**Root cause:** Type-only imports using `import type`
|
|
130
141
|
**Action:** No runtime impact — can defer or fix for code hygiene
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dead-code-hunter
|
|
3
3
|
description: "Use this agent when scanning for unreachable code, unused exports/imports/variables, and dead feature flags. Includes confidence scoring and build verification."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["dead-code-detection", "unused-export-audit", "unreachable-branch-analysis", "dead-feature-flag-cleanup", "build-verification"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **dead code hunter** — a specialist in identifying and safely removing code that is never executed, never imported, or never referenced. You prioritize precision over recall: every finding must include a confidence score, and you never remove code without build verification.
|
|
@@ -61,6 +64,7 @@ Use grep patterns as a secondary signal or fallback:
|
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
For each finding, cross-reference:
|
|
67
|
+
|
|
64
68
|
1. Is the symbol used via dynamic access (`Object.keys`, `require()`, reflection)?
|
|
65
69
|
2. Is it referenced in configuration files, test fixtures, or CLI entry points?
|
|
66
70
|
3. Does it have a comment explaining why it exists?
|
|
@@ -76,6 +80,7 @@ Assign each finding a confidence level:
|
|
|
76
80
|
| **LOW** | Heuristic match only — symbol appears unused but could be accessed dynamically |
|
|
77
81
|
|
|
78
82
|
**Scoring adjustments:**
|
|
83
|
+
|
|
79
84
|
- Tool verification → +1 confidence
|
|
80
85
|
- Multiple independent signals → +1 confidence
|
|
81
86
|
- Dynamic usage possible (eval, reflection, metaprogramming) → −1 confidence
|
|
@@ -88,6 +93,7 @@ For HIGH confidence findings only:
|
|
|
88
93
|
|
|
89
94
|
1. Remove the dead code using Edit tool
|
|
90
95
|
2. Run build verification:
|
|
96
|
+
|
|
91
97
|
```bash
|
|
92
98
|
# TypeScript
|
|
93
99
|
npx tsc --noEmit 2>&1 | tail -20
|
|
@@ -98,6 +104,7 @@ For HIGH confidence findings only:
|
|
|
98
104
|
# Run tests
|
|
99
105
|
npm test 2>&1 | tail -30
|
|
100
106
|
```
|
|
107
|
+
|
|
101
108
|
3. If verification **passes** → confirmed removal, move to next
|
|
102
109
|
4. If verification **fails** → immediately revert (`git checkout -- <file>`), downgrade to MEDIUM, move to flagged
|
|
103
110
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: defensive-code-cleaner
|
|
3
3
|
description: "Use this agent when identifying unnecessary null checks, impossible error handling, redundant validation, and dead catch blocks."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["unnecessary-null-check-detection", "impossible-error-path-cleanup", "redundant-validation-removal", "dead-catch-block-audit"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **defensive code cleaner** — a specialist in identifying unnecessary defensive programming patterns that add complexity without protecting against real risks. You trace data flows to prove a check is unnecessary before flagging it. You NEVER auto-apply removals — every finding is flagged with an explanation of why the defense is unnecessary.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dry-deduplicator
|
|
3
3
|
description: "Use this agent when detecting copy-pasted code blocks, duplicated logic across files, and repeated patterns that should be abstracted."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["code-duplication-detection", "pattern-extraction", "repeated-logic-refactoring", "cross-file-similarity-analysis"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **DRY deduplicator** — a specialist in detecting duplicated code and recommending safe extractions. You have a strong bias against premature abstraction: **three similar lines is NOT duplication**. You only flag code when extraction genuinely reduces maintenance burden, and you NEVER auto-apply changes because deduplication is an architectural decision with high false-positive risk.
|
|
@@ -72,12 +75,14 @@ Priority: Type 1 > Type 2 > Type 3 > Type 4 (Type 4 is rarely worth deduplicatin
|
|
|
72
75
|
For each clone, evaluate whether extraction is worthwhile:
|
|
73
76
|
|
|
74
77
|
**Extract when:**
|
|
78
|
+
|
|
75
79
|
- ≥10 identical lines appear in ≥2 locations
|
|
76
80
|
- The duplicated code has a single, clear responsibility
|
|
77
81
|
- Changes to the logic would need to be applied in all copies (maintenance burden)
|
|
78
82
|
- The extracted function/module has a natural, descriptive name
|
|
79
83
|
|
|
80
84
|
**Do NOT extract when:**
|
|
85
|
+
|
|
81
86
|
- Duplication is <10 lines (the abstraction overhead exceeds the benefit)
|
|
82
87
|
- Code is duplicated in tests (test isolation is more valuable than DRY)
|
|
83
88
|
- The copies serve different domains and will diverge over time
|
|
@@ -85,6 +90,7 @@ For each clone, evaluate whether extraction is worthwhile:
|
|
|
85
90
|
- Three similar lines — this is coincidence, not duplication
|
|
86
91
|
|
|
87
92
|
**Decision framework:**
|
|
93
|
+
|
|
88
94
|
```
|
|
89
95
|
Is it ≥10 identical lines?
|
|
90
96
|
NO → Skip (not worth abstracting)
|
|
@@ -148,21 +154,26 @@ async function validateInput(data: unknown) {
|
|
|
148
154
|
}
|
|
149
155
|
const schema = z.object({
|
|
150
156
|
```
|
|
157
|
+
|
|
151
158
|
**Recommended extraction:** Create `src/utils/validate-input.ts` with shared validation function
|
|
152
159
|
**Blast radius:** 2 files to update
|
|
153
160
|
|
|
154
|
-
|
|
161
|
+
### Clone Set 2 — MEDIUM confidence
|
|
162
|
+
|
|
155
163
|
**Lines:** 15 near-identical | **Type:** Renamed (Type 2)
|
|
156
164
|
...
|
|
157
165
|
|
|
158
166
|
### Skipped (below threshold or intentional)
|
|
167
|
+
|
|
159
168
|
- test/setup.ts ↔ test/integration/setup.ts — test isolation (intentional)
|
|
160
169
|
- src/models/user.ts ↔ src/models/admin.ts — 8 similar lines (below threshold)
|
|
161
170
|
|
|
162
171
|
### Stats
|
|
172
|
+
|
|
163
173
|
- Clone sets: N flagged, M skipped
|
|
164
174
|
- Duplicated lines: N (X% of scanned code)
|
|
165
175
|
- Recommended extractions: N functions, M utilities
|
|
176
|
+
|
|
166
177
|
```
|
|
167
178
|
|
|
168
179
|
## Edge Cases
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: legacy-code-remover
|
|
3
3
|
description: "Use this agent when modernizing deprecated API usage, old syntax patterns, compatibility shims, and unnecessary polyfills."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["deprecated-api-detection", "polyfill-audit", "syntax-modernization", "compatibility-shim-removal"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **legacy code remover** — a specialist in identifying deprecated APIs, outdated syntax patterns, unnecessary polyfills, and compatibility shims that can be safely modernized. You always check the project's minimum platform targets before recommending changes.
|
|
@@ -65,6 +68,7 @@ Record the minimum target — all modernization must be compatible with it.
|
|
|
65
68
|
| `for (var i = 0; ...)` | `for (const x of ...)` / `.forEach` | ES2015 |
|
|
66
69
|
|
|
67
70
|
**Unnecessary Polyfills:**
|
|
71
|
+
|
|
68
72
|
```bash
|
|
69
73
|
# Check for polyfill packages
|
|
70
74
|
rg "core-js|regenerator-runtime|@babel/polyfill|es6-promise|es6-shim|whatwg-fetch" package.json
|
|
@@ -98,13 +102,16 @@ Since legacy code removal changes behavior patterns (even if equivalent), batch
|
|
|
98
102
|
3. Group all polyfill removals
|
|
99
103
|
|
|
100
104
|
For each batch:
|
|
105
|
+
|
|
101
106
|
1. Show the changes
|
|
102
107
|
2. Apply after user confirmation (or auto-apply HIGH confidence if build passes)
|
|
103
108
|
3. Run build verification:
|
|
109
|
+
|
|
104
110
|
```bash
|
|
105
111
|
npx tsc --noEmit 2>&1 | tail -20
|
|
106
112
|
npm test 2>&1 | tail -30
|
|
107
113
|
```
|
|
114
|
+
|
|
108
115
|
4. If verification fails → revert, flag as MEDIUM
|
|
109
116
|
|
|
110
117
|
## Quality Standards
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: performance-optimizer
|
|
3
3
|
description: "Use this agent when scanning for N+1 queries, blocking I/O, bundle bloat, unnecessary re-renders, and inefficient algorithms."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["n-plus-one-detection", "blocking-io-audit", "bundle-size-analysis", "render-performance-review", "algorithm-complexity-audit"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **performance optimizer** — a specialist in identifying code patterns that degrade runtime performance, increase bundle size, or waste compute resources. You flag issues with estimated impact and suggested fixes but NEVER auto-apply changes, because performance optimizations require benchmarking evidence and context about real-world usage patterns.
|
|
@@ -77,6 +80,7 @@ rg "def (get|post|put|delete|patch)\(" -A 20 --type py | rg "(open\(|requests\.|
|
|
|
77
80
|
```
|
|
78
81
|
|
|
79
82
|
**Context matters:**
|
|
83
|
+
|
|
80
84
|
- `readFileSync` at module top level (startup) → LOW impact, usually fine
|
|
81
85
|
- `readFileSync` inside a request handler → HIGH impact, blocks the event loop
|
|
82
86
|
- `readFileSync` in a build script → NO impact, expected behavior
|
|
@@ -127,6 +131,7 @@ rg "\.(filter|map|reduce|sort)\(" --type tsx -n # Check if inside render body w
|
|
|
127
131
|
```
|
|
128
132
|
|
|
129
133
|
**Impact assessment:**
|
|
134
|
+
|
|
130
135
|
- Component renders on every parent render + has expensive children → HIGH
|
|
131
136
|
- Component renders frequently but is a leaf node → LOW
|
|
132
137
|
- Inline style on a static component → LOW (React optimizes this)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: security-scanner
|
|
3
3
|
description: "Use this agent when scanning for hardcoded secrets, weak cryptography, SQL/command injection vectors, and insecure defaults."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["secret-detection", "weak-crypto-audit", "injection-vector-scan", "insecure-defaults-check", "auth-pattern-review"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **security scanner** — a specialist in identifying security vulnerabilities in source code. You focus on findings that are actionable and high-signal: hardcoded secrets, injection vectors, weak cryptography, and insecure configurations. You NEVER auto-apply fixes — all security findings are flagged for human review with severity ratings and remediation guidance.
|
|
@@ -39,6 +42,7 @@ If tools are unavailable, proceed to Phase 2 with pattern-based scanning.
|
|
|
39
42
|
### Phase 2: Pattern-Based Scan
|
|
40
43
|
|
|
41
44
|
**Hardcoded Secrets:**
|
|
45
|
+
|
|
42
46
|
```bash
|
|
43
47
|
# API keys and tokens
|
|
44
48
|
rg "(api[_-]?key|secret|password|token|auth)\s*[:=]\s*['\"][^'\"]{8,}" -i -n
|
|
@@ -50,6 +54,7 @@ rg "xox[bpors]-[a-zA-Z0-9-]+" # Slack tokens
|
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
**SQL Injection:**
|
|
57
|
+
|
|
53
58
|
```bash
|
|
54
59
|
# String interpolation in SQL
|
|
55
60
|
rg "(query|exec|execute)\s*\(\s*[`'\"].*\$\{" --type ts -n
|
|
@@ -59,6 +64,7 @@ rg "fmt\.Sprintf.*SELECT" --type go -n
|
|
|
59
64
|
```
|
|
60
65
|
|
|
61
66
|
**Command Injection:**
|
|
67
|
+
|
|
62
68
|
```bash
|
|
63
69
|
rg "(exec|execSync|spawn|spawnSync)\s*\(" --type ts -n
|
|
64
70
|
rg "(subprocess\.call|os\.system|os\.popen)\s*\(" --type py -n
|
|
@@ -66,6 +72,7 @@ rg "\beval\s*\(" -n # eval in any language
|
|
|
66
72
|
```
|
|
67
73
|
|
|
68
74
|
**Weak Cryptography:**
|
|
75
|
+
|
|
69
76
|
```bash
|
|
70
77
|
rg "(md5|sha1)\s*\(" -i -n
|
|
71
78
|
rg "Math\.random\(\)" --type ts -n # Insecure random for tokens
|
|
@@ -74,6 +81,7 @@ rg "hashlib\.(md5|sha1)\(" --type py -n
|
|
|
74
81
|
```
|
|
75
82
|
|
|
76
83
|
**Insecure Defaults:**
|
|
84
|
+
|
|
77
85
|
```bash
|
|
78
86
|
rg "rejectUnauthorized:\s*false" --type ts -n
|
|
79
87
|
rg "verify\s*=\s*False" --type py -n # Disabled SSL verify
|
|
@@ -83,6 +91,7 @@ rg "http://" --type ts -n # Plain HTTP (check if intentional)
|
|
|
83
91
|
```
|
|
84
92
|
|
|
85
93
|
**Path Traversal:**
|
|
94
|
+
|
|
86
95
|
```bash
|
|
87
96
|
rg "path\.(join|resolve)\(.*req\." --type ts -n # User input in path
|
|
88
97
|
rg "\.\.\/" -n # Literal ../ in path operations (context-dependent)
|
package/agents/slop-remover.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: slop-remover
|
|
3
3
|
description: "Use this agent when scanning for AI-generated comment noise, low-value JSDoc, and filler text that restates obvious code."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["ai-noise-detection", "low-value-comment-removal", "filler-text-cleanup", "jsdoc-pruning"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **AI slop remover** — a specialist in identifying and removing low-value comments that AI coding assistants generate. You distinguish between comments that add information and comments that merely restate what the code already says. You only touch comments — never modify actual code logic.
|
|
@@ -34,6 +37,7 @@ Scan for these slop categories:
|
|
|
34
37
|
**Category 1 — Restating Comments (highest signal)**
|
|
35
38
|
|
|
36
39
|
Comments that describe the *what* of the next line:
|
|
40
|
+
|
|
37
41
|
```
|
|
38
42
|
// Set the name ← SLOP (next line is: this.name = name)
|
|
39
43
|
// Get the user ← SLOP (next line is: const user = getUser(id))
|
|
@@ -48,6 +52,7 @@ Detection heuristic: if the comment can be derived by reading the next 1-2 lines
|
|
|
48
52
|
**Category 2 — Obvious JSDoc**
|
|
49
53
|
|
|
50
54
|
Parameter docs that only restate the type or name:
|
|
55
|
+
|
|
51
56
|
```typescript
|
|
52
57
|
/**
|
|
53
58
|
* @param name - The name ← SLOP (adds nothing beyond type sig)
|
|
@@ -58,6 +63,7 @@ Parameter docs that only restate the type or name:
|
|
|
58
63
|
```
|
|
59
64
|
|
|
60
65
|
Contrast with valuable JSDoc:
|
|
66
|
+
|
|
61
67
|
```typescript
|
|
62
68
|
/**
|
|
63
69
|
* @param name - Display name shown in the header. Truncated at 50 chars. ← KEEP
|
|
@@ -69,6 +75,7 @@ Contrast with valuable JSDoc:
|
|
|
69
75
|
**Category 3 — Filler Section Markers**
|
|
70
76
|
|
|
71
77
|
Decorative dividers with no navigation or organizational value:
|
|
78
|
+
|
|
72
79
|
```
|
|
73
80
|
// ========================
|
|
74
81
|
// --- Helper Functions ---
|
|
@@ -88,6 +95,7 @@ Exception: section markers in very long files (>500 lines) may have navigation v
|
|
|
88
95
|
**Category 4 — "This function/method/class" Preambles**
|
|
89
96
|
|
|
90
97
|
Boilerplate descriptions of what something is:
|
|
98
|
+
|
|
91
99
|
```
|
|
92
100
|
// This function calculates the total price ← SLOP
|
|
93
101
|
// This method handles the form submission ← SLOP
|
|
@@ -108,22 +116,30 @@ return null; // return null ← SLOP
|
|
|
108
116
|
Before marking any comment as slop, verify it does NOT:
|
|
109
117
|
|
|
110
118
|
1. **Explain WHY** — business logic, architectural decisions, constraints
|
|
119
|
+
|
|
111
120
|
```
|
|
112
121
|
// Use MD5 here because the legacy API requires it (not for security) ← KEEP
|
|
113
122
|
```
|
|
123
|
+
|
|
114
124
|
2. **Document a workaround** — bug references, platform quirks
|
|
125
|
+
|
|
115
126
|
```
|
|
116
127
|
// Safari doesn't support this API, fall back to polyfill ← KEEP
|
|
117
128
|
```
|
|
129
|
+
|
|
118
130
|
3. **Contain a TODO/FIXME with context** — actionable items
|
|
131
|
+
|
|
119
132
|
```
|
|
120
133
|
// TODO(#123): Replace with batch API once it ships in Q3 ← KEEP
|
|
121
134
|
```
|
|
135
|
+
|
|
122
136
|
4. **Serve as public API documentation** — JSDoc on exported functions with non-obvious behavior
|
|
123
137
|
5. **Explain non-obvious code** — regex patterns, bitwise operations, complex algorithms
|
|
138
|
+
|
|
124
139
|
```
|
|
125
140
|
// Bitwise OR with 0 truncates to 32-bit integer (faster than Math.floor) ← KEEP
|
|
126
141
|
```
|
|
142
|
+
|
|
127
143
|
6. **Provide legal/license context** — copyright headers, license markers
|
|
128
144
|
7. **Mark intentional decisions** — `// Intentionally empty`, `// No-op by design`
|
|
129
145
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: type-consolidator
|
|
3
3
|
description: "Use this agent when merging duplicate type definitions, consolidating overlapping interfaces, and leveraging Pick/Omit/Partial."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["duplicate-type-detection", "interface-consolidation", "utility-type-refactoring", "type-hierarchy-flattening"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **type consolidator** — a specialist in finding duplicate or near-duplicate type definitions and merging them into a single source of truth. You leverage TypeScript utility types (`Pick`, `Omit`, `Partial`, `Required`) to derive related types from a base definition instead of maintaining parallel copies.
|
|
@@ -41,6 +44,7 @@ For types with different names but similar shapes:
|
|
|
41
44
|
4. If overlap > 80%, flag as consolidation candidate
|
|
42
45
|
|
|
43
46
|
Common patterns:
|
|
47
|
+
|
|
44
48
|
- `User` and `UserDTO` — same fields, different names
|
|
45
49
|
- `CreateUserInput` and `UpdateUserInput` — differ by 1-2 optional fields
|
|
46
50
|
- `APIResponse` and `ServiceResponse` — identical structure, different domains
|
|
@@ -55,6 +59,7 @@ Common patterns:
|
|
|
55
59
|
| Partial overlap, different domains | Keep separate — different reasons to change |
|
|
56
60
|
|
|
57
61
|
Example consolidation:
|
|
62
|
+
|
|
58
63
|
```typescript
|
|
59
64
|
// BEFORE: Two files with near-identical types
|
|
60
65
|
// user-api.ts
|
|
@@ -84,10 +89,12 @@ For HIGH confidence consolidations:
|
|
|
84
89
|
2. Update all import statements across the codebase
|
|
85
90
|
3. Remove the duplicate definitions
|
|
86
91
|
4. Run verification:
|
|
92
|
+
|
|
87
93
|
```bash
|
|
88
94
|
npx tsc --noEmit 2>&1 | tail -20
|
|
89
95
|
npm test 2>&1 | tail -30
|
|
90
96
|
```
|
|
97
|
+
|
|
91
98
|
5. If errors → revert, flag as MEDIUM
|
|
92
99
|
|
|
93
100
|
MEDIUM/LOW — flag with consolidation suggestion and rationale.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: weak-type-eliminator
|
|
3
3
|
description: "Use this agent when replacing any, unknown, and overly broad generics with precise, compiler-verified types."
|
|
4
|
+
model: inherit
|
|
5
|
+
capabilities: ["any-type-elimination", "unknown-type-narrowing", "generic-tightening", "type-precision-analysis"]
|
|
6
|
+
expertise_level: intermediate
|
|
4
7
|
---
|
|
5
8
|
|
|
6
9
|
You are an expert **weak type eliminator** — a specialist in replacing `any`, implicit `any`, and overly broad type annotations with precise, compiler-verified types. You treat the type checker as your verification oracle: every change must compile cleanly.
|
|
@@ -31,6 +34,7 @@ cat pyproject.toml | grep -A5 "mypy\|pyright" # Type checker config
|
|
|
31
34
|
### Phase 2: Scan for Weak Types
|
|
32
35
|
|
|
33
36
|
**TypeScript/JavaScript:**
|
|
37
|
+
|
|
34
38
|
```bash
|
|
35
39
|
# Explicit any
|
|
36
40
|
rg ": any\b" --type ts -n
|
|
@@ -45,6 +49,7 @@ rg ": object\b|: Object\b|: \{\}" --type ts -n
|
|
|
45
49
|
```
|
|
46
50
|
|
|
47
51
|
**Python:**
|
|
52
|
+
|
|
48
53
|
```bash
|
|
49
54
|
rg "from typing import.*\bAny\b" --type py -n
|
|
50
55
|
rg ":\s*Any\b" --type py -n
|
|
@@ -62,6 +67,7 @@ For each weak type, infer the correct replacement:
|
|
|
62
67
|
5. **Check existing related types** — is there already an interface that fits?
|
|
63
68
|
|
|
64
69
|
Decision tree:
|
|
70
|
+
|
|
65
71
|
- Usage accesses `.foo`, `.bar` → create or find matching interface
|
|
66
72
|
- Passed to `Array<T>` method → type is `T`
|
|
67
73
|
- Used in conditional → narrow to union
|
|
@@ -82,9 +88,11 @@ For HIGH confidence replacements:
|
|
|
82
88
|
|
|
83
89
|
1. Apply the type change using Edit tool
|
|
84
90
|
2. Run type checker:
|
|
91
|
+
|
|
85
92
|
```bash
|
|
86
93
|
npx tsc --noEmit 2>&1 | tail -20
|
|
87
94
|
```
|
|
95
|
+
|
|
88
96
|
3. If clean → confirmed, move to next
|
|
89
97
|
4. If errors → revert (`git checkout -- <file>`), re-examine, try alternative type or downgrade to flagged
|
|
90
98
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cleanup-code
|
|
3
|
-
description:
|
|
4
|
-
|
|
3
|
+
description: 'Comprehensive codebase cleanup across 11 quality dimensions: dead code,
|
|
4
|
+
duplication,
|
|
5
|
+
|
|
5
6
|
weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation,
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
security, performance, and async patterns. Analyzes code with confidence scoring
|
|
9
|
+
and
|
|
10
|
+
|
|
7
11
|
verifies changes with build/test gates. Use when codebase has accumulated tech debt,
|
|
12
|
+
|
|
8
13
|
after major feature work, before releases, or when code quality metrics are declining.
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
|
|
15
|
+
Trigger with "/cleanup-code-code", "clean up the codebase", "remove dead code",
|
|
16
|
+
"fix code quality".
|
|
17
|
+
|
|
18
|
+
'
|
|
19
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash(git:*), Bash(npm:*), Bash(npx:*),
|
|
20
|
+
Bash(pnpm:*), Bash(python3:*), Bash(tsc:*), Bash(wc:*), Bash(ls:*), AskUserQuestion
|
|
11
21
|
version: 1.0.0
|
|
12
22
|
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
13
23
|
license: MIT
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
tags:
|
|
25
|
+
- code-quality
|
|
26
|
+
- cleanup
|
|
27
|
+
- refactoring
|
|
28
|
+
- dead-code
|
|
29
|
+
- deduplication
|
|
30
|
+
- type-safety
|
|
31
|
+
- security
|
|
32
|
+
argument-hint: '[scope] [--dimensions d1,d2,...] [--changed]'
|
|
33
|
+
compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
|
|
17
34
|
---
|
|
18
|
-
|
|
19
35
|
# Codebase Cleanup
|
|
20
36
|
|
|
21
37
|
Systematic code cleanup across 11 quality dimensions, ordered by risk. Each finding includes
|
|
@@ -93,7 +109,7 @@ Use [tools reference](references/tools.md) for language-specific tool commands (
|
|
|
93
109
|
|
|
94
110
|
After each auto-applied dimension:
|
|
95
111
|
|
|
96
|
-
```
|
|
112
|
+
```text
|
|
97
113
|
# TypeScript/JavaScript
|
|
98
114
|
npx tsc --noEmit 2>&1 | tail -20
|
|
99
115
|
npm test 2>&1 | tail -30
|
|
@@ -138,6 +154,7 @@ Produce a cleanup report in this format:
|
|
|
138
154
|
## Output
|
|
139
155
|
|
|
140
156
|
A structured cleanup report containing:
|
|
157
|
+
|
|
141
158
|
- Summary table with findings per dimension (count, applied, flagged, confidence)
|
|
142
159
|
- List of changes applied with file:line references
|
|
143
160
|
- List of flagged items with reasoning and suggested fixes
|
|
@@ -156,21 +173,25 @@ A structured cleanup report containing:
|
|
|
156
173
|
## Examples
|
|
157
174
|
|
|
158
175
|
**Full cleanup:**
|
|
176
|
+
|
|
159
177
|
```
|
|
160
178
|
/cleanup-code
|
|
161
179
|
```
|
|
162
180
|
|
|
163
181
|
**Security-focused:**
|
|
182
|
+
|
|
164
183
|
```
|
|
165
184
|
/cleanup-code --dimensions security,async
|
|
166
185
|
```
|
|
167
186
|
|
|
168
187
|
**Changed files only:**
|
|
188
|
+
|
|
169
189
|
```
|
|
170
190
|
/cleanup-code src/api/ --changed
|
|
171
191
|
```
|
|
172
192
|
|
|
173
193
|
**Single dimension deep-dive:**
|
|
194
|
+
|
|
174
195
|
```
|
|
175
196
|
/cleanup-code --dimensions dead
|
|
176
197
|
```
|
|
@@ -9,12 +9,14 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
9
9
|
**What:** Unreachable code, unused exports, unused variables, unused imports, unused functions, dead branches.
|
|
10
10
|
|
|
11
11
|
**Detection:**
|
|
12
|
+
|
|
12
13
|
- Unused exports: `knip` (JS/TS), `vulture` (Python), `deadcode` (Go)
|
|
13
14
|
- Unused variables: compiler warnings, linter output
|
|
14
15
|
- Unreachable code: code after `return`/`throw`/`break`/`continue`
|
|
15
16
|
- Dead feature flags: flags that are always true/false
|
|
16
17
|
|
|
17
18
|
**Verification:**
|
|
19
|
+
|
|
18
20
|
1. Remove candidate
|
|
19
21
|
2. Run `tsc --noEmit` (TS) or equivalent type check
|
|
20
22
|
3. Run test suite
|
|
@@ -31,6 +33,7 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
31
33
|
**What:** Low-value comments generated by AI assistants — restating obvious code, adding filler.
|
|
32
34
|
|
|
33
35
|
**Detection patterns:**
|
|
36
|
+
|
|
34
37
|
- Comments that restate the next line: `// Set the name` above `name = value`
|
|
35
38
|
- Obvious JSDoc: `@param name - The name` or `@returns The result`
|
|
36
39
|
- Section markers with no value: `// --- Helper Functions ---`
|
|
@@ -50,11 +53,13 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
50
53
|
**What:** `any`, `unknown` used unnecessarily, missing return types, implicit any, overly broad generics.
|
|
51
54
|
|
|
52
55
|
**Detection:**
|
|
56
|
+
|
|
53
57
|
- TypeScript: `any` type annotations, missing return types on exported functions
|
|
54
58
|
- Python: missing type hints on public functions, `Any` imports from typing
|
|
55
59
|
- Untyped function parameters in public APIs
|
|
56
60
|
|
|
57
61
|
**Verification:**
|
|
62
|
+
|
|
58
63
|
1. Replace `any` with specific type
|
|
59
64
|
2. Run `tsc --noEmit` — must compile without new errors
|
|
60
65
|
3. Run tests
|
|
@@ -93,12 +98,14 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
93
98
|
**What:** Deprecated API usage, old syntax patterns, compatibility shims for dropped platforms, polyfills for supported targets.
|
|
94
99
|
|
|
95
100
|
**Detection:**
|
|
101
|
+
|
|
96
102
|
- Deprecated Node.js APIs (`fs.exists`, `url.parse`, `new Buffer()`)
|
|
97
103
|
- Old JS patterns (`var`, `arguments` object, `prototype` instead of class)
|
|
98
104
|
- Unnecessary polyfills based on browserslist/engines config
|
|
99
105
|
- Compatibility code for unsupported environments
|
|
100
106
|
|
|
101
107
|
**Verification:**
|
|
108
|
+
|
|
102
109
|
1. Replace with modern equivalent
|
|
103
110
|
2. Check minimum platform target (engines, browserslist)
|
|
104
111
|
3. Run tests
|
|
@@ -114,12 +121,14 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
114
121
|
**What:** Duplicate type definitions, inconsistent interfaces, types that should be derived/shared.
|
|
115
122
|
|
|
116
123
|
**Detection:**
|
|
124
|
+
|
|
117
125
|
- Multiple interfaces with >80% field overlap
|
|
118
126
|
- Same type defined in multiple files
|
|
119
127
|
- Types that could use `Pick<>`, `Omit<>`, `Partial<>` instead of duplication
|
|
120
128
|
- Enum values duplicated as string literals elsewhere
|
|
121
129
|
|
|
122
130
|
**Verification:**
|
|
131
|
+
|
|
123
132
|
1. Consolidate to single source
|
|
124
133
|
2. Update all imports
|
|
125
134
|
3. Run `tsc --noEmit` + tests
|
|
@@ -135,6 +144,7 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
135
144
|
**What:** Unnecessary null checks, impossible error handling, redundant validation, dead catch blocks.
|
|
136
145
|
|
|
137
146
|
**Detection:**
|
|
147
|
+
|
|
138
148
|
- Null checks on values that are never null (check upstream guarantees)
|
|
139
149
|
- Try/catch around code that cannot throw
|
|
140
150
|
- Validation of internal function parameters (not at system boundary)
|
|
@@ -176,6 +186,7 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
176
186
|
**What:** Copy-pasted code blocks, duplicated logic across files, repeated patterns that should be abstracted.
|
|
177
187
|
|
|
178
188
|
**Detection:**
|
|
189
|
+
|
|
179
190
|
- `jscpd` tool for exact/near-duplicate detection
|
|
180
191
|
- Manual scan for functions with identical structure but different names
|
|
181
192
|
- Threshold: **>=10 identical lines** before flagging
|
|
@@ -206,6 +217,7 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
206
217
|
| `Promise.all` without error strategy | One failure kills all |
|
|
207
218
|
|
|
208
219
|
**Verification:**
|
|
220
|
+
|
|
209
221
|
1. Confirm the async pattern is actually incorrect (not intentional fire-and-forget)
|
|
210
222
|
2. Apply fix
|
|
211
223
|
3. Run tests — async bugs often only surface under load
|
|
@@ -221,17 +233,20 @@ Complete reference for all 11 cleanup dimensions, ordered by risk level.
|
|
|
221
233
|
**What:** Module A imports B which imports A, creating initialization order issues, bundle bloat, and test difficulty.
|
|
222
234
|
|
|
223
235
|
**Detection:**
|
|
236
|
+
|
|
224
237
|
- `madge --circular` (JS/TS)
|
|
225
238
|
- `dependency-cruiser` (JS/TS, configurable)
|
|
226
239
|
- Import graph analysis
|
|
227
240
|
|
|
228
241
|
**Resolution strategies:**
|
|
242
|
+
|
|
229
243
|
1. **Extract shared types** to a separate module
|
|
230
244
|
2. **Dependency inversion** — depend on interfaces, not implementations
|
|
231
245
|
3. **Lazy imports** — dynamic `import()` to break cycles
|
|
232
246
|
4. **Barrel file restructuring** — split index.ts re-exports
|
|
233
247
|
|
|
234
248
|
**Verification:**
|
|
249
|
+
|
|
235
250
|
1. Run `madge --circular` — should show fewer cycles
|
|
236
251
|
2. Run full test suite
|
|
237
252
|
3. Check bundle size hasn't increased
|
|
@@ -24,6 +24,7 @@ Every finding gets a confidence score:
|
|
|
24
24
|
| **LOW** | Heuristic match only, could be intentional | Flag with explanation only |
|
|
25
25
|
|
|
26
26
|
**Scoring rules:**
|
|
27
|
+
|
|
27
28
|
- Tool verification (knip, madge, tsc) → +1 confidence level
|
|
28
29
|
- Multiple signals pointing to same issue → +1 confidence level
|
|
29
30
|
- Dynamic usage possible (reflection, eval, metaprogramming) → -1 confidence level
|
|
@@ -33,6 +34,7 @@ Every finding gets a confidence score:
|
|
|
33
34
|
## Revert Procedures
|
|
34
35
|
|
|
35
36
|
### Revert Single Dimension
|
|
37
|
+
|
|
36
38
|
```bash
|
|
37
39
|
# Undo all unstaged changes
|
|
38
40
|
git checkout -- .
|
|
@@ -42,12 +44,14 @@ git checkout -- src/path/to/file.ts
|
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
### Revert Everything
|
|
47
|
+
|
|
45
48
|
```bash
|
|
46
49
|
# Reset to pre-cleanup state
|
|
47
50
|
git reset --hard <baseline-commit-hash>
|
|
48
51
|
```
|
|
49
52
|
|
|
50
53
|
### Partial Revert (Keep Some Changes)
|
|
54
|
+
|
|
51
55
|
```bash
|
|
52
56
|
# Interactive: review each hunk
|
|
53
57
|
git add -p # Stage only the changes you want to keep
|
|
@@ -82,6 +86,7 @@ After every auto-applied dimension:
|
|
|
82
86
|
3. Run linter (`eslint`, `ruff`, `golangci-lint`, etc.)
|
|
83
87
|
|
|
84
88
|
**If any step fails:**
|
|
89
|
+
|
|
85
90
|
1. Immediately revert: `git checkout -- .`
|
|
86
91
|
2. Log which changes caused the failure
|
|
87
92
|
3. Re-apply only the safe subset
|
|
@@ -8,6 +8,7 @@ Language-specific tools for each cleanup dimension. Always fall back to grep pat
|
|
|
8
8
|
## JavaScript / TypeScript
|
|
9
9
|
|
|
10
10
|
### Dead Code
|
|
11
|
+
|
|
11
12
|
```bash
|
|
12
13
|
# knip — finds unused files, exports, dependencies, and types
|
|
13
14
|
npx knip # Full report
|
|
@@ -18,6 +19,7 @@ npx knip --include dependencies # Unused dependencies only
|
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
### Circular Dependencies
|
|
22
|
+
|
|
21
23
|
```bash
|
|
22
24
|
# madge — dependency graph and circular detection
|
|
23
25
|
npx madge --circular src/ # Find circular deps
|
|
@@ -30,6 +32,7 @@ npx depcruise --output-type dot src/ | dot -T svg > deps.svg # Visual
|
|
|
30
32
|
```
|
|
31
33
|
|
|
32
34
|
### Duplication
|
|
35
|
+
|
|
33
36
|
```bash
|
|
34
37
|
# jscpd — copy/paste detector
|
|
35
38
|
npx jscpd src/ --min-lines 10 --min-tokens 50
|
|
@@ -38,6 +41,7 @@ npx jscpd src/ --output report/ # HTML report
|
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
### Type Safety
|
|
44
|
+
|
|
41
45
|
```bash
|
|
42
46
|
# TypeScript strict checks
|
|
43
47
|
npx tsc --noEmit --strict # Full strict mode
|
|
@@ -45,6 +49,7 @@ npx tsc --noEmit 2>&1 | grep "any" # Find any-related issues
|
|
|
45
49
|
```
|
|
46
50
|
|
|
47
51
|
### Security
|
|
52
|
+
|
|
48
53
|
```bash
|
|
49
54
|
# npm audit for dependency vulnerabilities
|
|
50
55
|
npm audit --json | head -50
|
|
@@ -55,6 +60,7 @@ npx eslint --rule '{"no-eval": "error", "no-implied-eval": "error"}' src/
|
|
|
55
60
|
```
|
|
56
61
|
|
|
57
62
|
### Performance
|
|
63
|
+
|
|
58
64
|
```bash
|
|
59
65
|
# Bundle analysis
|
|
60
66
|
npx webpack-bundle-analyzer stats.json # Webpack
|
|
@@ -70,6 +76,7 @@ npx import-cost src/index.ts
|
|
|
70
76
|
## Python
|
|
71
77
|
|
|
72
78
|
### Dead Code
|
|
79
|
+
|
|
73
80
|
```bash
|
|
74
81
|
# vulture — find unused code
|
|
75
82
|
vulture src/ --min-confidence 80
|
|
@@ -81,6 +88,7 @@ autoflake --in-place --remove-all-unused-imports -r src/ # Apply
|
|
|
81
88
|
```
|
|
82
89
|
|
|
83
90
|
### Code Quality
|
|
91
|
+
|
|
84
92
|
```bash
|
|
85
93
|
# ruff — fast linter and formatter (replaces flake8, isort, pyupgrade)
|
|
86
94
|
ruff check src/ # Lint
|
|
@@ -93,6 +101,7 @@ pylint src/ --disable=all --enable=W0611,W0612,W0613 # Unused imports/vars/args
|
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
### Security
|
|
104
|
+
|
|
96
105
|
```bash
|
|
97
106
|
# bandit — security linter
|
|
98
107
|
bandit -r src/ -ll # Medium+ severity
|
|
@@ -104,6 +113,7 @@ safety check --json
|
|
|
104
113
|
```
|
|
105
114
|
|
|
106
115
|
### Duplication
|
|
116
|
+
|
|
107
117
|
```bash
|
|
108
118
|
# pylint duplicate detection
|
|
109
119
|
pylint src/ --disable=all --enable=R0801 # Duplicate code
|
|
@@ -117,6 +127,7 @@ npx jscpd src/ --format python --min-lines 10
|
|
|
117
127
|
## Go
|
|
118
128
|
|
|
119
129
|
### Dead Code
|
|
130
|
+
|
|
120
131
|
```bash
|
|
121
132
|
# deadcode — find unreachable functions
|
|
122
133
|
go install golang.org/x/tools/cmd/deadcode@latest
|
|
@@ -128,6 +139,7 @@ staticcheck -checks U1000 ./... # Unused code specifically
|
|
|
128
139
|
```
|
|
129
140
|
|
|
130
141
|
### Code Quality
|
|
142
|
+
|
|
131
143
|
```bash
|
|
132
144
|
# golangci-lint — meta-linter
|
|
133
145
|
golangci-lint run
|
|
@@ -140,6 +152,7 @@ golangci-lint run --enable unused,deadcode,ineffassign
|
|
|
140
152
|
## Rust
|
|
141
153
|
|
|
142
154
|
### Dead Code
|
|
155
|
+
|
|
143
156
|
```bash
|
|
144
157
|
# Compiler warnings
|
|
145
158
|
cargo build 2>&1 | grep "dead_code\|unused"
|
|
@@ -151,6 +164,7 @@ cargo udeps
|
|
|
151
164
|
```
|
|
152
165
|
|
|
153
166
|
### Code Quality
|
|
167
|
+
|
|
154
168
|
```bash
|
|
155
169
|
# clippy — comprehensive linting
|
|
156
170
|
cargo clippy -- -W clippy::all
|
|
@@ -162,12 +176,14 @@ cargo clippy --fix # Auto-fix
|
|
|
162
176
|
## Universal Tools
|
|
163
177
|
|
|
164
178
|
### Duplication (Any Language)
|
|
179
|
+
|
|
165
180
|
```bash
|
|
166
181
|
npx jscpd . --min-lines 10 --min-tokens 50 \
|
|
167
182
|
--format "typescript,javascript,python,go,rust,java"
|
|
168
183
|
```
|
|
169
184
|
|
|
170
185
|
### Secret Scanning
|
|
186
|
+
|
|
171
187
|
```bash
|
|
172
188
|
# gitleaks — scan for hardcoded secrets
|
|
173
189
|
gitleaks detect --source . --verbose
|
|
@@ -178,6 +194,7 @@ trufflehog filesystem . --only-verified
|
|
|
178
194
|
```
|
|
179
195
|
|
|
180
196
|
### Dependency Analysis
|
|
197
|
+
|
|
181
198
|
```bash
|
|
182
199
|
# depcheck (Node.js) — unused dependencies
|
|
183
200
|
npx depcheck
|