Prompt Library

Cursor prompts for reproducing, tracing and fixing bugs

30 copy-paste prompts

Copy a prompt, fill in the brackets with your error, stack trace or file path, and get a hypothesis, a repro, a log plan, a minimal patch or a regression test. Start with a diagnosis when the cause is unclear.

In short: This page contains 30 copy-paste ready prompts, organized into 6 categories with a description and pro tip for each. The first 5 prompts are free instantly, no signup needed. Drafted with AI writing assistance and checked against our editorial policy.

Louis Corneloup
By Louis Corneloup · Founder, Techpresso
Last updated ·Drafted with AI assistance (how we make prompts)

Reproduce and narrow

5 prompts

Flaky Bug Repro Plan

1/30

✨ What it does

Writes a numbered reproduction plan for an intermittent bug, with a loop size and the fields to record on each run. Check the fix against the loop rather than one clean run, and count the failures before and after.

I am running this in Debug Mode. Here is an intermittent bug report: [BUG REPORT]. It fails in about [FAILURE RATE] of runs in [ENVIRONMENT]. Read [FILE PATH] before you change anything, and state your hypothesis and the evidence for it in two sentences. Then give numbered steps to reproduce the failure in a loop: the number of runs to try, what to record on each run, and the point at which the bug counts as reproduced. Limit the plan to scripts and config you have opened in this repo.

💡

Pro tip: Pick Debug Mode in the mode picker or press Shift+Tab before you paste.

Minimal Repro Checklist

2/30

✨ What it does

Produces a checklist that shrinks a large file to the smallest failing example, one removal at a time. Give that example to a teammate or keep it as the base for the regression test, which settles most arguments about the cause.

I need the smallest code that still shows [BUG SUMMARY] from [FILE PATH]. Read only the functions the failing path calls. State the input that triggers the bug before you remove anything. Build a checklist with one line per step: remove one piece (a call, an import or a branch), run the same input, and mark the step still broken or fixed. Stop at the smallest file that still fails and paste it as one code block under 40 lines. Say which lines you removed and why the failure stayed.

💡

Pro tip: Remove the largest piece first, then the smaller ones. The order saves the most time.

Stack Trace Walkthrough

3/30

✨ What it does

Turns a raw stack trace into a table that ranks each frame by how likely it is to hold the cause. Check the top row against the file it names before you change code, since the frame that throws is often not the frame that caused the bad input.

I am running this in Ask Mode, which is read-only. Here is the stack trace: [STACK TRACE]. The error message is [ERROR MESSAGE]. Open each file the trace names before you describe its frame. Do not describe code you have not opened. Start at the frame that throws and go outward. For each frame, write one row: the function, the file, what the frame does and how likely it is to hold the bug. Name the most likely frame and give the evidence from the trace. Output a table with columns Frame, File, Role and Suspicion, then one sentence on what you could not open.

💡

Pro tip: Paste the whole trace, not only the last line. The cause often sits several frames up.

Regression Bisect Steps

4/30

✨ What it does

Gives a numbered git bisect plan for a regression between two commits, with the expected number of stops. Test each stop with the same input, because a bisect run that changes the input halfway will point at the wrong commit.

The last good build was [GOOD COMMIT] and the first bad build is [BAD COMMIT]. The symptom is [SYMPTOM]. Count the commits between [GOOD COMMIT] and [BAD COMMIT] with git first, then say how many bisect stops to expect (about log base 2 of the count). Give numbered steps to find the commit that caused the symptom with git bisect: the start command, how to mark a bad and a good commit, and what to check at each stop. Test each stop with the same input. Keep the whole answer under 200 words.

💡

Pro tip: Write the symptom as a yes or no check before you start, so every stop gives the same answer.

Bug Report Triage Options

5/30

✨ What it does

Ranks three possible causes for a user bug report and names the file to check first for each. Run the one-line test for the top cause before anyone opens a pull request, since a report often describes the symptom and not the cause.

Here is a bug report from a user: [BUG REPORT TEXT]. Give three possible causes. For each, name the file or area in [FILE PATH] that you would check first, and write the one-line test that would confirm or rule it out. Then pick the most likely cause and explain the pick in two sentences with the evidence. Mark any missing detail as MISSING DETAIL. Do not invent features, settings or logs the report does not mention.

💡

Pro tip: Paste the report exactly as the user wrote it. Paraphrases lose the detail that matters.

Trace and log

5 prompts

Targeted Logging Plan

6/30

✨ What it does

Builds a logging plan as a table, with one row per log line, its variables and a condition that limits the output. Add only the lines in the plan, run the failing case once, and remove every line after the fix so the code stays clean.

I need to see why [FUNCTION NAME] returns [WRONG VALUE] in [FILE PATH]. Before you add any log line, state the hypothesis you are testing and the evidence for it. Then produce a logging plan as a table with columns Location, Variable, Why it matters and Limit. Each row is one log line: the exact spot in the file, the variables it prints, and the condition that keeps output to the failing case. Add no logging library or config file the project does not already use.

💡

Pro tip: Ask for a condition on every line. An unfiltered log inside a loop floods the terminal.

Request Path Trace

7/30

✨ What it does

Maps one request from the route to the database as a numbered list, with the file and line for each call. Put your first log line at the split point it marks, since the bug often sits just after the last step that behaved.

I have @-mentioned the files on that path. Trace one request from the route handler for [ROUTE NAME] down to the database call. Read each file before you name it. Write the path as a numbered list of function calls, with the file and line for each step. Mark the first step where [EXPECTED BEHAVIOUR] and [ACTUAL BEHAVIOUR] split. Give the hypothesis for that step and the evidence in the code, and describe only the functions you have opened.

💡

Pro tip: Type @ and pick each file on the path. Name the route as it appears in the code.

Production Log Triage

8/30

✨ What it does

Groups a production log excerpt into patterns with counts and first timestamps. Confirm the top pattern in a staging run before you call it the cause, since logs show what happened and not always why it happened.

Read the log excerpt below, taken from [TIME WINDOW] when [SYMPTOM] happened: [LOG EXCERPT]. Work only from the lines I pasted. Group the lines into up to five patterns, count each pattern, and give the timestamp of its first line. Then name the one check that would separate the two most likely patterns. If a field that check needs is missing, write MISSING FIELD instead of guessing its value. Output a table of up to five rows with columns Pattern, Count, First seen and Linked to symptom, then two lines: the check, and any MISSING FIELD note.

💡

Pro tip: Strip tokens and customer names first. Recount with grep before you trust a count.

Working Versus Broken Logs

9/30

✨ What it does

Lines up a working log against a broken one and finds the first step where they part ways. Check the result by adding that log line, rerunning both flows, and confirming the broken run now matches the working run up to the named line.

Compare a working run and a broken run of [FLOW NAME]. Working log: [WORKING LOG]. Broken log: [BROKEN LOG]. Line up the two logs step by step and mark every step that appears in one run and not the other. Give the earliest difference and a hypothesis for its cause, with the evidence from the two logs. Output a table with columns Step, Working, Broken and Difference, then one sentence naming the log line to add next.

💡

Pro tip: Use runs from the same commit, or the difference may come from the code and not from the bug.

Interview Before Tracing

10/30

✨ What it does

Has the model ask five questions about a bug and wait for the answers before it reads any code. The three hypotheses that follow each name the evidence needed, so you know what to test first.

Ask me exactly five questions about [BUG SUMMARY] before you read any code. Cover the input that triggers it, the environment, what changed last, what I already tried, and what I expected. Stop after the fifth question and wait for my answers. Then read [FILE PATH], state three hypotheses with the evidence each one needs, and name the single log line that would prove or rule out the top hypothesis. Do not invent a stack trace or a file name I have not given you.

💡

Pro tip: Answer with real values, such as the exact input, not a word like bad.

Concurrency and runtime

5 prompts

Race Condition Hypothesis

11/30

✨ What it does

Lists the shared values that two async paths touch in the named function and marks each one safe or unsafe. Check the hypothesis by running the timing test on the unchanged code, where the bad order should make it fail.

The bug only shows up when [CONCURRENT ACTIONS] happen within [TIME WINDOW]. Read [FILE PATH] and the function [FUNCTION NAME] first. Output a table of up to five rows with columns Value, Access, Verdict and Reason, covering the most important shared values that two async paths can read or write. Then state your hypothesis for the race and the evidence from the code, and propose one timing test that forces the bad order, in under 200 words. Add no locks, queues or logs until I confirm the hypothesis. I will use Debug Mode for the reproduction after that.

💡

Pro tip: Name the two actions that collide, such as a save and a refresh, not only the word race.

Unhandled Promise Template

12/30

✨ What it does

Fills a fixed template for an unhandled promise rejection, based on the file and error you name. A fix that passes both before and after the change proves nothing, so check the test that fails before the fix first.

Fill in this template using only the code in [FILE PATH] and the error [ERROR MESSAGE]. Symptom: one sentence on what the user sees. Unawaited or uncaught call: the function, the file and the line. Missing await or missing catch: the exact spot. Hypothesis and evidence: one sentence each. Smallest fix: under 10 lines of code. Test that fails before the fix: its name and one sentence. Add no library call you have not read, and write UNKNOWN in any field the code does not answer.

💡

Pro tip: Keep the filled template in the pull request description so reviewers see the same fields.

Memory Growth Checklist

13/30

✨ What it does

Builds a checklist of listeners, timers, caches and observers that are added in one file but never removed. A single snapshot cannot show growth, so take two at the same points in time before you trust the top item.

My [SERVICE NAME] process grows from [START MEMORY] to [END MEMORY] over [TIME WINDOW]. Build a checklist for [FILE PATH]. Each item is a listener, timer, cache or observer that is added without a matching removal, with its file and line. Mark each item as found in the code or not found, based only on what you read. Then state your hypothesis for the strongest candidate, with its evidence, and the one heap snapshot step that would confirm it. Name no profiler option the project does not show.

💡

Pro tip: Record memory at fixed times, such as every ten minutes, so the growth has a slope you can read.

Slow Function Critique

14/30

✨ What it does

Critiques one slow function line by line, then rewrites only its slowest block. The rewrite stays a hypothesis until a measurement on the same input shows the new timings.

Here is the slow function from [FILE PATH]: [PASTED CODE]. Timing: [CURRENT TIMING] on [INPUT SIZE], target [TARGET TIMING]. Critique the code in a table with columns Line, Cost and Why. Then rewrite only the slowest block, in under 25 lines, and name the measurement that would show whether the rewrite reaches the target. Claim no speed-up until that measurement has been run, and keep the output the same as before.

💡

Pro tip: Use timings from the same input and the same machine, or the comparison means nothing.

Retry Storm After Timeout

15/30

✨ What it does

Lists each retry point that could multiply load after a timeout, with whether it has a backoff, jitter and a cap. Check the top finding by forcing a timeout in staging and counting retries per request ID, since one request can look harmless on its own.

After a timeout, [SERVICE NAME] clients seem to retry at once, and the logs show [RETRY PATTERN]. Read the retry code in [FILE PATH] and the timeout setting you find there. List every place a request is retried, with its file and line. For each retry, state whether it has a backoff, a jitter step and a retry cap, based only on the code you read. Name the path most likely to multiply the load, with the evidence, and the one change that would cut the retries. Output a table of up to five rows with columns Retry point, File and line, Backoff and Verdict.

💡

Pro tip: Count retries per request ID in the logs, not total requests, to see the multiplier.

Like these prompts? There are full tutorials behind them.

Learn the workflows, not just the prompts. Easy-to-follow tutorials inside AI Academy, and the library keeps growing.

Try AI Academy Free

Types, dependencies and builds

5 prompts

Null Crash Guard

16/30

✨ What it does

Lists every value on the path to the crashing line that can be empty, with the condition for each. Check each row by passing that empty value into a test and confirming the guard runs only in that case.

Act as a careful reviewer of [FILE PATH]. The error is [ERROR MESSAGE] on line [LINE NUMBER]. Find every value on the path to that line that can be null or undefined, and give the condition under which each one is empty, based only on the code you read. Propose the smallest guard that stops the crash. Output a 4-row table with columns Value, Empty when, Guard and Hides a real bug?, under 200 words. Use no default value unless the code shows what it should be.

💡

Pro tip: Use the line number from the stack trace, not the line where you first noticed the error.

Type Narrowing Steps

17/30

✨ What it does

Gives numbered type-narrowing steps for one failing call, each with the guard to add. Read where the value comes from before you accept an assertion, since a cast can hide the mismatch that caused the error.

Read the type definition for [TYPE NAME] and the call that fails with [ERROR MESSAGE]. Give numbered steps to narrow the type at that call site, one check per step, and write the exact type guard you would use for each. Do not use a type assertion that hides a real mismatch without flagging it as a risk. Say which steps you can skip if the value comes from a typed source you have opened.

💡

Pro tip: Paste the full type definition, including any union it extends, not a summary of it.

Upgrade Break Plan

18/30

✨ What it does

Writes a step-per-check plan to roll back one upgraded package and rerun the build. Roll back one package at a time, so you can tell which upgrade broke the build.

I am running this in Plan Mode. After upgrading [PACKAGE NAME] from [OLD VERSION] to [NEW VERSION], the build fails with [ERROR MESSAGE]. Read the lock file and the package manifest first. List the changes that could cause this, each with the evidence from those files. Write a plan with one step per check: roll back only that package, rerun the build, and record the result. Describe the package changelog only if you have opened it.

💡

Pro tip: Keep the old version number handy, since the rollback needs the exact pinned version.

Import Path After Move

19/30

✨ What it does

Produces a checklist of every import that still points to a file's old location, one line per file. Rerun the build once every line is ticked, and treat any entry point that still fails as a missed import.

The error [ERROR MESSAGE] appeared after I moved [FILE PATH] into a new folder. I have @-mentioned the files that import it. State your hypothesis and the evidence for it before you edit anything. List every import that still points to the old path, and add the alias or path config you have read that resolves those imports. Output a checklist with one line per file: old import, new import, and a tick once it is fixed. Invent no config file that the project does not contain.

💡

Pro tip: Type @ and pick each file that imports the moved one. Also search for the old name, since some imports are strings.

Build Failure For Product Teams

20/30

✨ What it does

Rewrites one build failure twice, once in plain language for a non-engineer and once as a 60 word note for engineers. The engineer version carries the evidence, so a reviewer can check the claim against the log.

Rewrite the build failure [ERROR MESSAGE] for a product manager who does not read code. Keep the file name and the error code, remove the jargon, and write three sentences: what broke, what it blocks, and what the team needs to decide. Then give the engineer's version in 60 words for the pull request thread, with your hypothesis and the evidence from the log. Do not state a cause that the log does not confirm.

💡

Pro tip: Paste the first error line rather than the whole log, so the rewrite stays short.

Environment-only failures

5 prompts

Local Versus CI Table

21/30

✨ What it does

Compares local and CI settings in a table and names the one most likely to cause the failure. Match that one setting locally before you change any code, so you test the cause and not a guess.

The test [TEST NAME] passes on my machine and fails in CI with [ERROR MESSAGE]. My local setup: [LOCAL SETUP NOTES]. The CI job: [CI JOB NOTES]. Read the CI workflow file at [FILE PATH] before you guess. Produce a table with columns Setting, Local, CI and Why it matters. Name the setting most likely to cause the failure and give the evidence from the workflow file. Name no CI variable or version that the workflow file does not show.

💡

Pro tip: Include the language and tool versions from both places, since version gaps cause many of these failures.

Environment Variable Checklist

22/30

✨ What it does

Marks every variable the code reads as set, missing or defaulted in each environment. The missing ones are the first suspects, but check the value and not only the name, since an empty string can pass a presence check.

Check every environment variable the code reads in [FILE PATH] against the variables set in [CONFIG FILE]. Produce a checklist with one line per variable, marked Set in CI, Set locally, Missing in CI or Default in code, with its file and line. Then state your hypothesis for [ERROR MESSAGE] and the evidence in those lines. Check each variable's value, not only its name, and quote each variable name exactly.

💡

Pro tip: Name the CI config file exactly as it appears in the repo, including its folder.

Timezone Bug Options

23/30

✨ What it does

Gives three time zone causes for a wrong date, each with a fixed-clock test. Set the clock to the value of the failing run and run each test, so hour-dependent bugs show up.

A date shows [WRONG DATE] in [ENVIRONMENT] but [EXPECTED DATE] on my laptop. Using only the date code in [FILE PATH], give three possible causes: the server time zone, a date parsed without a zone, or a daylight saving boundary. Output a 3-row table with columns Cause, Fixed-clock test and Would show, under 200 words, then name the most likely cause and its evidence. Change nothing until I confirm the choice.

💡

Pro tip: Note the time zone of the failing machine, not only the one on your own laptop.

Container Only Failure

24/30

✨ What it does

Matches each symptom to a likely cause found in the Dockerfile and compose file, then gives the next command to run. Read that command's output first, because it decides which cause is real.

The service starts with [LOCAL COMMAND] on my laptop but fails in the container with [ERROR MESSAGE]. Read the Dockerfile at [FILE PATH] and any compose file in the repo. List the symptoms in the order they appear in the logs. Output a 4-row table with columns Symptom, Likely cause, File and Next check, under 200 words, then the next command to run and what each possible output would mean. Use no image tag, port or path that is missing from the files you read.

💡

Pro tip: Paste the first error line from the container, since it often names the missing file or variable.

Encoding Fix Critique

25/30

✨ What it does

Scores a draft fix on four points and rewrites only the weak ones. Test the input that broke it, such as an accented name or an emoji, before you merge, because the draft may pass on plain ASCII and still fail.

Here is my fix draft for [ENCODING ISSUE] in [FILE PATH]: [FIX DRAFT]. Score it from 1 to 5 on four points: fixes the reported case, keeps other inputs working, uses only functions that exist in the code I shared, and comes with a test. Give the scores in a table with columns Point, Score and Reason. Then rewrite only the points that scored below 4, and show the failing input you used. Change only the files I shared.

💡

Pro tip: Paste the failing input in the exact bytes you saw, not a retyped copy.

Go from copy-pasting to actually mastering AI.

AI Academy: hands-on tutorials on ChatGPT, Claude, Midjourney, and many other tools. New tutorials are added regularly.

Start Your Free Trial

Tests and post-mortems

5 prompts

Explain Failing Test

26/30

✨ What it does

Explains a failing test in at most 120 words and sets what the test expects against what the code returns. Decide which side is wrong before you edit anything, since a test can match the old behaviour while the code is right about the new one.

Explain why the test [TEST NAME] in [FILE PATH] fails with [ERROR MESSAGE]. Read the test and the code under test before you answer. Say whether the test or the code is wrong, with the evidence from both, in no more than 120 words. Then output a table with two rows: what the test expects and what the code returns. Change the test only after I confirm which side is wrong.

💡

Pro tip: Paste the assertion line too, because it shows the exact value that did not match.

Regression Test Writer

27/30

✨ What it does

Writes one regression test that should fail on the old code and pass on the fix, in the project's own test style. Run it against the old commit before you merge, because a test that never failed proves nothing about the bug.

Before you write anything, state your hypothesis for [BUG SUMMARY] in [FILE PATH] and the evidence for it. Then write one regression test for that bug. The test must fail on the old code and pass on the fixed code. Read the existing test file next to it and match its framework and naming, and use no helper it does not already use. Give the test in one code block, then three numbered steps to confirm it fails before the fix.

💡

Pro tip: Name the commit or branch where the bug still exists, so the failing run is real.

Minimal Patch With Test

28/30

✨ What it does

Asks for the smallest patch to one bug, with its hypothesis and one test, shown as a short diff. Review the diff line by line against the hypothesis, because a small patch can still change a neighbouring case.

Make the smallest change that fixes [BUG SUMMARY] in [FILE PATH], then add one test. I have attached @Commit (Diff of Working State), my uncommitted changes. First write your hypothesis and its evidence in two sentences, and list the files you read. Show the patch as a diff of at most 30 lines and the test as one code block. Change no other file, and use only utility functions the project already exports.

💡

Pro tip: Type @ and choose Commit (Diff of Working State) from the list.

Short Post-Mortem Note

29/30

✨ What it does

Writes a four line post-mortem of 150 words at most, with the root cause and fix taken from your diff summary. Mark any missing fact as UNKNOWN, since a post-mortem that guesses a cause tends to be quoted later as fact.

Write a post-mortem for [INCIDENT TITLE] in 150 words at most, under four labelled lines: What broke, Root cause, Fix and Follow-up. Take the root cause and the fix only from the diff summary I paste here: [DIFF SUMMARY]. Mark anything the evidence does not show as UNKNOWN. Keep names out of the note, and add no date, duration or user count that I have not given you.

💡

Pro tip: Paste the failing test name too, since it is the strongest evidence the note can cite.

Pull Request Debug Checklist

30/30

✨ What it does

Lists ten checks to run before a bug fix pull request, each marked as needed or not needed for this change. Run the regression test on the old commit yourself, because a checklist can say a check passed without anyone having run it.

Before I open a pull request for the fix to [BUG SUMMARY], give me a checklist of ten checks. Include reproducing the bug on the old commit, running the failing test, confirming the regression test fails before the fix, checking the logs for the old error, and running the /agent-review command on the local changes. Read the repo files first. Do not list a project command or CI job you did not find in the repo files. Output ten lines, each with the check, Needed or Not needed for this change, and a few words of reason.

💡

Pro tip: Tick each check in the pull request description so reviewers can see what ran.

Free tool

Prompt Optimizer

Turn a rough idea into a structured, professional AI prompt.

Try it free →

Frequently Asked Questions

Use Debug Mode for bugs you can reproduce but cannot figure out, race conditions and timing issues, performance problems and memory leaks, and regressions. It proposes causes, adds logs, asks you to reproduce the bug, and reads the logs before it changes the code.
Remove tokens, passwords, session cookies and customer names before you paste any log. Check your team's policy and Cursor's own settings before you share production logs at all.
A stated hypothesis tells you which evidence should appear in the logs or the test. If the evidence does not match, the guess was wrong, and you have not lost time on a patch that only hides the symptom.
It can read the code and propose a cause, but a fix you cannot test is a guess. Ask for the reproduction steps first, run them yourself, and only then accept a patch with its regression test.
Run the failing input on the old commit, where it should fail, and on the fixed code, where it should pass. Keep the regression test in the repo so the same bug fails loudly if it ever comes back.

Prompts are the starting line. Tutorials are the finish.

A growing library of hands-on tutorials on ChatGPT, Claude, Midjourney, and many other AI tools. New tutorials are added regularly.

7-day free trial. Cancel anytime.