Debugging Through Investigation
Help the user debug an issue through systematic investigation and hypothesis-driven problem solving. This is a conversation, not a fix-it script.
Start by understanding the issue, then reproduce it, form theories, investigate with evidence, and only fix once you understand the root cause.
The Process
Understanding the issue:
- Explore the codebase first — read relevant files to build context before asking questions
- Ask questions one at a time to understand the problem
- Prefer multiple choice questions when possible, but open-ended is fine too
- Only one question per message
- Focus on understanding: expected behavior, actual behavior, reproduction steps, when it started, what changed recently
Reproducing the issue:
- Attempt to reproduce the issue before investigating code
- If this is a frontend/browser issue and you see
playwright_* tools available, use them:
playwright_navigate to load the page
playwright_screenshot to capture visual evidence
playwright_click / playwright_fill to interact with elements
playwright_evaluate to check console errors and state
- If this is a backend/CLI issue, run the reproduction steps with Bash
- If this is a test failure, run the specific failing test
- If you cannot reproduce, investigate why — environment, timing, specific data, concurrency
- Document the reproduction case clearly — you need it later to verify the fix
Forming hypotheses:
- Based on symptoms and code context, propose 2-3 theories about the root cause
- For each theory: description, likelihood (high/medium/low), how to test it
- Present theories to the user — they may have context that rules some out
- Wait for user input before proceeding
Investigating:
- Work through hypotheses starting with the most likely
- Read relevant code paths — use Glob and Grep to find files, Read to inspect
- Check logs, trace execution, inspect state
- Use Playwright for frontend state inspection if available
- Present findings as you go — if Theory A doesn't pan out, explain why and move to Theory B
- Once you identify the root cause with evidence, present it clearly and wait for confirmation:
Root cause identified:
- File: [path:line]
- Problem: [what's wrong]
- Why: [explanation]
- Evidence: [what you observed]
Fixing:
- Propose the fix before implementing — the user may want a different approach
- Apply the minimal change that addresses the root cause
- Do not refactor unrelated code
- Add a test case for the bug if it wasn't covered by tests
- Add defensive checks or better error messages if appropriate
Verifying:
- Re-run the reproduction case — confirm the issue is fixed
- Run relevant tests — ensure nothing else broke
- Check related functionality for similar issues
- If Playwright is available, take a screenshot showing the fix works
Report
After fixing, provide a clear summary:
Debug session complete.
Issue: [brief description]
Root Cause: [what was wrong]
Fix: [what changed]
Files modified:
- [path] — [summary of changes]
Verification:
- [x] Issue no longer reproduces
- [x] Tests pass
- [x] Related functionality checked
Key Principles
- One question at a time — do not overwhelm
- Reproduce first — never skip this step
- Hypothesis-driven — do not make random changes
- Evidence-based — confirm theories with data, not guesses
- Minimal fixes — address the root cause, not symptoms
- Verify thoroughly — test the fix and related functionality
- Interactive — involve the user at key decision points
- Use Playwright when available — for frontend debugging, check your tool list for
playwright_* tools
When to Stop and Escalate
Stop and ask the user for help if:
- You cannot reproduce the issue after multiple attempts
- The root cause requires domain knowledge you do not have
- The fix would require architectural changes beyond a targeted patch
- Multiple theories seem equally plausible and you need more context
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: debug-83description: Use when encountering a bug, test failure, unexpected behavior, or when the user asks for help debugging. Hypothesis-driven — reproduce, investigate, fix, verify. Standalone — works outside the plan/spec/build workflow.4---56# Debugging Through Investigation78Help the user debug an issue through systematic investigation and hypothesis-driven problem solving. This is a conversation, not a fix-it script.910Start by understanding the issue, then reproduce it, form theories, investigate with evidence, and only fix once you understand the root cause.1112## The Process1314**Understanding the issue:**15- Explore the codebase first — read relevant files to build context before asking questions16- Ask questions one at a time to understand the problem17- Prefer multiple choice questions when possible, but open-ended is fine too18- Only one question per message19- Focus on understanding: expected behavior, actual behavior, reproduction steps, when it started, what changed recently2021**Reproducing the issue:**22- Attempt to reproduce the issue before investigating code23- If this is a frontend/browser issue and you see `playwright_*` tools available, use them:24 - `playwright_navigate` to load the page25 - `playwright_screenshot` to capture visual evidence26 - `playwright_click` / `playwright_fill` to interact with elements27 - `playwright_evaluate` to check console errors and state28- If this is a backend/CLI issue, run the reproduction steps with Bash29- If this is a test failure, run the specific failing test30- If you cannot reproduce, investigate why — environment, timing, specific data, concurrency31- Document the reproduction case clearly — you need it later to verify the fix3233**Forming hypotheses:**34- Based on symptoms and code context, propose 2-3 theories about the root cause35- For each theory: description, likelihood (high/medium/low), how to test it36- Present theories to the user — they may have context that rules some out37- Wait for user input before proceeding3839**Investigating:**40- Work through hypotheses starting with the most likely41- Read relevant code paths — use Glob and Grep to find files, Read to inspect42- Check logs, trace execution, inspect state43- Use Playwright for frontend state inspection if available44- Present findings as you go — if Theory A doesn't pan out, explain why and move to Theory B45- Once you identify the root cause with evidence, present it clearly and wait for confirmation:4647```48Root cause identified:49- File: [path:line]50- Problem: [what's wrong]51- Why: [explanation]52- Evidence: [what you observed]53```5455**Fixing:**56- Propose the fix before implementing — the user may want a different approach57- Apply the minimal change that addresses the root cause58- Do not refactor unrelated code59- Add a test case for the bug if it wasn't covered by tests60- Add defensive checks or better error messages if appropriate6162**Verifying:**63- Re-run the reproduction case — confirm the issue is fixed64- Run relevant tests — ensure nothing else broke65- Check related functionality for similar issues66- If Playwright is available, take a screenshot showing the fix works6768## Report6970After fixing, provide a clear summary:7172```73Debug session complete.7475Issue: [brief description]76Root Cause: [what was wrong]77Fix: [what changed]7879Files modified:80- [path] — [summary of changes]8182Verification:83- [x] Issue no longer reproduces84- [x] Tests pass85- [x] Related functionality checked86```8788## Key Principles8990- **One question at a time** — do not overwhelm91- **Reproduce first** — never skip this step92- **Hypothesis-driven** — do not make random changes93- **Evidence-based** — confirm theories with data, not guesses94- **Minimal fixes** — address the root cause, not symptoms95- **Verify thoroughly** — test the fix and related functionality96- **Interactive** — involve the user at key decision points97- **Use Playwright when available** — for frontend debugging, check your tool list for `playwright_*` tools9899## When to Stop and Escalate100101Stop and ask the user for help if:102- You cannot reproduce the issue after multiple attempts103- The root cause requires domain knowledge you do not have104- The fix would require architectural changes beyond a targeted patch105- Multiple theories seem equally plausible and you need more context106107---108> Converted and distributed by [TomeVault](https://tomevault.io/claim/ratler) — claim your Tome and manage your conversions.109<!-- tomevault:4.0:skill_md:2026-04-11 -->