What Should You Give Cursor to Fix a Bug?
Paste the full error or stack trace, say exactly when it happens, state what should happen instead, and ask for the root cause before the fix. For errors in your terminal, type @Terminals to attach the output rather than retyping it.
This is failing: [paste the full error or stack trace, or attach @Terminals] It happens when: [exact steps, input or user type] It should: [expected behavior] It started: [after which change, if known. Use @Branch if it's on this branch] Find the root cause and explain it in one or two sentences before changing anything. Then make the smallest fix and add a regression test that would have caught this. Run [test command] and show me the result.
- Errorwhere it failed
- Triggerwhen it happens
- Expectedwhat should happen instead
- Root cause firstbefore any fix
Try it now
- 1Run the failing command in Cursor's terminal so the output is there to attach.
- 2Open Agent with Cmd+I (Ctrl+I), paste the prompt above, type
@Terminalsand pick the terminal. - 3Before accepting the fix, ask "Is this the root cause, or does it mask the symptom?" It worked if the explanation points to a real cause and the new test fails without the fix.
Use it when
Runtime errors, failing tests and build failures with a clear message. Start here, because it's the fastest route when the cause is visible. For slowness, the same pattern works with real data, such as pasted EXPLAIN ANALYZE output, query logs or profiling results.
Skip it when
Intermittent bugs with no consistent error, or anything where a first fix attempt has already failed. Use Debug mode, which collects runtime evidence. If you can't trigger a bug yet, work on that first, since Cursor's course says that without a reproduction you can't verify the fix.
Why it works
A stack trace gives Agent a starting file and line. The trigger tells it which path through the code matters, which the trace alone often can't show. Cursor's course makes this point with an example: the same TypeError becomes easy once you add that it only affects users created before a profile onboarding flow existed. Agent can then read the code, follow the path and patch it. Cursor says this works well when the cause shows in the error message, and that trickier bugs need a more systematic approach.
Example
Cursor's course shows this trace: TypeError: Cannot read properties of undefined (reading 'profile'), from getProfile at src/services/UserService.ts:45. You add that it happens when a user created before the onboarding flow views their profile. Now Agent has the file, the line and the reason some records have no profile. A null check alone would hide that, so ask what should happen for those older users.
Going further
Know about one hidden difference between your shell and Agent's. Cursor's troubleshooting page says it sets CI=1 when Agent runs terminal commands, which can change how your tools behave. A test that passes for you and fails for Agent, or the reverse, may come from this. Run it as unset CI && your-command, or add a rule telling Agent to do so. For production issues, MCP servers for tools such as Sentry and Datadog let it pull error details itself instead of relying on what you paste.
Common mistakes
- Paraphrasing the error. The exact text and line numbers are often what the agent searches for.
- Accepting a fix you don't understand. Cursor warns that a null check can make the error go away while the data problem stays.
- Leaving out the trigger, so Agent fixes the first plausible cause instead of yours.
- Skipping the regression test, so the same bug can come back unnoticed.
Sources
- Finding and fixing bugs, Cursor Learn
- Prompting agents, Cursor Docs
- Agent troubleshooting, Cursor Help
- @ mentions and context, Cursor Help
Checked 6 November 2026. Products change often, so confirm details with the vendor.