These debugging prompts help you find and fix bugs faster: explaining error messages, tracing root causes, reproducing issues, fixing performance problems, memory leaks, race conditions and failing tests.
20 prompts on this page. Last updated: 4 December 2026. Written and tested by Saad Raza.
How to use these prompts
- Click Copy on any prompt.
- Paste it into ChatGPT, Claude, Gemini, Copilot or Perplexity.
- Replace everything in [square brackets] with your own details. The more specific you are, the better the answer.
- Read and edit the result before you use it. Add your own experience and check every fact, name and number.
Give the AI your language, version, framework and coding conventions, and paste the relevant code rather than describing it. Review, run and test every generated change before merging it, and never paste secrets, keys or private customer data into an AI tool.
Errors
1. Explain an error message
Explain this error in plain English, its most likely causes and how to fix each: [paste error and stack trace]. Language and framework: [details].
2. Fix a bug with context
This code should [expected behaviour] but instead [actual behaviour]. Code: [paste]. Inputs: [example]. Find the bug, explain the root cause and give the minimal fix.
3. Debug step by step
Walk through this code step by step with input [input], tracking variable values, and show where it goes wrong: [paste].
4. Find the root cause, not the symptom
Here is a bug and the quick fix we applied: [paste]. Is this fixing the root cause? What else could trigger the same problem?
5. Reproduce an intermittent bug
This bug happens only sometimes: [describe]. List possible causes such as race conditions, caching, time zones or data differences, and how to reproduce each reliably.
Specific problem types
6. Fix a failing test
This test fails: [paste test and failure output]. Code under test: [paste]. Is the bug in the test or the code? Give the fix.
7. Fix a null or undefined error
I get [null pointer or undefined] errors here: [paste]. Find where the value can be missing and add safe handling.
8. Debug a race condition
This concurrent code sometimes produces wrong results: [paste]. Identify shared state and race conditions, and fix them.
9. Find a memory leak
My [application] memory usage keeps growing. Here is the relevant code and profiler output: [paste]. Find likely leaks and fixes.
10. Fix a slow query or endpoint
This endpoint takes [time]: [paste code, query and timings]. Find the bottleneck and suggest fixes, from queries to caching.
11. Debug a CORS or network error
My frontend at [origin] gets this error calling [API]: [paste]. Explain the cause and the correct server configuration.
12. Debug a dependency or build error
My build fails with: [paste]. Package versions: [paste]. Explain the conflict and how to resolve it.
13. Debug environment differences
This works locally but fails in [staging or production]: [describe error]. List configuration, environment, version and data differences to check.
Tools and process
14. Add useful logging
Add logging to this code that would help debug [problem] in production, without logging sensitive data: [paste].
15. Write a minimal reproduction
Help me reduce this code to the smallest example that still shows the bug, for a bug report or forum question: [paste].
16. Use a debugger
Explain how to debug [problem] using [debugger or browser dev tools] step by step, including breakpoints and watches.
17. Analyse logs
Here are log lines around the time of the failure: [paste]. Build a timeline of what happened and identify the likely failure point.
18. Write a bug postmortem
Write a blameless postmortem for this incident: [paste timeline and details]. Include impact, root cause, contributing factors and action items.
19. Prevent the bug from returning
Now that this bug is fixed: [describe], write a regression test and suggest checks or lint rules to catch similar bugs.
20. Rubber duck debugging
Act as a rubber duck. I will explain my code and the problem; ask me short questions that help me spot the issue myself, without giving the answer straight away.
What are debugging prompts?
Debugging prompts help you find and fix bugs faster with AI: explaining error messages and stack traces, tracing root causes, reproducing intermittent bugs, fixing failing tests, race conditions, memory leaks, slow queries, CORS and build errors, and writing postmortems so the bug does not return.
How to write better debugging prompts
- Share the full error: stack traces point to the real problem.
- Describe expected versus actual: with a concrete input.
- Include versions: many bugs depend on library or runtime versions.
- Add a regression test: once fixed, keep it fixed.
Best AI tools to use with these prompts
Use ChatGPT, Claude or an editor assistant such as GitHub Copilot or Cursor to explain errors, your IDE debugger and browser DevTools to step through code, and Sentry or similar tools to capture production errors with context.
Frequently asked questions
Can ChatGPT fix my code?
AI is good at explaining errors and spotting common bugs. Give it the full error, the relevant code and what you expected, and always test the fix.
What should I include when asking AI to debug?
The exact error and stack trace, the relevant code, inputs, expected versus actual behaviour, and your language, framework and versions.
Why does the AI fix not work?
Usually it is missing context, such as other files, versions or data. Share more context or ask it to list assumptions.
Can AI find bugs in my code?
AI is good at spotting common bugs and explaining errors. Give it the relevant code, error and expected behaviour, and always test the fix.
Why does AI sometimes give the wrong fix?
It may lack context, such as other files, versions or data. Share more context and ask it to list its assumptions.
More software development prompts
- Code Generation PromptsWrite functions, classes, scripts and boilerplate.
- Code Review and Refactoring PromptsReview, clean up and improve existing code.
- Software Testing PromptsUnit, integration and end-to-end tests.
- Technical Documentation PromptsREADMEs, API docs, comments and guides.
- SQL and Database PromptsQueries, schema design, indexes and optimisation.
- API Development PromptsDesign, build, secure and document APIs.
- DevOps PromptsCI/CD, Docker, cloud, monitoring and deployment.
- System Design and Architecture PromptsArchitecture, scaling, trade-offs and design reviews.
Back to all software development prompts or the full prompt library, including SEO prompts.
Shipping software? Make sure customers can find it. Request a free audit and I will show you what to fix first.
Request received
Thank you! Saad will contact you within the next 24 hours.
Keep an eye on your phone and inbox.
