Vibe Coding
Debug with AI
Paste the error, isolate the failing case, and fix one cause. Do not restart the whole feature.
Debug, do not regenerate
When something fails, the worst move is "rewrite it from scratch." You lose the parts that already worked. Debug like a programmer: reproduce, isolate, fix, confirm.
The debug prompt
@notes.py @test_notes.py
Command: pytest -q test_notes.py::test_delete_last
Expected: pass
Got: IndexError: list index out of range
Do not rewrite the module.
Explain the cause in 3 bullets, then apply the smallest fix.Give a failing example
If there is no test yet, add one. That pins the bug.
def test_delete_last():
notes = ["a", "b"]
delete_at(notes, 1)
assert notes == ["a"]After two failed tries
- Ask for hypotheses, not more code.
- Print the value that is wrong. "What is
indexhere?" - Revert to the last green commit if the file is now messy.
Thrashing (five rewrites of the same function) means the prompt is underspecified or the slice is too large. Stop and plan.
How you debug in a session
- Reproduce: the exact command, in your terminal.
- Open the file and line the traceback names. If you see the bug, say the line number.
- Pin it with a failing test if one does not exist.
- Prompt for the smallest fix. Two failed tries, then stop and plan — do not rewrite the module.
Read traces yourself
Python tracebacks name the file and line. Open that line before you ask the agent. If you see the bug, say so: "Line 42 uses the length after pop. Fix that." Specific beats mystical.
Try it yourself
pytest fails with IndexError in delete_at. You have already asked “rewrite delete” twice. What is the next prompt?
Show solution
@notes.py @test_notes.py
Do not rewrite the module.
Command: pytest -q test_notes.py::test_delete_last
Got: IndexError: list index out of range
Explain the cause in 3 bullets. Then apply the smallest fix.Key takeaways
- Reproduce with a command or a test.
- Smallest fix, not a rewrite.
- Stop after two failed attempts and tighten the problem.
- You paste the traceback. You do not describe the vibe of the failure.