specialist-agent 2.11.3 → 2.12.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/.claude-plugin/marketplace.json +48 -73
- package/.claude-plugin/plugin.json +8 -14
- package/.codex/INSTALL.md +32 -9
- package/.cursor-plugin/marketplace.json +45 -2
- package/.cursor-plugin/plugin.json +14 -12
- package/.opencode/opencode.json +45 -0
- package/README.md +18 -2
- package/agents/analyst-lite.md +1 -1
- package/agents/analyst.md +5 -1
- package/agents/api.md +1 -0
- package/agents/architect-lite.md +1 -1
- package/agents/architect.md +10 -1
- package/agents/autopilot-lite.md +46 -0
- package/agents/autopilot.md +196 -0
- package/agents/cloud-lite.md +1 -1
- package/agents/cloud.md +2 -1
- package/agents/data.md +1 -0
- package/agents/debugger.md +3 -0
- package/agents/deps-lite.md +1 -1
- package/agents/deps.md +2 -1
- package/agents/designer.md +8 -0
- package/agents/devops-lite.md +1 -1
- package/agents/devops.md +2 -1
- package/agents/docs-lite.md +1 -1
- package/agents/docs.md +2 -1
- package/agents/executor-lite.md +1 -1
- package/agents/executor.md +58 -31
- package/agents/explorer-lite.md +1 -1
- package/agents/explorer.md +14 -1
- package/agents/finance.md +1 -0
- package/agents/i18n.md +1 -0
- package/agents/legal.md +1 -0
- package/agents/marketing.md +9 -0
- package/agents/memory.md +103 -178
- package/agents/orchestrator-lite.md +1 -1
- package/agents/orchestrator.md +62 -39
- package/agents/pair-lite.md +1 -1
- package/agents/pair.md +2 -1
- package/agents/perf.md +1 -0
- package/agents/planner-lite.md +1 -1
- package/agents/planner.md +17 -11
- package/agents/product.md +9 -0
- package/agents/refactor.md +1 -0
- package/agents/ripple-lite.md +1 -1
- package/agents/ripple.md +4 -1
- package/agents/scout-lite.md +1 -1
- package/agents/scout.md +2 -1
- package/agents/security-lite.md +1 -1
- package/agents/security.md +4 -1
- package/agents/sentry-triage-lite.md +1 -1
- package/agents/sentry-triage.md +4 -1
- package/agents/starter-lite.md +1 -1
- package/agents/starter.md +2 -1
- package/agents/support.md +1 -0
- package/agents/tdd.md +3 -0
- package/agents/tester.md +1 -0
- package/cli/index.mjs +1 -1
- package/hooks/hooks.json +61 -76
- package/hooks/lifecycle.json +91 -0
- package/hooks/native/auto-dispatch.mjs +7 -2
- package/hooks/native/session-end.mjs +42 -0
- package/package.json +1 -1
- package/skills/audit/SKILL.md +71 -9
- package/skills/autopilot/SKILL.md +286 -0
- package/skills/brainstorm/SKILL.md +60 -7
- package/skills/codereview/SKILL.md +16 -3
- package/skills/copywriting/SKILL.md +218 -0
- package/skills/cro/SKILL.md +234 -0
- package/skills/design-review/SKILL.md +217 -0
- package/skills/grill/SKILL.md +270 -0
- package/skills/improve-architecture/SKILL.md +205 -0
- package/skills/prd/SKILL.md +241 -0
- package/skills/recall/SKILL.md +36 -74
- package/skills/remember/SKILL.md +41 -91
- package/skills/seo-audit/SKILL.md +240 -0
- package/skills/tdd/SKILL.md +49 -4
- package/skills/write-skill/SKILL.md +18 -6
- package/templates/autopilot/PROMPT.md +39 -0
- package/templates/autopilot/README.md +122 -0
- package/templates/autopilot/devcontainer.json +21 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grill
|
|
3
|
+
description: "Use when you want to stress-test code by having an adversarial reviewer try to break it - finding edge cases, security holes, race conditions, and logical flaws that normal reviews miss."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[path, function, or module to grill]"
|
|
6
|
+
allowed-tools: Read, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /grill - Adversarial Code Challenge
|
|
10
|
+
|
|
11
|
+
Stress-test code by systematically trying to break it - finding edge cases, security holes, race conditions, and logical flaws that normal code reviews miss. This is not a review; this is an attack.
|
|
12
|
+
|
|
13
|
+
**Target:** $ARGUMENTS
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Before deploying critical code (auth, payments, data handling)
|
|
18
|
+
- After writing complex business logic
|
|
19
|
+
- When code handles user input or external data
|
|
20
|
+
- Before security audits (find issues first)
|
|
21
|
+
- When you suspect a function has hidden edge cases
|
|
22
|
+
- After fixing a bug (verify the fix doesn't break under stress)
|
|
23
|
+
- NOT for: general code quality (use `/codereview`)
|
|
24
|
+
- NOT for: architecture assessment (use `@architect`)
|
|
25
|
+
- NOT for: test creation (use `/tdd` - but grilling findings feed into test cases)
|
|
26
|
+
|
|
27
|
+
## Iron Rule
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
31
|
+
║ ASSUME THE CODE IS BROKEN UNTIL PROVEN OTHERWISE ║
|
|
32
|
+
║ Your job is to find HOW, not to confirm it works. ║
|
|
33
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Workflow
|
|
37
|
+
|
|
38
|
+
### Step 1: Target Analysis
|
|
39
|
+
|
|
40
|
+
1. **Read the target code** completely
|
|
41
|
+
2. **Understand the contract:**
|
|
42
|
+
- What are the expected inputs? (types, ranges, formats)
|
|
43
|
+
- What are the expected outputs?
|
|
44
|
+
- What side effects does it have? (DB writes, API calls, file I/O)
|
|
45
|
+
- What invariants should always hold?
|
|
46
|
+
3. **Identify trust boundaries:**
|
|
47
|
+
- Where does external data enter?
|
|
48
|
+
- Where does the code trust input without validation?
|
|
49
|
+
- Where are type assertions or casts used?
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Read the target
|
|
53
|
+
cat $TARGET 2>/dev/null || find . -name "$TARGET*" -not -path "*/node_modules/*" | head -5
|
|
54
|
+
|
|
55
|
+
# Find type assertions and unsafe casts
|
|
56
|
+
grep -rn "as any\|as unknown\|! \|!\.\|@ts-ignore\|@ts-expect-error" $TARGET --include="*.ts" --include="*.tsx" 2>/dev/null | head -15
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Output:**
|
|
60
|
+
```markdown
|
|
61
|
+
## Target Profile
|
|
62
|
+
- **Function/Module:** [name]
|
|
63
|
+
- **Contract:** [inputs → outputs]
|
|
64
|
+
- **Side effects:** [DB, API, file, state]
|
|
65
|
+
- **Trust boundaries:** [where external data enters]
|
|
66
|
+
- **Unsafe patterns:** [casts, assertions, ignores]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**BLOCKED** until target is fully understood.
|
|
70
|
+
|
|
71
|
+
### Step 2: Attack Vector Execution
|
|
72
|
+
|
|
73
|
+
Systematically attack across 5 categories:
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
**Category 1: Input Attacks**
|
|
78
|
+
|
|
79
|
+
Try to break the code with unexpected inputs:
|
|
80
|
+
|
|
81
|
+
| Attack | Input | Expected Failure |
|
|
82
|
+
|--------|-------|-----------------|
|
|
83
|
+
| Null/undefined | `null`, `undefined` | TypeError, crash |
|
|
84
|
+
| Empty values | `""`, `[]`, `{}`, `0` | Logic error, empty result |
|
|
85
|
+
| Type coercion | `"0"`, `"false"`, `"null"` | Truthy/falsy confusion |
|
|
86
|
+
| Boundary values | `Number.MAX_SAFE_INTEGER`, `-1`, `0.1 + 0.2` | Overflow, off-by-one, float precision |
|
|
87
|
+
| Long strings | `"a".repeat(1_000_000)` | Memory exhaustion, buffer overflow |
|
|
88
|
+
| Special characters | `<script>`, `'; DROP TABLE`, `../../../etc/passwd` | XSS, SQL injection, path traversal |
|
|
89
|
+
| Unicode edge cases | `"é"`, `"🚀"`, `"\u0000"`, RTL text | Encoding errors, display corruption |
|
|
90
|
+
| Nested data | Deeply nested objects (100+ levels) | Stack overflow, infinite recursion |
|
|
91
|
+
| Prototype pollution | `{"__proto__": {"admin": true}}` | Privilege escalation |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
**Category 2: State Attacks**
|
|
96
|
+
|
|
97
|
+
Try to break the code through state manipulation:
|
|
98
|
+
|
|
99
|
+
| Attack | Scenario | Expected Failure |
|
|
100
|
+
|--------|----------|-----------------|
|
|
101
|
+
| Concurrent calls | Same function called simultaneously | Race condition, double write |
|
|
102
|
+
| Out-of-order execution | Step 3 before step 1 | Undefined behavior |
|
|
103
|
+
| Stale state | Use cached/old data with new logic | Inconsistency |
|
|
104
|
+
| State pollution | Shared mutable state across calls | Side effect leaks |
|
|
105
|
+
| Re-entrance | Function calls itself indirectly | Infinite loop, deadlock |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
**Category 3: Boundary Attacks**
|
|
110
|
+
|
|
111
|
+
Try to exploit boundaries:
|
|
112
|
+
|
|
113
|
+
| Attack | Scenario | Expected Failure |
|
|
114
|
+
|--------|----------|-----------------|
|
|
115
|
+
| Off-by-one | First/last element, array[length] | IndexError, missing data |
|
|
116
|
+
| Empty collection | `[]`, empty Map/Set | Unexpected behavior on .map(), .reduce() |
|
|
117
|
+
| Single item | Array of 1, Map with 1 entry | Logic that assumes >1 items |
|
|
118
|
+
| Max limits | Max array size, max string length | Performance degradation |
|
|
119
|
+
| Pagination edges | Page 0, page -1, page past end | Error or empty result |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
**Category 4: Logic Attacks**
|
|
124
|
+
|
|
125
|
+
Try to find logical flaws:
|
|
126
|
+
|
|
127
|
+
| Attack | Scenario | Expected Failure |
|
|
128
|
+
|--------|----------|-----------------|
|
|
129
|
+
| Contradictory inputs | `{min: 10, max: 5}` | No validation, unexpected range |
|
|
130
|
+
| Impossible states | Admin + banned, published + draft | State machine violation |
|
|
131
|
+
| Circular references | Object referencing itself | Stack overflow, infinite loop |
|
|
132
|
+
| Time-dependent logic | Timezone differences, DST, leap year | Wrong date calculations |
|
|
133
|
+
| Floating point | `0.1 + 0.2 !== 0.3` | Financial calculation errors |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
**Category 5: Error Path Attacks**
|
|
138
|
+
|
|
139
|
+
Try to trigger every error path:
|
|
140
|
+
|
|
141
|
+
| Attack | Scenario | Expected Failure |
|
|
142
|
+
|--------|----------|-----------------|
|
|
143
|
+
| Network failure | API returns 500, timeout, DNS failure | Unhandled rejection, crash |
|
|
144
|
+
| Permission denied | File system, database, API auth | Silent failure, data loss |
|
|
145
|
+
| Resource exhaustion | Disk full, memory full, connection pool exhausted | Crash without graceful degradation |
|
|
146
|
+
| Partial failure | 3 of 5 batch operations fail | Inconsistent state |
|
|
147
|
+
| Corrupted data | Invalid JSON, truncated response, wrong encoding | Parse error, crash |
|
|
148
|
+
|
|
149
|
+
### Step 3: Exploitation Report
|
|
150
|
+
|
|
151
|
+
For each vulnerability found:
|
|
152
|
+
|
|
153
|
+
```markdown
|
|
154
|
+
### Vulnerability [N]: [Title]
|
|
155
|
+
|
|
156
|
+
**Category:** [Input | State | Boundary | Logic | Error Path]
|
|
157
|
+
**Severity:** CRITICAL | HIGH | MEDIUM | LOW
|
|
158
|
+
**Location:** [file:line]
|
|
159
|
+
|
|
160
|
+
**Attack:**
|
|
161
|
+
```
|
|
162
|
+
[exact input or scenario that triggers the bug]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Expected behavior:** [what should happen]
|
|
166
|
+
**Actual behavior:** [what actually happens]
|
|
167
|
+
**Impact:** [data loss | crash | security breach | incorrect result | performance degradation]
|
|
168
|
+
|
|
169
|
+
**Proof:** [how to reproduce]
|
|
170
|
+
**Fix:** [specific code change to prevent this]
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Step 4: Hardening Recommendations
|
|
174
|
+
|
|
175
|
+
For each vulnerability, provide a concrete fix:
|
|
176
|
+
|
|
177
|
+
| Pattern | Fix |
|
|
178
|
+
|---------|-----|
|
|
179
|
+
| Missing null check | Add guard clause or optional chaining |
|
|
180
|
+
| No input validation | Add Zod/Yup schema validation at boundary |
|
|
181
|
+
| Race condition | Add mutex, optimistic locking, or idempotency |
|
|
182
|
+
| Injection vulnerability | Parameterized queries, input sanitization |
|
|
183
|
+
| Missing error handling | Add try/catch with specific error types |
|
|
184
|
+
| Unsafe type assertion | Replace `as` with runtime type guard |
|
|
185
|
+
|
|
186
|
+
### Step 5: Resilience Score
|
|
187
|
+
|
|
188
|
+
Rate the target on a 0-10 scale:
|
|
189
|
+
|
|
190
|
+
| Score | Rating | Meaning |
|
|
191
|
+
|-------|--------|---------|
|
|
192
|
+
| 9-10 | Fortress | Battle-hardened, handles all attack categories |
|
|
193
|
+
| 7-8 | Solid | Handles most attacks, minor edge case gaps |
|
|
194
|
+
| 5-6 | Average | Common attacks handled, but gaps in 1-2 categories |
|
|
195
|
+
| 3-4 | Fragile | Multiple attack categories succeed |
|
|
196
|
+
| 0-2 | Vulnerable | Critical flaws, immediate fixes needed |
|
|
197
|
+
|
|
198
|
+
**Formula:** Start at 10, subtract points per vulnerability:
|
|
199
|
+
- CRITICAL: -3 points
|
|
200
|
+
- HIGH: -2 points
|
|
201
|
+
- MEDIUM: -1 point
|
|
202
|
+
- LOW: -0.5 points (minimum score: 0)
|
|
203
|
+
|
|
204
|
+
## Verification Protocol
|
|
205
|
+
|
|
206
|
+
**Before claiming the grill is complete:**
|
|
207
|
+
|
|
208
|
+
1. All 5 attack categories were tested (input, state, boundary, logic, error path)
|
|
209
|
+
2. Every vulnerability has a severity level and file:line reference
|
|
210
|
+
3. Every vulnerability has a proof (reproducible attack)
|
|
211
|
+
4. Every vulnerability has a concrete fix recommendation
|
|
212
|
+
5. Resilience score was calculated using the formula
|
|
213
|
+
6. At least 10 distinct attacks were attempted across all categories
|
|
214
|
+
7. Type assertions and unsafe patterns were specifically targeted
|
|
215
|
+
|
|
216
|
+
## Anti-Rationalization
|
|
217
|
+
|
|
218
|
+
| Excuse | Reality |
|
|
219
|
+
|--------|---------|
|
|
220
|
+
| "The tests already cover edge cases" | Tests cover what you thought of. Grilling covers what you didn't. Testers think in happy paths; attackers think in failure modes. |
|
|
221
|
+
| "It's internal code, nobody will send bad input" | Internal code today becomes API tomorrow. Internal doesn't mean safe. One refactor exposes it. |
|
|
222
|
+
| "We validate at the API layer" | Defense in depth. If the API layer has a bug, what stops the attack downstream? |
|
|
223
|
+
| "Edge cases are rare in production" | Rare cases cause production incidents. Murphy's law is not optional. The rarer the case, the less likely you tested it. |
|
|
224
|
+
| "This is overkill for a simple function" | Simple functions in critical paths (auth, payments, data) deserve maximum scrutiny. Simplicity doesn't equal safety. |
|
|
225
|
+
| "TypeScript prevents these issues" | TypeScript prevents type errors at compile time. It doesn't prevent logic errors, race conditions, or injection attacks at runtime. |
|
|
226
|
+
| "Nobody would actually try this" | Automated scanners, fuzzing tools, and malicious actors try exactly these attacks. If you don't, they will. |
|
|
227
|
+
|
|
228
|
+
## Rules
|
|
229
|
+
|
|
230
|
+
1. **Assume broken** - Your job is to break the code, not validate it
|
|
231
|
+
2. **All 5 categories** - Never skip an attack category
|
|
232
|
+
3. **Proof required** - Every vulnerability needs a reproducible attack scenario
|
|
233
|
+
4. **Read-only** - Never modify files during a grill (fixes come after)
|
|
234
|
+
5. **No false positives** - Only report vulnerabilities you can prove
|
|
235
|
+
6. **Severity justified** - Every rating needs a specific impact description
|
|
236
|
+
7. **Fix included** - Every vulnerability includes a concrete remediation
|
|
237
|
+
8. **Target scope** - Only grill the specified target, don't drift to other files
|
|
238
|
+
9. **Type assertions are targets** - Every `as`, `!`, and `@ts-ignore` is suspicious until proven safe
|
|
239
|
+
10. **Score is mechanical** - Follow the formula, no subjective adjustments
|
|
240
|
+
|
|
241
|
+
## Output
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
──── /grill ────
|
|
245
|
+
Target: $ARGUMENTS
|
|
246
|
+
Contract: [inputs → outputs]
|
|
247
|
+
Trust boundaries: [N identified]
|
|
248
|
+
|
|
249
|
+
Attacks Attempted: [N]
|
|
250
|
+
Input: [N attempted] → [N succeeded]
|
|
251
|
+
State: [N attempted] → [N succeeded]
|
|
252
|
+
Boundary: [N attempted] → [N succeeded]
|
|
253
|
+
Logic: [N attempted] → [N succeeded]
|
|
254
|
+
Error: [N attempted] → [N succeeded]
|
|
255
|
+
|
|
256
|
+
Vulnerabilities Found: [N]
|
|
257
|
+
CRITICAL: N
|
|
258
|
+
HIGH: N
|
|
259
|
+
MEDIUM: N
|
|
260
|
+
LOW: N
|
|
261
|
+
|
|
262
|
+
Top Vulnerabilities:
|
|
263
|
+
1. [CRITICAL] [description] - [file:line]
|
|
264
|
+
2. [HIGH] [description] - [file:line]
|
|
265
|
+
3. [HIGH] [description] - [file:line]
|
|
266
|
+
|
|
267
|
+
Resilience Score: [N]/10 ([rating])
|
|
268
|
+
|
|
269
|
+
──── Grill complete ────
|
|
270
|
+
```
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: improve-architecture
|
|
3
|
+
description: "Use when the codebase has architectural issues like high coupling, circular dependencies, or unclear boundaries - but a full migration is not needed."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[module, path, or 'full']"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /improve-architecture - Incremental Architecture Improvement
|
|
10
|
+
|
|
11
|
+
Fix architectural issues incrementally - circular dependencies, high coupling, unclear boundaries, god files - without a full migration. Measure before, fix, measure after.
|
|
12
|
+
|
|
13
|
+
**Target:** $ARGUMENTS
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
- Circular dependencies causing build issues or test instability
|
|
18
|
+
- God files (>500 lines) that are hard to maintain
|
|
19
|
+
- Cross-module imports violating layer boundaries
|
|
20
|
+
- High coupling making changes ripple unpredictably
|
|
21
|
+
- Unclear module boundaries after organic growth
|
|
22
|
+
- Before adding a major feature to a messy area
|
|
23
|
+
- NOT for: full architecture pattern migration (use `/migrate-architecture`)
|
|
24
|
+
- NOT for: code-level refactoring without structural issues (use `@refactor`)
|
|
25
|
+
- NOT for: greenfield architecture design (use `@architect`)
|
|
26
|
+
|
|
27
|
+
## Workflow
|
|
28
|
+
|
|
29
|
+
### Step 1: Architecture Scan
|
|
30
|
+
|
|
31
|
+
1. **Map current structure:**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Directory structure overview
|
|
35
|
+
find $TARGET -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.vue" -o -name "*.svelte" \) | head -100
|
|
36
|
+
|
|
37
|
+
# Count lines per file (find god files >500 lines)
|
|
38
|
+
find $TARGET -type f \( -name "*.ts" -o -name "*.tsx" \) -exec wc -l {} + 2>/dev/null | sort -rn | head -20
|
|
39
|
+
|
|
40
|
+
# Find circular dependency candidates (mutual imports)
|
|
41
|
+
for f in $(find $TARGET -name "*.ts" -not -path "*/node_modules/*" | head -50); do
|
|
42
|
+
imports=$(grep -oP "from ['\"]\..*?['\"]" "$f" 2>/dev/null | sed "s/from ['\"]//;s/['\"]//")
|
|
43
|
+
for imp in $imports; do
|
|
44
|
+
target_file=$(realpath --relative-to=. "$(dirname $f)/$imp" 2>/dev/null)
|
|
45
|
+
if [ -f "${target_file}.ts" ] && grep -q "$(basename $f .ts)" "${target_file}.ts" 2>/dev/null; then
|
|
46
|
+
echo "CIRCULAR: $f <-> ${target_file}.ts"
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
done 2>/dev/null | head -20
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. **Read `docs/ARCHITECTURE.md`** if it exists - compare actual vs intended structure
|
|
53
|
+
3. **Identify pain points** with metrics
|
|
54
|
+
|
|
55
|
+
**Output:**
|
|
56
|
+
```markdown
|
|
57
|
+
## Architecture Scan
|
|
58
|
+
|
|
59
|
+
| Metric | Value | Threshold | Status |
|
|
60
|
+
|--------|-------|-----------|--------|
|
|
61
|
+
| God files (>500 lines) | N | 0 | [OK/WARN/FAIL] |
|
|
62
|
+
| Circular dependencies | N | 0 | [OK/WARN/FAIL] |
|
|
63
|
+
| Cross-boundary imports | N | 0 | [OK/WARN/FAIL] |
|
|
64
|
+
| Max file size (lines) | N | 500 | [OK/WARN/FAIL] |
|
|
65
|
+
| Avg module cohesion | [H/M/L] | HIGH | [OK/WARN/FAIL] |
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**BLOCKED** until scan produces metrics.
|
|
69
|
+
|
|
70
|
+
### Step 2: Issue Classification
|
|
71
|
+
|
|
72
|
+
Classify every issue found:
|
|
73
|
+
|
|
74
|
+
| Category | Description | Examples |
|
|
75
|
+
|----------|-------------|---------|
|
|
76
|
+
| **Circular Dependency** | Module A imports B, B imports A | Service ↔ Utility cycles |
|
|
77
|
+
| **Boundary Violation** | Import crosses architectural layer | Component importing from data layer |
|
|
78
|
+
| **God File** | Single file with too many responsibilities | 800-line service doing auth + validation + logging |
|
|
79
|
+
| **Naming Inconsistency** | Files/modules don't follow project conventions | Mix of camelCase and kebab-case |
|
|
80
|
+
| **Missing Abstraction** | Duplicated logic that should be extracted | Same validation in 3 services |
|
|
81
|
+
| **Dead Code** | Unreferenced exports, unused files | Old API endpoints, deprecated utils |
|
|
82
|
+
|
|
83
|
+
For each issue:
|
|
84
|
+
```markdown
|
|
85
|
+
### Issue [N]: [Title]
|
|
86
|
+
- **Category:** [from table above]
|
|
87
|
+
- **Location:** [file:line]
|
|
88
|
+
- **Impact:** HIGH/MEDIUM/LOW
|
|
89
|
+
- **Fix:** [targeted fix description]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**BLOCKED** until all issues are classified with impact levels.
|
|
93
|
+
|
|
94
|
+
### Step 3: Improvement Plan
|
|
95
|
+
|
|
96
|
+
For each issue, define a **targeted fix** (not a rewrite):
|
|
97
|
+
|
|
98
|
+
| Issue Type | Fix Strategy |
|
|
99
|
+
|-----------|-------------|
|
|
100
|
+
| Circular dependency | Extract shared code to a new module, or invert dependency direction |
|
|
101
|
+
| Boundary violation | Move import to correct layer, or create a facade |
|
|
102
|
+
| God file | Extract responsibilities into separate files with single purpose |
|
|
103
|
+
| Naming inconsistency | Rename files/exports to follow established convention |
|
|
104
|
+
| Missing abstraction | Extract shared logic into a utility or service |
|
|
105
|
+
| Dead code | Remove unreferenced exports and files |
|
|
106
|
+
|
|
107
|
+
**Order fixes by dependency** - Fix circular dependencies first (they block other fixes).
|
|
108
|
+
|
|
109
|
+
### Step 4: Incremental Execution
|
|
110
|
+
|
|
111
|
+
Execute fixes **one at a time**, verifying between each:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
FOR each fix in improvement plan (ordered by dependency):
|
|
115
|
+
1. Apply the fix (edit files)
|
|
116
|
+
2. Verify TypeScript compiles:
|
|
117
|
+
tsc --noEmit 2>&1 | head -20
|
|
118
|
+
3. Run tests:
|
|
119
|
+
npm test 2>&1 | tail -20
|
|
120
|
+
4. IF compile or tests fail → REVERT and re-evaluate
|
|
121
|
+
5. IF pass → Mark fix as complete, proceed to next
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**BLOCKED** after each fix until compilation and tests pass.
|
|
125
|
+
|
|
126
|
+
### Step 5: Before/After Metrics
|
|
127
|
+
|
|
128
|
+
Generate a comparison report:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Re-run the same scans from Step 1
|
|
132
|
+
# Compare metrics before and after
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Output:**
|
|
136
|
+
```markdown
|
|
137
|
+
## Before/After
|
|
138
|
+
|
|
139
|
+
| Metric | Before | After | Change |
|
|
140
|
+
|--------|--------|-------|--------|
|
|
141
|
+
| God files | N | N | -N |
|
|
142
|
+
| Circular deps | N | N | -N |
|
|
143
|
+
| Cross-boundary imports | N | N | -N |
|
|
144
|
+
| Max file size | N | N | -N lines |
|
|
145
|
+
| Files changed | - | N | - |
|
|
146
|
+
| Tests passing | ✓ | ✓ | - |
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Verification Protocol
|
|
150
|
+
|
|
151
|
+
**Before claiming improvements are complete:**
|
|
152
|
+
|
|
153
|
+
1. Before/after metrics exist with concrete numbers
|
|
154
|
+
2. TypeScript compiles without errors after every fix
|
|
155
|
+
3. All tests pass after every fix
|
|
156
|
+
4. No new circular dependencies were introduced
|
|
157
|
+
5. Each fix addresses exactly one issue (not bundled changes)
|
|
158
|
+
6. Files were not just renamed - structural improvements were made
|
|
159
|
+
7. `docs/ARCHITECTURE.md` was updated if module boundaries changed
|
|
160
|
+
|
|
161
|
+
## Anti-Rationalization
|
|
162
|
+
|
|
163
|
+
| Excuse | Reality |
|
|
164
|
+
|--------|---------|
|
|
165
|
+
| "The architecture is fine, it works" | Working code with high coupling breaks when you add the next feature. Measure coupling. |
|
|
166
|
+
| "We need a full rewrite" | 90% of architecture issues can be fixed incrementally. Rewrites fail 70% of the time (IEEE study). |
|
|
167
|
+
| "Circular dependencies are harmless" | They cause build failures, test instability, and make modules impossible to extract or test independently. |
|
|
168
|
+
| "Refactoring is not a feature" | Technical debt compounds at ~23% per year (Gartner). Every sprint you delay costs more next sprint. |
|
|
169
|
+
| "We'll improve it in a dedicated sprint" | Dedicated refactoring sprints never get prioritized. Improve incrementally, every sprint. |
|
|
170
|
+
| "Splitting files just creates more files" | More small files with clear names > fewer god files. File count is not complexity. |
|
|
171
|
+
| "The tests still pass so it's fine" | Tests passing means behavior is preserved, not that architecture is healthy. Tests don't catch coupling. |
|
|
172
|
+
|
|
173
|
+
## Rules
|
|
174
|
+
|
|
175
|
+
1. **Measure before fixing** - No improvements without baseline metrics
|
|
176
|
+
2. **One fix at a time** - Never bundle multiple structural changes
|
|
177
|
+
3. **Verify after each fix** - TypeScript + tests must pass before proceeding
|
|
178
|
+
4. **Revert on failure** - If a fix breaks something, undo it and re-evaluate
|
|
179
|
+
5. **No feature changes** - Only structural improvements, never change behavior
|
|
180
|
+
6. **Update docs** - If boundaries change, update ARCHITECTURE.md
|
|
181
|
+
7. **Incremental only** - This skill improves, not migrates. Use `/migrate-architecture` for pattern changes
|
|
182
|
+
8. **Dependency order** - Fix circular dependencies before other issues
|
|
183
|
+
|
|
184
|
+
## Output
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
──── /improve-architecture ────
|
|
188
|
+
Target: $ARGUMENTS
|
|
189
|
+
|
|
190
|
+
Scan Results:
|
|
191
|
+
God files: N → N (-N)
|
|
192
|
+
Circular deps: N → N (-N)
|
|
193
|
+
Boundary violations: N → N (-N)
|
|
194
|
+
Max file size: N → N lines
|
|
195
|
+
|
|
196
|
+
Fixes Applied: N/N
|
|
197
|
+
✓ [Fix 1 description]
|
|
198
|
+
✓ [Fix 2 description]
|
|
199
|
+
✓ [Fix 3 description]
|
|
200
|
+
|
|
201
|
+
Compilation: ✓ passing
|
|
202
|
+
Tests: ✓ passing ([N] tests)
|
|
203
|
+
|
|
204
|
+
──── Architecture improved incrementally ────
|
|
205
|
+
```
|