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 index here?"
  • 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

  1. Reproduce: the exact command, in your terminal.
  2. Open the file and line the traceback names. If you see the bug, say the line number.
  3. Pin it with a failing test if one does not exist.
  4. 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.

FAQ: Debug with AI

Common questions about this page.

What is vibe coding?

Vibe coding is building software by directing an AI in natural language while you review, test, and own the result. The StudyGrid Vibe Coding course teaches the workflow, prompts, and habits that make it work.

Should I run debug with ai examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn debug with ai in this Vibe Coding AI lesson (Debug with AI).

How do I vibe code the right way?

Give one clear goal, attach the files that matter, ask for a plan first, review every diff, run tests, then commit a small slice. The How You Work lesson is the session guide. Best Practices is the full playbook.

How does a user actually work with vibe coding?

You open a real project in an agent editor or CLI agent (Cursor, VS Code + Copilot, Claude Code, and similar), write one goal, attach two or three files, ask the agent to plan then implement a small slice, read the diff, run tests yourself, and commit. You are the director. The model drafts. The How You Work lesson walks through a 30-minute session. The Tools lesson is the stack picker.

Is vibe coding only for experts?

No. Beginners can use it to learn faster if they read the generated code. Experts use it to move quicker on boilerplate while keeping architecture and review in their hands.

What tools do I need for vibe coding?

You need an agent that can read your project, edit files, and show a diff — for example Cursor, VS Code with GitHub Copilot, Claude Code, Codex CLI, Continue, or Windsurf — plus Git for undo and a language you can read (this course uses Python). A browser chatbot is not enough. The Tools lesson compares the stacks. Setup covers the checklist.

Which AI coding tool should I use for vibe coding?

Pick one stack and stay with it for a project. Cursor is a common agent editor. VS Code plus GitHub Copilot fits if you already work there. Claude Code and Codex CLI are terminal agents. Continue, Windsurf, Zed, and JetBrains AI Assistant also work if they can apply a diff. Do not hop tools on a dirty tree.

Is the Vibe Coding course free?

Yes. The full Vibe Coding course on StudyGrid (studygrid.in) is free. Open the header menu, start at What Is Vibe Coding, then How You Work and Tools, and follow Next through the project and cheatsheet.