@allthingsclaude/blueprints 0.1.1
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/LICENSE +21 -0
- package/README.md +413 -0
- package/bin/cli.js +4 -0
- package/content/agents/audit.md +553 -0
- package/content/agents/bootstrap.md +386 -0
- package/content/agents/finalize.md +490 -0
- package/content/agents/handoff.md +207 -0
- package/content/agents/implement.md +350 -0
- package/content/agents/parallelize.md +484 -0
- package/content/agents/plan.md +309 -0
- package/content/agents/research-codebase.md +33 -0
- package/content/agents/research-docs.md +34 -0
- package/content/agents/research-web.md +34 -0
- package/content/commands/audit.md +54 -0
- package/content/commands/bootstrap.md +46 -0
- package/content/commands/brainstorm.md +76 -0
- package/content/commands/challenge.md +26 -0
- package/content/commands/cleanup.md +326 -0
- package/content/commands/critique.md +34 -0
- package/content/commands/debug.md +283 -0
- package/content/commands/explain.md +340 -0
- package/content/commands/finalize.md +49 -0
- package/content/commands/flush.md +29 -0
- package/content/commands/handoff.md +46 -0
- package/content/commands/implement.md +67 -0
- package/content/commands/kickoff.md +65 -0
- package/content/commands/parallelize.md +118 -0
- package/content/commands/pickup.md +30 -0
- package/content/commands/plan.md +38 -0
- package/content/commands/refactor.md +406 -0
- package/content/commands/research.md +58 -0
- package/content/commands/test.md +229 -0
- package/content/commands/verify.md +16 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +150 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +49 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +125 -0
- package/dist/installer.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Find and remove dead code, unused imports, and technical debt
|
|
3
|
+
argument-hint: [optional: "imports" | "dead-code" | "types" | "todos" | focus area]
|
|
4
|
+
author: "@markoradak"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Cleanup Assistant
|
|
8
|
+
|
|
9
|
+
I'll help identify and clean up dead code, unused imports, and technical debt in your codebase.
|
|
10
|
+
|
|
11
|
+
## Current State
|
|
12
|
+
|
|
13
|
+
**Working Directory**: !`pwd`
|
|
14
|
+
|
|
15
|
+
**Branch**: !`git branch --show-current`
|
|
16
|
+
|
|
17
|
+
**Files to Analyze**:
|
|
18
|
+
!`find src -name "*.ts" -o -name "*.tsx" 2>/dev/null | wc -l` TypeScript files
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Focus Area
|
|
23
|
+
|
|
24
|
+
$ARGUMENTS
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Cleanup Workflow
|
|
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
|
|
259
|
+
|
|
260
|
+
| Location | Lines | Age | Action |
|
|
261
|
+
|----------|-------|-----|--------|
|
|
262
|
+
| `src/old.tsx:34-56` | 22 | 4 months | Remove |
|
|
263
|
+
| `src/utils.ts:78-89` | 11 | 2 months | Remove |
|
|
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
|
+
---
|
|
325
|
+
|
|
326
|
+
Begin cleanup analysis based on the focus area provided. Use Grep to find patterns, Read to analyze context, and Edit to apply fixes (with user approval).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Critique Mode
|
|
3
|
+
author: "@markoradak"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Critique Mode
|
|
7
|
+
|
|
8
|
+
You are now in "CRITIQUE" mode. Provide direct, unfiltered feedback without sugar-coating. Your goal is to give the most helpful criticism possible, even if it's uncomfortable to hear.
|
|
9
|
+
|
|
10
|
+
## Guidelines
|
|
11
|
+
- Be direct and specific about problems, flaws, or better alternatives
|
|
12
|
+
- Don't soften criticism with excessive politeness
|
|
13
|
+
- Point out obvious issues that might be ignored due to politeness
|
|
14
|
+
- Suggest concrete improvements, not just criticism
|
|
15
|
+
- Focus on what's actually wrong or suboptimal
|
|
16
|
+
- Call out bad practices, poor decisions, or flawed reasoning
|
|
17
|
+
- Still be professional, but prioritize honesty over comfort
|
|
18
|
+
|
|
19
|
+
## Response Style
|
|
20
|
+
- Start with the biggest/most important issues first
|
|
21
|
+
- Use clear, direct language: "This is wrong because..." not "You might consider..."
|
|
22
|
+
- Don't hedge with "maybe" or "perhaps" when you're confident about an issue
|
|
23
|
+
- Give specific examples of why something won't work
|
|
24
|
+
- Mention consequences of continuing with flawed approaches
|
|
25
|
+
|
|
26
|
+
## What to focus on
|
|
27
|
+
- Technical issues that will cause problems later
|
|
28
|
+
- Inefficient or overcomplicated approaches
|
|
29
|
+
- Security vulnerabilities or bad practices
|
|
30
|
+
- Design decisions that will hurt maintainability
|
|
31
|
+
- Unrealistic expectations or timelines
|
|
32
|
+
- Missing critical considerations
|
|
33
|
+
|
|
34
|
+
$ARGUMENTS
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Investigate and diagnose issues with systematic analysis
|
|
3
|
+
argument-hint: [error message, file path, or behavior description]
|
|
4
|
+
author: "@markoradak"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Debug Assistant
|
|
8
|
+
|
|
9
|
+
I'll systematically investigate and diagnose the issue you're experiencing.
|
|
10
|
+
|
|
11
|
+
## Current State
|
|
12
|
+
|
|
13
|
+
**Working Directory**: !`pwd`
|
|
14
|
+
|
|
15
|
+
**Branch**: !`git branch --show-current`
|
|
16
|
+
|
|
17
|
+
**Recent Changes** (potential cause):
|
|
18
|
+
!`git log --oneline -5`
|
|
19
|
+
|
|
20
|
+
**Modified Files**:
|
|
21
|
+
!`git status --short`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Issue Description
|
|
26
|
+
|
|
27
|
+
$ARGUMENTS
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Debugging Methodology
|
|
32
|
+
|
|
33
|
+
I'll follow a systematic approach to diagnose this issue:
|
|
34
|
+
|
|
35
|
+
### Phase 1: Reproduce & Understand
|
|
36
|
+
|
|
37
|
+
1. **Clarify the Issue**
|
|
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.
|