AI Prompts for Debugging
20 framework-tagged, copy-paste templates for Developers — Debugging.
Works with ChatGPT, Claude, and Gemini.
21 Prompts — Debugging
Click any prompt to copyRoot Cause Analysis
COTWalk me through debugging this error step-by-step:
Language/framework: [language + version]. Error message: [exact error]. When it occurs: [trigger condition].
[code block]
Step 1: Identify the root cause. Step 2: Explain why this happens. Step 3: Provide the corrected code. Step 4: How to prevent this class of bug in future.
Error Message Explainer
Zero-ShotExplain this error message in plain English:
[error message]
Language: [language]. Context: [what the code is trying to do].
1. What the error means. 2. The most common causes (ranked by likelihood). 3. Quickest diagnostic step to confirm the cause. 4. The fix. 5. Any gotchas or edge cases to watch for after fixing.
Stack Trace Decoder
Zero-ShotDecode the following stack trace and identify the source of the bug:
[paste stack trace]
Language: [language]. Framework: [framework].
Tell me: which file and line to look at first, what chain of calls led to the error, and whether this is a symptom or root cause. Then give me 3 specific things to check in the codebase.
Intermittent Bug Investigation
COTHelp me debug an intermittent bug that occurs roughly [frequency].
What happens: [description]. Conditions observed: [conditions]. Suspected area: [file/component].
Intermittent bugs are usually caused by: race conditions, state mutations, cache issues, network timing, or resource exhaustion. Walk me through which of these to rule out first and how to add instrumentation to catch it.
Memory Leak Diagnosis
Zero-ShotHelp me find a memory leak in a [language/runtime] application.
Symptoms: [describe: memory grows over time / OOM crash / slow degradation]. Suspected component: [component].
Provide: 3 most common causes of memory leaks in [language/runtime], how to profile and confirm it, what to look for in the [code section], and the fix pattern for each root cause.
Null Pointer / Undefined Error
Zero-ShotFix this null/undefined reference error:
[code block]
Error: [error message]. Language: [language].
Explain: where the null value is coming from, whether this is a defensive programming issue or a logic bug, the correct fix, and whether adding a null check is the right approach or if it's masking a deeper issue.
Race Condition Fix
Zero-ShotIdentify and fix the race condition in this code:
[code block]
Language/environment: [language + async model].
Explain: what the race condition is, under what timing conditions it manifests, the synchronisation mechanism to use (mutex/lock/atomic/Promise chaining/etc.), and the fixed code. Add a comment explaining the fix for future developers.
Type Error Debugging
Zero-ShotDebug this type error:
[code block]
Language: [TypeScript/Python/etc.]. Error: [type error message].
Explain: what types are expected vs received, where the type mismatch originates, whether to fix the type definition or the runtime value, and the corrected code with the type fix. If this requires a broader type system change, flag what else needs updating.
API Response Debugging
Zero-ShotHelp me debug why this API call is failing:
Endpoint: [endpoint]. Method: [HTTP method]. Expected response: [expected]. Actual response: [status code + body].
Code making the call: [code block]
Check: request headers, authentication, request body format, URL construction, CORS (if applicable), and rate limiting. Provide a debugging checklist and the most likely fix.
Database Query Debugging
Zero-ShotDebug this database query that's returning unexpected results:
Query: [SQL or ORM query]. Database: [DB type + version]. Expected: [expected result]. Actual: [actual result].
Diagnose: WHERE clause issues, JOIN type problems, NULL handling, index usage, data type mismatch, or transaction isolation. Provide the corrected query and explain what was wrong.
CSS Layout Bug
Zero-ShotFix this CSS layout bug:
Issue: [describe what looks wrong]. Browser: [browser + version]. Target: [desktop/mobile/both].
HTML: [structure]. CSS: [relevant styles].
Diagnose: box model issue, flexbox/grid problem, specificity conflict, or inherited property. Provide the fixed CSS and a brief explanation of why the original was broken.
Performance Regression
Zero-ShotHelp me track down a performance regression. The operation [operation] used to take [old time]ms and now takes [new time]ms after the change in [commit/deployment].
Code before: [before]. Code after: [after].
Identify the performance difference, explain the Big-O impact, and provide the optimised version that restores the original performance.
Flaky Test Fix
Zero-ShotThis test passes locally but fails in CI roughly [% of runs]:
[test code]
Test framework: [framework]. Language: [language]. CI environment: [CI tool].
Common causes of flaky tests: timing/async issues, global state leakage, environment differences, random data, or network dependencies. Diagnose which applies here and provide a fix that makes the test deterministic.
Infinite Loop Detection
Zero-ShotMy program is hanging with what appears to be an infinite loop or deadlock:
[relevant code]
Language: [language]. Last known state before hang: [state].
Walk me through: how to confirm it's a loop vs deadlock, how to add instrumentation to find the loop entry point, the exit condition that's failing, and the fix. Also show how to add a circuit-breaker or timeout to prevent this class of bug.
Dependency Conflict
Zero-ShotHelp me resolve this dependency conflict:
Error: [dependency error message]. Package manager: [npm/pip/gem/cargo]. Language: [language].
Conflicting packages: [package A requires X, package B requires Y].
Options: upgrade, downgrade, peer dependency fix, or override. Walk me through the safest resolution path and what breaking changes to test for.
Environment-Specific Bug
Zero-ShotA bug occurs in [production/staging] but not in [local/dev]:
Behaviour: [description]. Key differences between environments: [OS/Node version/env vars/data volume/etc.].
Systematic approach to isolate the cause: what environment variables to check, configuration differences to audit, data differences to consider, and how to reproduce it locally. Most likely root causes ranked by probability.
Third-Party SDK Integration Bug
Zero-ShotHelp me debug why the [SDK/library name] integration isn't working.
Expected behaviour: [expected]. Actual behaviour: [actual]. SDK version: [version].
My integration code: [code block]
Check: initialisation order, API key/config setup, callback vs promise handling, version compatibility, and SDK-specific gotchas. Provide the corrected integration pattern.
Regex Debug
Zero-ShotDebug this regex that isn't matching as expected:
Regex: [pattern]. Language/engine: [engine]. Input: [test string]. Expected match: [expected]. Actual match: [actual].
Explain: which part of the pattern is failing and why, what character class or quantifier is causing the issue, and provide the corrected regex with an explanation of each part. Add 3 test cases (match and non-match).
Build / Compile Error
Zero-ShotFix this build error:
Build tool: [webpack/vite/gradle/cargo/etc.]. Language: [language].
Error output: [build error].
Diagnose: misconfiguration, missing file/module, incompatible plugin version, or environment issue. Provide the specific config fix, what the error message actually means (in plain English), and how to verify the fix before a full rebuild.
Log Analysis
Zero-ShotAnalyse these application logs to identify the root cause of the issue:
[paste log excerpt]
System: [service/framework]. Time window: [start → end]. Reported symptom: [user-facing impact].
Find: the first error signal, the chain of events leading to the failure, which service or component originated the problem, and what data or state triggered it. Recommend immediate fix and long-term monitoring.
Debugging Strategy for Unknown Error
COTI have a bug I can't reproduce and don't understand. Help me build a systematic debugging strategy.
What the user reports: [user report]. Available information: [logs/error reports/stack traces available]. System: [language + framework + infrastructure].
Design a debugging plan: what to log, what to monitor, how to narrow the scope, how to create a minimal reproduction case, and what the top 5 hypotheses are in order of likelihood.
How to use these prompts
- Replace [placeholders in brackets] with your specific details before sending.
- Add context about your audience, tone, or format to get more tailored results.
- Chain prompts — use one output as input to the next for complex tasks.
- Works with ChatGPT, Claude, Gemini, and other LLMs.
Developers Topics
Build Custom Prompts
Use our AI prompt builder to create prompts tailored to your exact situation.
Try Prompt BuilderLearn the Frameworks
The badges on each prompt reference proven prompt engineering frameworks.
Browse 60+ Frameworks →