◆ AI · debug

Debug your code with AI

Paste the error, the code, and what you expected — get the actual cause, not a guess, and the fix.

4heights
8tasks
8roles do it

AI prompts

do it · improve it · decide · become
AExecute — “help me do it”Here's my code and the error. 1) Read the code and the full error message below. 2) Tell me the…+
Here's my code and the error. 1) Read the code and the full error message below. 2) Tell me the exact line and reason it fails, not a general guess. 3) Give me the corrected code with the change marked. 4) Explain in one sentence why the original broke. 5) List any other lines with the same bug waiting to happen. 6) Tell me one quick test to confirm the fix works. Code: [PASTE]. Error: [PASTE]. What I expected: [DESCRIBE].
when the reply comes backPush once: ask it to sharpen the weakest part, and to say what it assumed.
BImprove — “do it better”I already have a fix for this bug but it feels hacky. Here's the buggy code, my patch, and the…+
I already have a fix for this bug but it feels hacky. Here's the buggy code, my patch, and the error it solved: [PASTE]. Tell me: does my fix treat the symptom or the cause? Will it break under edge cases like empty input, nulls, or concurrent calls? Rewrite it the way a senior dev would, and name the specific weakness you removed.
when the reply comes backPush once: ask it to sharpen the weakest part, and to say what it assumed.
CDecide — “help me choose”My code is slow and I have two ways to fix it: [OPTION A] or [OPTION B]. Here's the code:…+
My code is slow and I have two ways to fix it: [OPTION A] or [OPTION B]. Here's the code: [PASTE]. Compare them on speed, readability, and how likely each is to introduce a new bug. Show your reasoning for each, then tell me which you'd ship and why — pick one, don't give me a both-are-fine answer.
when the reply comes backPush once: ask it to sharpen the weakest part, and to say what it assumed.
DBecome — “help me grow”Use this bug as a lesson. Here's the code, the error, and the fix: [PASTE]. Walk me through how…+
Use this bug as a lesson. Here's the code, the error, and the fix: [PASTE]. Walk me through how you'd have found this myself from scratch — what you read first in the stack trace, what you'd print or log, how you'd narrow it down. Then give me a 5-step debugging checklist I can reuse next time, in plain words.
when the reply comes backPush once: ask it to sharpen the weakest part, and to say what it assumed.

The real tasks

8 of them
I have a stack trace and no idea what broke
My code runs but gives the wrong output
I have to fix a bug someone else wrote
My tests pass locally but fail in CI
I have to find why this function is so slow
I keep getting a null error I can't trace
My app crashes only sometimes and I can't reproduce it
I have to figure out this cryptic library error message

Who does this

8 roles
Software EngineerFrontend DeveloperBackend DeveloperData ScientistDevOps EngineerQA EngineerStudent ProgrammerIndie App Developer

Questions people actually ask

with the jobs and tasks they touch

Give it three things: the code, the exact error text, and what you expected to happen. Without all three it's guessing, and its guess will be confident and wrong.

The more it knows about your intent, the sharper the answer. 'It's broken' gets you a lecture. 'It returns 0 when I expected 5' gets you the fix.

  1. Paste the full code block, not a snippet
  2. Paste the complete error and stack trace
  3. Say what you expected vs what happened
  4. Ask for the exact line and reason, not general advice
  5. Ask it to confirm the fix with one test

Silent wrong answers are the worst kind — no crash to point at. The trick is showing the AI a concrete input and the wrong output next to the right one.

Give it one small example where you know the correct answer by hand. That turns a vague hunt into a math check the AI can actually reason through.

  1. Pick one input where you know the correct output
  2. Paste the code, the input, and both outputs
  3. Ask it to trace the code line by line with that input
  4. Have it point to where the value goes wrong
  5. Ask for the fix and re-trace to confirm

Big stack traces are fine — the AI reads the whole thing. What confuses it is missing the top line, which is usually where your code is, buried under library noise.

Include everything but tell it what's yours. It'll ignore the framework internals and zero in on your file.

  1. Copy the entire trace, top to bottom
  2. Tell it which file names are your own code
  3. Paste the code from those files too
  4. Ask which frame is the real cause
  5. Ask what to log to confirm before you touch code

Inherited code is a maze. Use the AI as a fast reader — have it explain the flow before you touch anything, so you're not fixing blind.

Ask what the code is trying to do first. Once you understand intent, the bug usually shows itself.

  1. Paste the file and ask for a plain-English summary of what it does
  2. Point to the bug's symptom and error
  3. Ask which function is responsible
  4. Ask what assumptions the code makes that might be wrong
  5. Get the fix and ask what else it might affect

This is almost always environment, not logic — different versions, missing env vars, timing, or file paths. Feed the AI both logs and it'll spot the mismatch fast.

Give it the CI config too. The difference is usually hiding in there.

  1. Paste the test code and the CI failure log
  2. Paste your local pass log and CI config
  3. Ask what differs between the two environments
  4. List suspects: versions, env vars, ordering, timezone
  5. Ask for one change to test the top suspect

The AI doesn't run your code — it predicts what a fix looks like. When it lacks context it fills gaps with plausible-sounding code that compiles but breaks something else.

Give it more real context and it stops inventing. The invented fixes come from thin information, not from the model being dumb.

  • It never actually executes your code — it reasons about it
  • Missing context forces it to assume, and assumptions get wrong
  • It may 'fix' by changing behavior you actually wanted
  • It can hallucinate library functions that don't exist
  • Always run the fix before trusting it
  • Ask it to explain why the fix works — bad ones can't

Debugging finds why your code broke so you learn and the fix is minimal. Rewriting throws it out and hopes the new version works — you lose the lesson and often the surrounding logic.

Rewrite when the code is a mess anyway. Debug when it mostly works and one thing is off. Reaching for a full rewrite every time is how you stay a beginner forever.

see alsoStudent Programmer →

Understand it. Paste-and-pray works until the same bug shows up in a new shape and you're stuck again, still helpless. The whole point of debugging is that next time you're faster.

Spend two minutes asking 'why did this break' after every fix. That's the difference between someone who can code and someone who can only copy.

see alsoStudent Programmer →

Intermittent bugs are timing, memory, or race conditions nine times out of ten. Describe exactly when it does and doesn't happen — the pattern is the clue, even when it feels random.

Give the AI the code plus every crash log you've got. It'll spot conditions you didn't notice were shared across the crashes.

see alsoIndie App Developer →Backend Developer →

Null errors are a value that was never set, or got cleared somewhere upstream. Give the AI the trace and the functions in the chain, and ask it to find where the value should have been assigned.

It'll walk backward through the calls faster than you can. Then verify by logging that one spot before you fix it.

Slow code is usually one loop, one query, or one thing done repeatedly that should be done once. Paste the function and ask the AI to rank operations by likely cost.

Don't guess and optimize blind — that's how you make it uglier and no faster. Get the AI's suspect list, then measure the top one before changing anything.

They fit different moments. Copilot lives in your editor for quick fixes as you type. Claude Opus handles deep reasoning on nasty bugs. Claude Code can actually read your whole repo and run things.

Most people end up using two: an in-editor helper plus a chat model for the hard stuff.

ToolBest forCatch
GitHub CopilotInline fixes while codingWeak on deep multi-file bugs
Claude Opus 4.6Hard reasoning, tricky logicYou paste context by hand
Claude CodeWhole-repo bugs, runs codeSetup and needs your files

Editor tools are fast for small stuff — you don't break flow. Chat models win when you need to explain the whole situation and get real reasoning back.

Rule of thumb: one-liner bug, use the editor. Bug you can't even describe, open a chat and dump everything.

SituationEditor (Copilot)Chat (Claude/Grok)
Typo or small syntax fixFast, no context switchOverkill
Confusing logic bugLimited viewFull reasoning, better
Need to explain intentHard to doPaste it all, easy

Because you still have to know when the AI is wrong — and it will be, especially on your specific edge cases and your weird setup. You can't judge a fix you don't understand.

Trust the AI to speed you up, not to think for you. The people who thrive use it to learn faster, not to skip the learning. The ones who paste blind stall out the moment the bug is unusual.

see alsoStudent Programmer →

Trust the reasoning, verify the behavior. The AI can explain the bug perfectly and still hand you a fix that breaks an edge case it never saw. It doesn't run your code — you do.

Before you ship: read the fix, understand why it works, and run your tests. Two minutes of checking beats a 2am rollback. Never ship a fix you can't explain out loud.