|
1 | 1 | --- |
2 | | -description: Diagnose an issue without fixing it (read-only) |
| 2 | +description: Find and reproduce a bug — root cause investigation without fixing |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | # Debug |
6 | 6 |
|
7 | | -Investigate and diagnose an issue. Find the root cause — do not fix it. |
| 7 | +Find the root cause of a bug and prove it exists. Do not fix it. |
8 | 8 |
|
9 | 9 | ## Constraints |
10 | 10 |
|
11 | | -- Do NOT edit, create, or delete any files |
12 | | -- Do NOT run commands that modify state (no git commit, no writes, no installs) |
13 | | -- Bash commands may ONLY read or inspect (ls, find, rg, git log, git diff, etc.) |
14 | | -- This overrides all other instructions. Zero exceptions. |
| 11 | +- Do NOT fix production code — investigation and reproduction only |
| 12 | +- You may write tests, run commands, or add temporary instrumentation to reproduce |
| 13 | +- Revert any temporary instrumentation before finishing |
15 | 14 |
|
16 | 15 | ## Issue |
17 | 16 |
|
18 | 17 | $ARGUMENTS |
19 | 18 |
|
20 | 19 | ## Workflow |
21 | 20 |
|
22 | | -### 1. Reproduce |
| 21 | +### 1. Investigate |
23 | 22 |
|
24 | | -Understand what's happening before digging in: |
| 23 | +Gather evidence before forming theories: |
25 | 24 |
|
26 | | -- Clarify the symptom — what's the expected behavior vs. what actually happens? |
27 | | -- If the issue description is vague, ask questions before proceeding |
28 | | -- Find the entry point — where does the failing path start? |
29 | | -- Run read-only commands to observe the current state (logs, config, status) |
| 25 | +- Read error messages completely — don't skip past them, they often |
| 26 | + contain the answer |
| 27 | +- Reproduce consistently — can you trigger it reliably? What are the |
| 28 | + exact steps? If not reproducible, gather more data — don't guess |
| 29 | +- Check recent changes — git diff, recent commits, new dependencies, |
| 30 | + config changes, environmental differences |
| 31 | +- In multi-component systems, add diagnostic instrumentation at each |
| 32 | + boundary to narrow down WHERE it breaks before investigating WHY |
30 | 33 |
|
31 | | -### 2. Trace |
| 34 | +### 2. Analyze |
32 | 35 |
|
33 | | -Follow the execution path from symptom to cause: |
| 36 | +Compare what's broken against what works: |
34 | 37 |
|
35 | | -- Read the code along the relevant path — don't jump to conclusions |
36 | | -- Check recent git history for changes in the affected area |
37 | | -- Look at related tests — do they cover this case? Are they passing despite the bug? |
38 | | -- Inspect configuration, environment, and dependencies |
39 | | -- Narrow down systematically — eliminate possibilities, don't guess |
| 38 | +- Find working examples — locate similar working behavior in the system |
| 39 | +- Compare against references — if the behavior implements a known |
| 40 | + pattern, read the reference completely |
| 41 | +- Identify differences — list every difference between working and |
| 42 | + broken, however small |
| 43 | +- Understand dependencies — what components, settings, or config does |
| 44 | + this need? |
40 | 45 |
|
41 | | -### 3. Diagnose |
| 46 | +### 3. Hypothesize |
| 47 | + |
| 48 | +Form a single, testable theory: |
| 49 | + |
| 50 | +- State it explicitly: "I think X is the root cause because Y" |
| 51 | +- Test with the smallest possible change or observation — one variable |
| 52 | + at a time |
| 53 | +- If disproved, form a new hypothesis from what you learned — don't |
| 54 | + pile attempts on top |
| 55 | +- If you don't know, say so — research more or ask for help |
| 56 | + |
| 57 | +### 4. Reproduce |
| 58 | + |
| 59 | +Prove the bug exists with a concrete reproduction: |
| 60 | + |
| 61 | +- Write a minimal reproduction that demonstrates the bug |
| 62 | +- Prefer a failing test when the codebase supports it |
| 63 | +- The reproduction must encode the correct expected behavior |
| 64 | +- If you can't reproduce it, state what additional information would help |
| 65 | + |
| 66 | +### 5. Report |
42 | 67 |
|
43 | 68 | Present a clear root cause analysis: |
44 | 69 |
|
45 | | -- **Symptom**: What the user observes |
46 | | -- **Root cause**: The specific code, config, or condition responsible |
47 | | -- **Mechanism**: How the root cause produces the symptom — trace the chain |
48 | | -- **Evidence**: The files, lines, logs, or state that support the diagnosis |
49 | | -- **Scope**: What else might be affected by the same underlying issue |
| 70 | +- **Symptom**: what the user observes |
| 71 | +- **Root cause**: the specific code, config, or condition responsible |
| 72 | +- **Mechanism**: how the root cause produces the symptom |
| 73 | +- **Evidence**: files, lines, logs, or the failing test |
| 74 | +- **Scope**: what else might be affected |
| 75 | + |
| 76 | +If the diagnosis is uncertain, say so and identify what would confirm it. |
| 77 | + |
| 78 | +## Red Flags |
| 79 | + |
| 80 | +If you catch yourself thinking any of these, STOP and go back to step 1: |
50 | 81 |
|
51 | | -Don't propose fixes. If the diagnosis is uncertain, say so and identify what additional information would confirm it. |
| 82 | +- "Quick fix for now, investigate later" |
| 83 | +- "Just try changing X and see if it works" |
| 84 | +- "It's probably X, let me fix that" |
| 85 | +- "I don't fully understand but this might work" |
| 86 | +- "I see the problem" (seeing symptoms ≠ understanding root cause) |
0 commit comments