In this categoryTroubleshooting ยท 27
- How to Fix an OpenAI 401 'Invalid API Key' ErrorStart
- How to Fix OpenAI 429 Rate Limit Errors With Backoff
- How to Fix Anthropic Claude API 401 Authentication Errors
- How to Fix Google Gemini 'API Key Not Valid' Errors
- How to Fix an API Key That Loads as Undefined
- How to Handle Anthropic 529 'Overloaded' Errors
- How to Fix Rate Limit Errors from an AI API
- How to Fix CORS Errors When Calling an AI API From the Browser
- How to Fix 'Model Not Found' and Deprecated Model Errors
- How to Rotate a Leaked API Key Without Downtime
- How to Fix SSL Certificate Errors When Calling AI APIs
- How to count tokens before sending a prompt to Claude
- How to Fix 'Context Length Exceeded' Token Limit Errors
- How to fix a context length exceeded error in the Claude API
- How to fix a Claude response that gets cut off mid-sentence
- How to reduce Claude hallucinations by grounding answers in your documents
- How to keep a long Claude conversation under the context limit
- How to stop Claude from calling tools when it should not
- How to handle a Claude Fable 5 refusal with a fallback model
- How to choose the right Claude model for cost and quality
- How to cut Claude API costs with prompt caching
- How to halve Claude costs for bulk jobs with the Batch API
- How to cap spend on a Claude agent with a task budget
- How to Debug an MCP Server That Will Not Connect
- How to Ask an Agent to Explain a Bug Before Fixing It
- How to Roll Back a Bad Deploy Quickly
- How to Fix Cursor Not Indexing Your Codebase
How to Ask an Agent to Explain a Bug Before Fixing It
Make the agent state the root cause first so you can confirm the diagnosis before it writes a fix that masks the real problem.
Agents are quick to patch symptoms. Ask one to fix a failing test and it may silence the test rather than fix the bug behind it. Requiring an explanation of the root cause before any edit lets you catch a wrong diagnosis early and avoid a fix that just hides the problem.
What you need
- A reproducible bug or failing test
- An agent session in the project
- About 6 minutes
Step 1: Ask for the cause, not a fix
Tell the agent to diagnose first and hold off editing. You want the root cause in plain words before any code changes.
Step 2: Confirm the diagnosis
Check the explanation against the symptom. A right cause explains every part of the bug; a wrong one leaves something unexplained.
Step 3: Approve the targeted fix
Once the cause is confirmed, ask for the smallest fix that addresses it and a test that would have caught the bug.
Diagnosis confirmed. Fix calcTotal() to apply the discount before tax, and add a test that fails on the old order. Keep the change minimal.Result: fixes target the actual cause instead of muting symptoms, and a new test locks the behavior in so the bug stays fixed.
Watch related tutorials
12:36
18:52
22:40
7:18
30:24
18:22New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.