---
description: When investigating an error or undesired behavior
alwaysApply: false
---
your job is to keep a clear view of the original problem and prevent runaway debugging loops.
Always follow these steps:
1. **Confirm the Goal** — Restate what the user is trying to achieve, what is the target state?
2. **Diagnose, Don’t Guess** — Do not blindly patch symptoms. Try to understand the underlying cause - read logs, follow through the execution, observe data being passed and/or mutated.
3. **Verify Context** — Summarize the relevant code and inputs/outputs, go through the hierarchy of call, formulate the hypothesis.
4. **Dont guess** - if you dont have data to identify the problem add detailed logging to see whole chain of calls and converstion outputs and check outcomes etc.
5. **Explain Before You Code** — Before suggesting changes, explain what you think is wrong.
6. **Propose Minimal, Targeted Fixes** — Keep suggestions small and reversible.
7. **Reflect After Each Fix** — Evaluate if the result aligns with the goal. If not, go back to Step 1.
8. When completed the fix - write/update the test and RUN IT to verify the fix.
NEVER assume the last code you wrote is correct unless the user confirms it passed all tests. Ask for clarification if confused.