@allthingsclaude/blueprints 0.2.0 → 0.3.0-beta.10
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 +80 -12
- package/content/agents/audit.md +40 -25
- package/content/agents/bootstrap.md +25 -5
- package/content/agents/changelog.md +350 -0
- package/content/agents/cleanup.md +155 -0
- package/content/agents/commit.md +235 -0
- package/content/agents/debug.md +198 -0
- package/content/agents/docs.md +344 -0
- package/content/agents/{optimize.md → dry.md} +38 -15
- package/content/agents/explain.md +195 -0
- package/content/agents/finalize.md +20 -5
- package/content/agents/handoff.md +11 -5
- package/content/agents/imagine.md +2 -2
- package/content/agents/implement.md +54 -16
- package/content/agents/migrate.md +330 -0
- package/content/agents/parallelize.md +21 -4
- package/content/agents/plan.md +35 -5
- package/content/agents/refactor.md +156 -0
- package/content/agents/release.md +502 -0
- package/content/agents/research-codebase.md +160 -18
- package/content/agents/research-docs.md +135 -19
- package/content/agents/research-web.md +149 -19
- package/content/agents/secure.md +351 -0
- package/content/agents/storyboard.md +11 -5
- package/content/agents/test.md +181 -0
- package/content/commands/audit.md +15 -24
- package/content/commands/auto.md +361 -0
- package/content/commands/bootstrap.md +2 -2
- package/content/commands/brainstorm.md +63 -9
- package/content/commands/challenge.md +7 -0
- package/content/commands/changelog.md +50 -0
- package/content/commands/cleanup.md +14 -301
- package/content/commands/commit.md +45 -0
- package/content/commands/critique.md +7 -0
- package/content/commands/debug.md +9 -251
- package/content/commands/docs.md +48 -0
- package/content/commands/dry.md +48 -0
- package/content/commands/explain.md +12 -309
- package/content/commands/finalize.md +3 -3
- package/content/commands/flush.md +9 -14
- package/content/commands/handoff.md +1 -1
- package/content/commands/implement.md +5 -5
- package/content/commands/kickoff.md +7 -4
- package/content/commands/migrate.md +54 -0
- package/content/commands/parallelize.md +2 -2
- package/content/commands/pickup.md +1 -1
- package/content/commands/plan.md +2 -2
- package/content/commands/refactor.md +21 -379
- package/content/commands/release.md +63 -0
- package/content/commands/research.md +1 -1
- package/content/commands/secure.md +51 -0
- package/content/commands/storyboard.md +3 -3
- package/content/commands/test.md +15 -201
- package/content/commands/verify.md +7 -0
- package/dist/cli.js +47 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +29 -4
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +120 -17
- package/dist/installer.js.map +1 -1
- package/package.json +5 -1
- package/content/commands/optimize.md +0 -338
|
@@ -4,18 +4,20 @@ argument-hint: [optional: "imports" | "dead-code" | "types" | "todos" | focus ar
|
|
|
4
4
|
author: "@markoradak"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# Code Cleanup
|
|
7
|
+
# Code Cleanup
|
|
8
8
|
|
|
9
|
-
I'll
|
|
9
|
+
I'll scan your codebase for dead code, unused imports, and technical debt.
|
|
10
|
+
|
|
11
|
+
> **When to use**: You want to remove things that shouldn't be there (unused imports, dead exports, stale TODOs, console.logs). Use `/dry` to consolidate duplicated code, `/refactor` for structural changes, or `/audit` to review changes before committing.
|
|
10
12
|
|
|
11
13
|
## Current State
|
|
12
14
|
|
|
13
15
|
**Working Directory**: !`pwd`
|
|
14
16
|
|
|
15
|
-
**Branch**: !`git branch --show-current`
|
|
17
|
+
**Branch**: !`git branch --show-current 2>/dev/null || echo "Not a git repository"`
|
|
16
18
|
|
|
17
19
|
**Files to Analyze**:
|
|
18
|
-
!`find
|
|
20
|
+
!`find . -maxdepth 5 -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" 2>/dev/null | grep -v node_modules | wc -l` source files
|
|
19
21
|
|
|
20
22
|
---
|
|
21
23
|
|
|
@@ -25,302 +27,13 @@ $ARGUMENTS
|
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
28
|
-
## Cleanup
|
|
29
|
-
|
|
30
|
-
Based on the arguments, I'll focus on specific cleanup tasks:
|
|
31
|
-
|
|
32
|
-
### If "imports" or no argument:
|
|
33
|
-
- Find and remove unused imports
|
|
34
|
-
- Organize import order
|
|
35
|
-
- Remove duplicate imports
|
|
36
|
-
|
|
37
|
-
### If "dead-code":
|
|
38
|
-
- Find unreferenced exports
|
|
39
|
-
- Identify unused functions/components
|
|
40
|
-
- Detect unreachable code
|
|
41
|
-
|
|
42
|
-
### If "types":
|
|
43
|
-
- Audit `any` usage
|
|
44
|
-
- Find implicit any
|
|
45
|
-
- Identify redundant type assertions
|
|
46
|
-
|
|
47
|
-
### If "todos":
|
|
48
|
-
- Inventory all TODO/FIXME/HACK comments
|
|
49
|
-
- Categorize by priority
|
|
50
|
-
- Suggest which to address or remove
|
|
51
|
-
|
|
52
|
-
### If specific file/folder provided:
|
|
53
|
-
- Deep cleanup of that area only
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Cleanup Categories
|
|
58
|
-
|
|
59
|
-
### 1. Unused Imports
|
|
60
|
-
|
|
61
|
-
**Detection**:
|
|
62
|
-
```bash
|
|
63
|
-
# ESLint can find these
|
|
64
|
-
pnpm eslint src --rule '@typescript-eslint/no-unused-vars: error' --format compact 2>&1 | grep "no-unused-vars"
|
|
65
|
-
|
|
66
|
-
# Or check specific file
|
|
67
|
-
grep -E "^import" path/to/file.ts
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Cleanup Strategy**:
|
|
71
|
-
- Remove imports not referenced in the file
|
|
72
|
-
- Remove type-only imports if types aren't used
|
|
73
|
-
- Consolidate multiple imports from same module
|
|
74
|
-
|
|
75
|
-
### 2. Dead Code
|
|
76
|
-
|
|
77
|
-
**Detection Patterns**:
|
|
78
|
-
|
|
79
|
-
**Unreferenced Exports**:
|
|
80
|
-
```bash
|
|
81
|
-
# Find all exports
|
|
82
|
-
grep -rn "export " src/ --include="*.ts" --include="*.tsx"
|
|
83
|
-
|
|
84
|
-
# Check if each is imported anywhere
|
|
85
|
-
grep -rn "import.*{.*ExportName" src/
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Unused Functions**:
|
|
89
|
-
- Functions defined but never called
|
|
90
|
-
- Event handlers attached to removed elements
|
|
91
|
-
- Utility functions from old features
|
|
92
|
-
|
|
93
|
-
**Unreachable Code**:
|
|
94
|
-
- Code after return/throw statements
|
|
95
|
-
- Conditions that can never be true
|
|
96
|
-
- Catch blocks for errors that can't occur
|
|
97
|
-
|
|
98
|
-
### 3. Type Cleanup
|
|
99
|
-
|
|
100
|
-
**`any` Audit**:
|
|
101
|
-
```bash
|
|
102
|
-
# Find explicit any
|
|
103
|
-
grep -rn ": any" src/ --include="*.ts" --include="*.tsx"
|
|
104
|
-
|
|
105
|
-
# Find any in function parameters
|
|
106
|
-
grep -rn "(.*any.*)" src/ --include="*.ts"
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
**Categories**:
|
|
110
|
-
- **Justified**: External library types, truly dynamic data
|
|
111
|
-
- **Lazy**: Should be properly typed
|
|
112
|
-
- **Accidental**: Implicit any from missing types
|
|
113
|
-
|
|
114
|
-
### 4. TODO/FIXME Inventory
|
|
115
|
-
|
|
116
|
-
**Detection**:
|
|
117
|
-
```bash
|
|
118
|
-
# Find all TODOs
|
|
119
|
-
grep -rn "TODO\|FIXME\|HACK\|XXX" src/ --include="*.ts" --include="*.tsx"
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**Categories**:
|
|
123
|
-
- **Stale**: Old TODOs that are no longer relevant
|
|
124
|
-
- **Completed**: Work is done but comment remains
|
|
125
|
-
- **Valid**: Still needs to be done
|
|
126
|
-
- **Won't Do**: Decided against implementing
|
|
127
|
-
|
|
128
|
-
### 5. Console Statements
|
|
129
|
-
|
|
130
|
-
**Detection**:
|
|
131
|
-
```bash
|
|
132
|
-
# Find console.log/warn/error
|
|
133
|
-
grep -rn "console\." src/ --include="*.ts" --include="*.tsx"
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Categories**:
|
|
137
|
-
- **Debug**: Should be removed
|
|
138
|
-
- **Intentional**: Error logging, should use proper logger
|
|
139
|
-
- **Temporary**: Left from debugging session
|
|
140
|
-
|
|
141
|
-
### 6. Commented Code
|
|
142
|
-
|
|
143
|
-
**Detection**:
|
|
144
|
-
- Large blocks of commented-out code
|
|
145
|
-
- Commented function definitions
|
|
146
|
-
- "Old" or "backup" comments
|
|
147
|
-
|
|
148
|
-
**Policy**:
|
|
149
|
-
- If it's in git history, delete it
|
|
150
|
-
- If it might be needed, create a branch
|
|
151
|
-
- Never commit commented-out code
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## Cleanup Report Format
|
|
156
|
-
|
|
157
|
-
```markdown
|
|
158
|
-
# Cleanup Report
|
|
159
|
-
|
|
160
|
-
**Scanned**: [X] files in [path]
|
|
161
|
-
**Date**: [timestamp]
|
|
162
|
-
**Focus**: [area or "all"]
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## Summary
|
|
167
|
-
|
|
168
|
-
| Category | Found | Auto-fixable | Manual Review |
|
|
169
|
-
|----------|-------|--------------|---------------|
|
|
170
|
-
| Unused Imports | X | X | 0 |
|
|
171
|
-
| Dead Code | X | 0 | X |
|
|
172
|
-
| `any` Types | X | 0 | X |
|
|
173
|
-
| TODOs | X | N/A | X |
|
|
174
|
-
| Console Statements | X | X | 0 |
|
|
175
|
-
| Commented Code | X | X | 0 |
|
|
176
|
-
|
|
177
|
-
**Estimated Impact**: -[X] lines of code
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## Unused Imports
|
|
182
|
-
|
|
183
|
-
### `src/components/Example.tsx`
|
|
184
|
-
|
|
185
|
-
**Remove**:
|
|
186
|
-
```typescript
|
|
187
|
-
// Line 3: unused
|
|
188
|
-
import { unusedFunction } from '@/lib/utils'
|
|
189
|
-
|
|
190
|
-
// Line 5: only 'used' is used, remove 'unused'
|
|
191
|
-
import { used, unused } from '@/lib/helpers'
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
**After**:
|
|
195
|
-
```typescript
|
|
196
|
-
import { used } from '@/lib/helpers'
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
## Dead Code
|
|
202
|
-
|
|
203
|
-
### Unreferenced Exports
|
|
204
|
-
|
|
205
|
-
| Export | File | Last Modified | Recommendation |
|
|
206
|
-
|--------|------|---------------|----------------|
|
|
207
|
-
| `oldHelper` | `src/lib/utils.ts:45` | 3 months ago | Remove |
|
|
208
|
-
| `deprecatedFn` | `src/lib/api.ts:123` | 6 months ago | Remove |
|
|
209
|
-
|
|
210
|
-
### Unused Functions
|
|
211
|
-
|
|
212
|
-
**`src/lib/helpers.ts:78`** - `formatOldDate()`
|
|
213
|
-
- Not imported anywhere
|
|
214
|
-
- Last modified: [date]
|
|
215
|
-
- **Recommendation**: Remove
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
## Type Issues
|
|
220
|
-
|
|
221
|
-
### `any` Usage
|
|
222
|
-
|
|
223
|
-
| Location | Context | Recommendation |
|
|
224
|
-
|----------|---------|----------------|
|
|
225
|
-
| `src/api/route.ts:23` | API response | Type as `ApiResponse` |
|
|
226
|
-
| `src/utils/parse.ts:45` | JSON parse | Use `unknown` + validation |
|
|
227
|
-
| `src/lib/external.ts:12` | 3rd party | Justified - add comment |
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
## TODO Inventory
|
|
232
|
-
|
|
233
|
-
### Stale (Remove)
|
|
234
|
-
|
|
235
|
-
- `src/old.ts:45`: "TODO: refactor this" (file deleted 2 months ago)
|
|
236
|
-
- `src/api.ts:23`: "FIXME: temporary" (been there 6 months)
|
|
237
|
-
|
|
238
|
-
### Valid (Keep/Address)
|
|
239
|
-
|
|
240
|
-
- `src/auth.ts:89`: "TODO: add rate limiting" - Still needed
|
|
241
|
-
- `src/db.ts:34`: "FIXME: optimize query" - Performance issue
|
|
242
|
-
|
|
243
|
-
### Completed (Remove)
|
|
244
|
-
|
|
245
|
-
- `src/user.ts:56`: "TODO: add validation" - Validation exists
|
|
246
|
-
|
|
247
|
-
---
|
|
248
|
-
|
|
249
|
-
## Console Statements
|
|
250
|
-
|
|
251
|
-
| Location | Type | Action |
|
|
252
|
-
|----------|------|--------|
|
|
253
|
-
| `src/debug.ts:12` | `console.log` | Remove (debug) |
|
|
254
|
-
| `src/api.ts:45` | `console.error` | Replace with logger |
|
|
255
|
-
|
|
256
|
-
---
|
|
257
|
-
|
|
258
|
-
## Commented Code
|
|
30
|
+
## Launching Cleanup Agent
|
|
259
31
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
## Recommended Actions
|
|
268
|
-
|
|
269
|
-
### Auto-fix (Safe)
|
|
270
|
-
|
|
271
|
-
These can be automatically cleaned up:
|
|
272
|
-
|
|
273
|
-
1. [ ] Remove unused imports
|
|
274
|
-
2. [ ] Remove console.log statements
|
|
275
|
-
3. [ ] Remove commented-out code
|
|
276
|
-
|
|
277
|
-
Run: "Would you like me to auto-fix these?"
|
|
278
|
-
|
|
279
|
-
### Manual Review Required
|
|
280
|
-
|
|
281
|
-
These need human decision:
|
|
282
|
-
|
|
283
|
-
1. [ ] Review dead code exports before removal
|
|
284
|
-
2. [ ] Decide on TODO items
|
|
285
|
-
3. [ ] Type the `any` usages appropriately
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## Next Steps
|
|
290
|
-
|
|
291
|
-
1. Review this report
|
|
292
|
-
2. Approve auto-fixes
|
|
293
|
-
3. Address manual review items
|
|
294
|
-
4. Run `pnpm typecheck && pnpm lint` to verify
|
|
295
|
-
5. Commit cleanup: `git commit -m "chore: code cleanup"`
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
---
|
|
299
|
-
|
|
300
|
-
## Auto-Fix Capabilities
|
|
301
|
-
|
|
302
|
-
When user approves, I can automatically:
|
|
303
|
-
|
|
304
|
-
- **Remove unused imports**: Edit files to remove
|
|
305
|
-
- **Remove console statements**: Edit to remove (except console.error in catch blocks)
|
|
306
|
-
- **Remove commented code**: Edit to remove blocks
|
|
307
|
-
- **Organize imports**: Sort and group imports
|
|
308
|
-
|
|
309
|
-
I will NOT automatically:
|
|
310
|
-
- Remove functions (might have dynamic usage)
|
|
311
|
-
- Change `any` types (needs proper typing)
|
|
312
|
-
- Remove TODOs (needs human decision)
|
|
313
|
-
- Remove exports (might be used externally)
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## Safety Guidelines
|
|
318
|
-
|
|
319
|
-
1. **Always validate after cleanup**: Run typecheck and lint
|
|
320
|
-
2. **Review before committing**: Show git diff
|
|
321
|
-
3. **Don't break functionality**: When in doubt, leave it
|
|
322
|
-
4. **Track what was removed**: Clear commit message
|
|
323
|
-
|
|
324
|
-
---
|
|
32
|
+
The cleanup agent will:
|
|
33
|
+
- Detect your toolchain (package manager, available scripts)
|
|
34
|
+
- Scan for unused imports, dead code, `any` types, stale TODOs, console statements, and commented-out code
|
|
35
|
+
- Generate a structured report with file:line references
|
|
36
|
+
- Offer auto-fix for safe changes (with your approval)
|
|
37
|
+
- Validate that nothing breaks after cleanup
|
|
325
38
|
|
|
326
|
-
|
|
39
|
+
Use the Task tool to launch the cleanup agent (subagent_type="cleanup") with the focus area and any additional context from arguments.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a well-crafted git commit from your current changes
|
|
3
|
+
argument-hint: [optional: commit message hint or scope]
|
|
4
|
+
author: "@markoradak"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Commit Changes
|
|
8
|
+
|
|
9
|
+
I'll analyze your changes and create a clean, well-structured git commit.
|
|
10
|
+
|
|
11
|
+
> **When to use**: You have changes ready to commit and want a good commit message without the full session finalization. Use `/finalize` when closing out a work session with plan updates and phase summaries. Use `/audit` to review changes before committing.
|
|
12
|
+
|
|
13
|
+
## Current State
|
|
14
|
+
|
|
15
|
+
**Working Directory**: !`pwd`
|
|
16
|
+
|
|
17
|
+
**Branch**: !`git branch --show-current 2>/dev/null || echo "Not a git repository"`
|
|
18
|
+
|
|
19
|
+
**Status**:
|
|
20
|
+
!`git status --short`
|
|
21
|
+
|
|
22
|
+
**Changes Summary**:
|
|
23
|
+
!`git diff --stat`
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Context
|
|
28
|
+
|
|
29
|
+
$ARGUMENTS
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Launching Commit Agent
|
|
34
|
+
|
|
35
|
+
The commit agent will:
|
|
36
|
+
- Review all staged and unstaged changes
|
|
37
|
+
- Understand the intent and scope of the changes
|
|
38
|
+
- Determine the appropriate commit type (`feat`, `fix`, `refactor`, etc.)
|
|
39
|
+
- Draft a concise, well-formatted commit message
|
|
40
|
+
- Stage the relevant files and create the commit
|
|
41
|
+
- Verify the commit was created successfully
|
|
42
|
+
|
|
43
|
+
**This will create a git commit.** The agent will show you the proposed message before committing.
|
|
44
|
+
|
|
45
|
+
Use the Task tool to launch the commit agent (subagent_type="commit") with any additional context from arguments.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Critique Mode
|
|
3
|
+
argument-hint: [optional: code, design, or approach to critique]
|
|
3
4
|
author: "@markoradak"
|
|
4
5
|
---
|
|
5
6
|
|
|
@@ -31,4 +32,10 @@ You are now in "CRITIQUE" mode. Provide direct, unfiltered feedback without suga
|
|
|
31
32
|
- Unrealistic expectations or timelines
|
|
32
33
|
- Missing critical considerations
|
|
33
34
|
|
|
35
|
+
## Scope
|
|
36
|
+
|
|
37
|
+
This mode applies to the current task or topic. Once the critique is delivered, normal conversation resumes.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
34
41
|
$ARGUMENTS
|
|
@@ -12,7 +12,7 @@ I'll systematically investigate and diagnose the issue you're experiencing.
|
|
|
12
12
|
|
|
13
13
|
**Working Directory**: !`pwd`
|
|
14
14
|
|
|
15
|
-
**Branch**: !`git branch --show-current`
|
|
15
|
+
**Branch**: !`git branch --show-current 2>/dev/null || echo "Not a git repository"`
|
|
16
16
|
|
|
17
17
|
**Recent Changes** (potential cause):
|
|
18
18
|
!`git log --oneline -5`
|
|
@@ -28,256 +28,14 @@ $ARGUMENTS
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Launching Debug Agent
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The debug agent will follow a systematic 4-phase methodology:
|
|
34
|
+
1. **Reproduce & Understand** — Clarify the issue, gather context
|
|
35
|
+
2. **Isolate the Problem** — Narrow scope, trace data flow
|
|
36
|
+
3. **Root Cause Analysis** — Identify candidates, verify hypothesis
|
|
37
|
+
4. **Resolution** — Develop fix, suggest prevention
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
It will produce a structured diagnosis report with root cause, investigation trail, recommended fixes, and verification steps.
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
- What is the expected behavior?
|
|
39
|
-
- What is the actual behavior?
|
|
40
|
-
- When did this start happening?
|
|
41
|
-
- Is it reproducible consistently?
|
|
42
|
-
|
|
43
|
-
2. **Gather Context**
|
|
44
|
-
- Check error messages and stack traces
|
|
45
|
-
- Review relevant logs
|
|
46
|
-
- Identify affected files/components
|
|
47
|
-
|
|
48
|
-
### Phase 2: Isolate the Problem
|
|
49
|
-
|
|
50
|
-
3. **Narrow Down the Scope**
|
|
51
|
-
- Which layer is the issue in? (UI, API, DB, external service)
|
|
52
|
-
- Is it environment-specific? (dev, prod, test)
|
|
53
|
-
- Does it affect all users/data or specific cases?
|
|
54
|
-
|
|
55
|
-
4. **Trace Data Flow**
|
|
56
|
-
- Follow the execution path
|
|
57
|
-
- Check input/output at each step
|
|
58
|
-
- Identify where behavior diverges from expected
|
|
59
|
-
|
|
60
|
-
### Phase 3: Root Cause Analysis
|
|
61
|
-
|
|
62
|
-
5. **Identify Candidates**
|
|
63
|
-
- Recent code changes (git blame, git log)
|
|
64
|
-
- Configuration changes
|
|
65
|
-
- Dependency updates
|
|
66
|
-
- External factors (API changes, data issues)
|
|
67
|
-
|
|
68
|
-
6. **Verify Hypothesis**
|
|
69
|
-
- Test each candidate systematically
|
|
70
|
-
- Use console.log/debugger strategically
|
|
71
|
-
- Check edge cases and boundary conditions
|
|
72
|
-
|
|
73
|
-
### Phase 4: Resolution
|
|
74
|
-
|
|
75
|
-
7. **Develop Fix**
|
|
76
|
-
- Address root cause, not symptoms
|
|
77
|
-
- Consider side effects
|
|
78
|
-
- Validate fix doesn't break other things
|
|
79
|
-
|
|
80
|
-
8. **Prevent Recurrence**
|
|
81
|
-
- Add test coverage
|
|
82
|
-
- Improve error handling
|
|
83
|
-
- Update documentation if needed
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Diagnostic Commands
|
|
88
|
-
|
|
89
|
-
### Error Analysis
|
|
90
|
-
```bash
|
|
91
|
-
# Search for error patterns in logs
|
|
92
|
-
grep -r "error" .next/server/ 2>/dev/null | tail -20
|
|
93
|
-
|
|
94
|
-
# Check recent console output
|
|
95
|
-
# (User should provide if available)
|
|
96
|
-
|
|
97
|
-
# TypeScript errors
|
|
98
|
-
pnpm typecheck 2>&1 | head -50
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Code Investigation
|
|
102
|
-
```bash
|
|
103
|
-
# Find where something is defined
|
|
104
|
-
grep -rn "functionName" src/
|
|
105
|
-
|
|
106
|
-
# Check recent changes to a file
|
|
107
|
-
git log -p --follow -5 -- path/to/file.ts
|
|
108
|
-
|
|
109
|
-
# Find all usages of a function/component
|
|
110
|
-
grep -rn "ComponentName" src/
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Runtime Investigation
|
|
114
|
-
```bash
|
|
115
|
-
# Check if dev server is running
|
|
116
|
-
lsof -i :3000 2>/dev/null || echo "Port 3000 not in use"
|
|
117
|
-
|
|
118
|
-
# Check environment
|
|
119
|
-
env | grep -E "^(DATABASE|NEXT|NODE)" | head -10
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Database Investigation
|
|
123
|
-
```bash
|
|
124
|
-
# Check Prisma schema
|
|
125
|
-
cat prisma/schema.prisma | grep -A5 "model"
|
|
126
|
-
|
|
127
|
-
# Verify database connection
|
|
128
|
-
pnpm prisma db pull --print 2>&1 | head -20
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Common Issue Patterns
|
|
134
|
-
|
|
135
|
-
### TypeScript Errors
|
|
136
|
-
- **"Cannot find module"**: Check imports, paths, tsconfig
|
|
137
|
-
- **"Type X is not assignable"**: Verify types match at boundaries
|
|
138
|
-
- **"Property does not exist"**: Check object shape, optional chaining
|
|
139
|
-
|
|
140
|
-
### React/Next.js Issues
|
|
141
|
-
- **Hydration mismatch**: Server/client rendering differences
|
|
142
|
-
- **"use client" missing**: Server component using client features
|
|
143
|
-
- **Stale data**: Cache invalidation, revalidation issues
|
|
144
|
-
|
|
145
|
-
### API/tRPC Issues
|
|
146
|
-
- **401/403**: Authentication/authorization check
|
|
147
|
-
- **500**: Server-side error, check logs
|
|
148
|
-
- **Network error**: CORS, URL configuration
|
|
149
|
-
|
|
150
|
-
### Database Issues
|
|
151
|
-
- **Connection refused**: Check DATABASE_URL, server running
|
|
152
|
-
- **Unique constraint**: Duplicate data, check upsert logic
|
|
153
|
-
- **Foreign key violation**: Related record doesn't exist
|
|
154
|
-
|
|
155
|
-
### Build Issues
|
|
156
|
-
- **Module not found**: Check dependencies, imports
|
|
157
|
-
- **Out of memory**: Increase Node memory, check for loops
|
|
158
|
-
- **Type errors**: Run `pnpm typecheck` for details
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## Output Format
|
|
163
|
-
|
|
164
|
-
After investigation, provide a structured diagnosis:
|
|
165
|
-
|
|
166
|
-
```markdown
|
|
167
|
-
# Diagnosis Report
|
|
168
|
-
|
|
169
|
-
**Issue**: [One-line summary]
|
|
170
|
-
**Severity**: [Critical/High/Medium/Low]
|
|
171
|
-
**Category**: [TypeScript/Runtime/Database/Network/Configuration]
|
|
172
|
-
|
|
173
|
-
---
|
|
174
|
-
|
|
175
|
-
## Summary
|
|
176
|
-
|
|
177
|
-
[2-3 sentence overview of what's happening and why]
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
## Root Cause
|
|
182
|
-
|
|
183
|
-
**Location**: `path/to/file.ts:123`
|
|
184
|
-
|
|
185
|
-
**Problem**: [Detailed explanation of the root cause]
|
|
186
|
-
|
|
187
|
-
**Evidence**:
|
|
188
|
-
- [Finding 1 that supports this diagnosis]
|
|
189
|
-
- [Finding 2]
|
|
190
|
-
- [Relevant code snippet or error message]
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## Investigation Trail
|
|
195
|
-
|
|
196
|
-
1. **Checked**: [What was investigated]
|
|
197
|
-
- **Finding**: [What was found]
|
|
198
|
-
|
|
199
|
-
2. **Checked**: [Next investigation step]
|
|
200
|
-
- **Finding**: [Result]
|
|
201
|
-
|
|
202
|
-
3. **Conclusion**: [How findings led to root cause]
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
## Recommended Fix
|
|
207
|
-
|
|
208
|
-
### Option 1: [Primary fix] (Recommended)
|
|
209
|
-
|
|
210
|
-
**File**: `path/to/file.ts:123`
|
|
211
|
-
|
|
212
|
-
**Current Code**:
|
|
213
|
-
```typescript
|
|
214
|
-
// problematic code
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
**Fixed Code**:
|
|
218
|
-
```typescript
|
|
219
|
-
// corrected code
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
**Why This Works**: [Explanation]
|
|
223
|
-
|
|
224
|
-
### Option 2: [Alternative fix]
|
|
225
|
-
|
|
226
|
-
[If there's a reasonable alternative approach]
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Verification Steps
|
|
231
|
-
|
|
232
|
-
1. [ ] Apply the fix
|
|
233
|
-
2. [ ] Run `pnpm typecheck` - should pass
|
|
234
|
-
3. [ ] Run `pnpm lint` - should pass
|
|
235
|
-
4. [ ] Test the specific scenario that was failing
|
|
236
|
-
5. [ ] Run related tests: `pnpm test [pattern]`
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## Prevention
|
|
241
|
-
|
|
242
|
-
- [ ] Add test case for this scenario
|
|
243
|
-
- [ ] Consider adding validation at [location]
|
|
244
|
-
- [ ] Update documentation if behavior was unclear
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
## Related Files
|
|
249
|
-
|
|
250
|
-
- `path/to/related.ts` - [Why relevant]
|
|
251
|
-
- `path/to/another.ts` - [Why relevant]
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
## Investigation Strategies by Issue Type
|
|
257
|
-
|
|
258
|
-
### "It was working before"
|
|
259
|
-
1. Check `git log` for recent changes
|
|
260
|
-
2. Use `git bisect` to find breaking commit
|
|
261
|
-
3. Review dependency updates in package.json
|
|
262
|
-
|
|
263
|
-
### "It works locally but not in production"
|
|
264
|
-
1. Compare environment variables
|
|
265
|
-
2. Check build output differences
|
|
266
|
-
3. Review deployment logs
|
|
267
|
-
4. Verify database state
|
|
268
|
-
|
|
269
|
-
### "It works sometimes"
|
|
270
|
-
1. Look for race conditions
|
|
271
|
-
2. Check for timing-dependent logic
|
|
272
|
-
3. Review caching behavior
|
|
273
|
-
4. Check for data-dependent paths
|
|
274
|
-
|
|
275
|
-
### "The error message doesn't make sense"
|
|
276
|
-
1. Find where the error is thrown
|
|
277
|
-
2. Check what condition triggers it
|
|
278
|
-
3. Add logging to trace the path
|
|
279
|
-
4. Look for error transformation/wrapping
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
Begin systematic investigation based on the issue description provided. Use Read to examine files, Grep to search for patterns, and Bash for diagnostics. Ask clarifying questions if the issue description is insufficient.
|
|
41
|
+
Use the Task tool to launch the debug agent (subagent_type="debug") with the issue description and any additional context from arguments.
|