These 40 prompts cover the full loop in Cursor — setting context, building, running Agent mode, debugging, refactoring, testing, reviewing, and shipping. Every one is a real message you paste into the chat pane. The pattern that makes them work: point at exact context with @-symbols (@Codebase, @Docs, @Web, @Git, @Terminal), name the files Agent may touch, and give it acceptance criteria plus "run the tests" so it can check its own work.

You pick the model per chat — Claude Opus 4.8, GPT-5.x, Gemini, or Auto — but technique matters more than the model. Save the standing stuff (stack, conventions, "stay in scope") in .cursor/rules so you stop repeating it. New to this? Read how to prompt Cursor for coding, keep the Cursor prompt cheat sheet open, and grab reusable skeletons from the Cursor prompt templates.

Advertisement

Setup & context

Five prompts to give Cursor the right context before it does anything. Point at files and docs explicitly with @-symbols instead of hoping the model finds them.

1. Onboard Agent to a New Repo

Get your bearings in this repo before we change anything. Use @Codebase.

Do this:
- Map the project: languages, frameworks, entry points, and how it's built, run, and tested.
- Summarize the architecture in a short paragraph plus a bullet list of the main modules.
- List the commands to build, run, lint, and test.
- Flag anything fragile or unusual I should know before we make changes.

Don't edit any files yet — just report back.

Best for: Starting a session in unfamiliar code — a look-before-you-leap pass makes every later change better-informed.

2. Answer a Question About the Codebase

Use Ask mode. With @Codebase, answer this without editing anything:

Question: [where does X happen / how does Y flow through the system]?

Do this:
- Point me to the exact files and functions involved, with paths.
- Explain the flow in order, step by step.
- Note anything surprising or inconsistent you find along the way.

Why it works: Ask mode is read-only, so you get an explanation and a map of the code without any accidental edits.

3. Pull in Files and Docs Explicitly

I'm attaching exactly the context you need — use only this, don't wander the repo.

@[path/to/file-a] @[path/to/file-b] #[path/to/related-file]

Task: [what I want done], matching the patterns in the files above.

Do this:
- Follow the conventions in the attached files.
- Ask me for any file you need that I haven't attached instead of guessing.

Best for: Focused changes — attaching the exact files with @ and # keeps Cursor on the code that matters.

4. Research an API With @Web and @Docs

Before you write code, check the current API. Use @Docs [library] and @Web.

Task: I need to [use feature] with [library/version].

Do this:
- Confirm the current, non-deprecated way to do this from the docs.
- Show a minimal working example that matches our stack: [stack].
- Note any recent breaking change or gotcha from the version we're on.
- Cite the doc or page you relied on.

Why it works: @Docs and @Web pull live, version-accurate information so Agent doesn't code against an API it half-remembers.

5. Generate .cursor/rules for the Project

Using @Codebase, draft project rules for Cursor so I stop repeating myself.

Do this:
- Create a .cursor/rules/ directory with focused .mdc files (e.g. general, testing, and one per major area).
- For each file, set the right type (Always, Auto Attached with a glob, or Agent Requested) and a scoping glob.
- Capture our real conventions: language/version, formatting, folder layout, naming, how we write tests, and "don't touch unrelated files".
- Keep each rule short and specific — no vague advice.

Show me the files and where they go before creating them.

Best for: Encoding conventions once so every Ask, Agent, and inline run follows them automatically.

Build features

Seven prompts to go from idea to working code. Give exact paths, attach a sibling file to match patterns, and define what "done" looks like.

6. Build a Feature From a Spec

Agent mode. Implement this feature end to end. Plan before editing.

Feature: [what it does]. Acceptance: [how we'll know it works].
Files likely involved: [path/a], [path/b] — confirm and add any others you need.

Do this:
- Outline your plan and the file list before making changes.
- Match the existing patterns in the surrounding code.
- Add or update tests, then run them and fix any failures.
- Summarize what changed and why.

Only touch the files needed for this feature.

Why it works: A clear spec, exact paths, and acceptance criteria let Agent self-check and stay in scope.

7. Scaffold a Component or Endpoint

Scaffold a [component / endpoint] following our conventions.

Stack: [framework and version]. It should [responsibility]. It talks to [DB / API / module].
Match the pattern in @[path/to/a/sibling-file].

Do this:
- Create the file(s) at the right path with types, error handling, and a minimal test.
- Leave clearly marked TODOs where I need to fill in business logic.
- List the files you created and a one-line note on each.

Don't wire it into anything else yet.

Best for: Consistent boilerplate — a sibling file in context means Cursor matches your structure, not a generic one.

8. Build UI From a Screenshot or Description

Build this UI. [Attach the screenshot, or describe it below.]

What it is: [screen/component]. Layout: [describe]. States: [empty, loading, error].
Stack: [framework + styling]. Match @[path/to/existing-component] for style and structure.

Do this:
- Build a responsive, accessible component with sensible defaults.
- Handle the empty, loading, and error states.
- Use our existing design tokens/components, not new ad-hoc styles.
- Show me the component and where it lives.

Why it works: Naming the states and an existing component to match keeps the UI on-brand and production-ready, not a rough mock.

9. Wire Up an API Call

Wire [component/page] to [the API endpoint]. Use @Docs [library] if needed.

Endpoint: [method + path]. Request: [shape]. Response: [shape].
Follow the data-fetching pattern in @[path/to/existing-fetch].

Do this:
- Add the call with proper loading and error handling.
- Type the request and response.
- Handle non-200s and network failures gracefully.
- Add a test that mocks the endpoint.

Best for: Reliable integrations — pinning the endpoint shapes and an existing pattern avoids guesswork.

10. Add a Form With Validation

Add a [form name] form with validation.

Fields: [field: type/rules, ...]. Submit does: [action]. Stack: [form/validation lib].
Match the pattern in @[path/to/an/existing-form].

Do this:
- Build the form with client-side validation and clear inline error messages.
- Disable submit while invalid or in flight; show success and failure states.
- Type the values and the submit payload.
- Add tests for a valid submit and each validation rule.

Why it works: Listing fields and rules up front produces complete validation instead of a happy-path form you have to harden later.

Advertisement

11. Design a DB Schema and Query

Design the schema and queries for this feature. Use @Docs [ORM/DB] if relevant.

What we're storing: [entities and relationships]. DB: [Postgres / MySQL / SQLite].
Existing schema/migrations: @[path/to/schema].

Do this:
- Propose the tables/columns/indexes with reasoning; call out trade-offs.
- Write the migration in our existing style.
- Write the main query/queries this feature needs, formatted and explained.
- Warn me about NULLs, uniqueness, and performance concerns.

Best for: Getting the data model right before code depends on it — indexes and trade-offs are called out, not buried.

12. Build a Small Internal Tool

Agent mode. Build a small self-contained tool.

What it does: [describe]. Input: [source]. Output: [format]. Run as: [CLI / script / tiny web page].

Do this:
- Create it as a new file/folder at [path]; keep dependencies minimal.
- Handle empty input and error cases.
- Add a short usage note at the top and a smoke test.
- Run it once to confirm it works, then show me the output.

Why it works: Scoping it to a new path and asking Agent to run it once closes the loop on a working tool, not a draft.

Agent mode & multi-file

Six prompts for driving Agent across many files. Make it plan first, define "done", and gate risky actions behind your approval.

13. Plan Before You Edit

Plan this change before touching any code. Use @Codebase.

Goal: [what should be true when done].

Do this:
- Find every file involved and list them with a one-line reason each.
- Propose a step-by-step plan and the order of edits.
- Call out risks, unknowns, and anything you'd want to confirm with me.

Don't edit anything yet — wait for me to approve the plan.

Best for: Big or risky changes — approving the plan and file list first prevents surprise edits.

14. Implement a Change End to End

Agent mode. Implement this change across the repo, plan first.

Goal: [what should be true when done]. Acceptance: [how we'll know].

Do this:
- Outline the plan and file list, then make the change following existing patterns.
- Add or update tests, run them, and fix failures until green.
- Show a summary of what changed and why.

Ask before anything destructive (deleting files, migrations, force-push).

Why it works: Acceptance criteria let Agent verify itself, and the guardrail keeps risky actions behind your approval.

15. Cross-File Rename or Migration

Rename/migrate [old] to [new] everywhere it's used. Use @Codebase to find all usages.

Do this:
- List every file and reference that needs to change before editing.
- Make the change consistently across all of them, including imports, types, tests, and docs.
- Update any config or string references, not just code symbols.
- Run the build and tests afterward and fix anything that broke.

Report anything ambiguous instead of guessing.

Best for: Repo-wide renames — listing usages first catches the references a find-and-replace would miss.

16. Kick Off a Background Agent Task

Run this as a background agent task while I keep working.

Task: [self-contained chunk of work]. Acceptance: [how we'll know it's done].

Do this:
- Work through it independently, following our conventions and .cursor/rules.
- Add/update tests and run them until they pass.
- Keep the change scoped to [paths]; don't touch anything else.
- When done, summarize the change and flag anything that needs my decision.

Why it works: Background agents shine on well-scoped, self-checkable tasks you can hand off and review later.

17. Stay in Scope — Don't Touch Unrelated Files

Make this change with a strict scope.

Change: [what to do]. Allowed files: [path/a], [path/b] — these only.

Rules:
- Do not modify, reformat, or "clean up" any file outside the allowed list.
- If the change genuinely requires touching another file, stop and ask me first.
- No drive-by refactors, no import reordering elsewhere, no version bumps.

Show me the per-file diff when you're done.

Best for: Keeping a diff small and reviewable — an explicit allow-list stops helpful-but-unwanted edits.

18. Auto-Run the Test Loop

Agent mode with auto-run. Make [change] and don't stop until the tests pass.

Do this:
- Make the change, then run [test command].
- Read the output, fix failures, and re-run — loop until everything is green.
- If a test looks wrong (not the code), stop and explain before changing it.
- When green, summarize what you changed and paste the final test output.

Why it works: Letting Agent run tests, read output, and iterate turns "write code" into "deliver working code".

Debug & fix

Five prompts for getting unstuck. Feed Cursor the real signal with @Lint Errors, @Terminal, and expected-vs-actual.

19. Diagnose From @Lint Errors and @Terminal

Diagnose and fix the current errors. Use @Lint Errors and @Terminal.

Context: I was trying to [what you were doing]. Expected: [X]. Actual: [Y].

Do this:
- Give the most likely root cause first, then alternates.
- Apply the exact fix and point to where it goes.
- Run the relevant command/test to confirm it's resolved.
- Suggest one change that would stop this class of error recurring.

Best for: Fast diagnosis — @Lint Errors and @Terminal hand Cursor the real errors instead of your paraphrase.

20. Fix a Failing Test

A test is failing and I'm not sure if the test or the code is wrong.

Test: @[path/to/test]. Code under test: @[path/to/code].
Run [test command] and read the failure with @Terminal.

Do this:
- Tell me whether the bug is in the test or the code, and how you know.
- Apply the minimal fix.
- Re-run the test to confirm it passes and nothing else broke.

Why it works: Deciding test-vs-code first stops Cursor from "fixing" a test that was correctly catching a real bug.

21. Reproduce a Bug First

Reproduce this bug before fixing it. Use @Codebase to find the relevant code.

Report: "[paste the user's description]". Steps: [if known]. Expected vs actual: [both].

Do this:
- Write a failing test (or a repro script) that demonstrates the bug, and run it to confirm you see it.
- Only then trace to the root cause and apply the smallest safe fix.
- Re-run the test to prove it's fixed.

Report the root cause, the fix, and how you verified it.

Best for: Fixes you can trust — a failing test up front proves the bug is real and later proves it's gone.

22. Trace a Bug Across Files

Trace this bug across the codebase. Use @Codebase.

Symptom: [what's wrong]. Where it surfaces: @[path/to/file].

Do this:
- Follow the data/control flow from where the symptom appears back to its source.
- List each hop (file → function) so I can see the path.
- Identify the actual root cause, not just the symptom's location.
- Propose the fix and the smallest place to make it.

Why it works: @Codebase lets Cursor follow the call chain across files instead of patching wherever the error happens to appear.

23. Fix a Type or Build Error

Fix this type/build error properly, not by suppressing it. Use @Terminal and @Lint Errors.

Error: [paste it if not already in context].

Do this:
- Explain what the error actually means here.
- Fix the underlying cause; don't reach for "any", @ts-ignore, or casts unless truly unavoidable — and justify it if you do.
- Run the build/typecheck to confirm it's clean.
- Flag any related spot the same issue might hide.

Best for: Clean builds — asking for the real cause avoids the tempting one-line suppression that hides the bug.

Refactor & clean up

Five prompts for changing code safely. The guardrail throughout: behavior must not change unless you say so.

24. Refactor for Readability, No Behavior Change

Refactor @[path/to/file] for readability without changing behavior.

Do this:
- Keep the exact same inputs and outputs.
- Improve naming, structure, and flow; remove obvious duplication.
- Run the existing tests to prove behavior is unchanged.
- List what you changed and why, and flag any latent bug you noticed.

Don't touch any other file.

Best for: Cleaning inherited code — the no-behavior-change rule plus running tests keeps it safe to merge.

25. Extract Functions From a God Function

Split the large function in @[path/to/file] into smaller, well-named pieces.

Do this:
- Extract logical units into named helpers with single responsibilities.
- Keep behavior identical; note any hidden coupling you find.
- Give each new function a one-line description of its job.
- Run the tests to confirm nothing changed behaviorally.

Why it works: Named single-responsibility pieces give you a structure you can test, not just shorter code.

26. Remove Duplication

Find and remove duplication in these files. Use @Codebase to spot repeats.

Scope: @[path/a] @[path/b] (and closely related files).

Do this:
- Identify genuinely duplicated logic (not just superficially similar code).
- Extract it into one shared, well-named place; update all call sites.
- Keep behavior identical and run the tests.
- Don't over-abstract — if two things only look alike, leave them.

Best for: DRYing up code without creating the wrong abstraction — the "don't over-abstract" line matters.

27. Add Types to Untyped Code

Add types to @[path/to/file] without changing behavior.

Target: [TypeScript / Python hints / etc.].

Do this:
- Add accurate types; avoid "any"/loose types unless truly necessary.
- Where a type reveals a possible bug, flag it instead of hiding it.
- Keep runtime behavior identical and run the typecheck and tests.
- List any inconsistency the types surfaced that I should check.

Why it works: Types often expose latent bugs; asking Cursor to flag them turns a chore into a free audit.

28. Migrate a Library or Version

Migrate @[path/to/file] from [old library/version] to [new]. Check @Docs [new library] first.

Do this:
- Confirm the current API from the docs before editing.
- Rewrite using the new API, preserving behavior.
- List every changed call and what replaced it.
- Flag deprecations and breaking changes; run the build and tests.

If you're unsure about an API detail, check @Docs or ask — don't guess.

Best for: Version bumps — checking @Docs first keeps the migration accurate instead of based on stale memory.

Tests

Four prompts for coverage that catches real bugs. Point Cursor at the behavior and have it run what it writes.

29. Write Unit Tests and Run Them

Write thorough unit tests for @[path/to/file] and run them.

Framework: [Jest / pytest / etc.].

Do this:
- Cover the happy path, edge cases, and error paths.
- Include boundaries I'd forget (empty, null, max, negative, unicode).
- Name each test after the behavior it verifies.
- Run the suite and fix any failures; paste the final passing output.

Best for: Real coverage — boundary cases are where the bugs hide, and Cursor runs the tests to prove they pass.

30. Find the Coverage Gaps

Tell me what I'm not testing. Code: @[path/to/code]. Tests: @[path/to/tests].

Do this:
- List the untested paths, branches, and edge cases, ranked by risk.
- Write tests for the top gaps and run them.
- Flag any code that looks untested because it's actually unreachable or dead.

Why it works: Giving Cursor both the code and existing tests turns this into gap analysis instead of duplicate tests.

31. Write an Integration Test

Write an integration test for [flow], end to end. Use @Codebase to see how the pieces connect.

Flow: [start] → [steps] → [expected result].

Do this:
- Test the real integration between [components/modules], not each in isolation.
- Set up and tear down any needed state or fixtures.
- Assert on the observable outcome, not internal details.
- Run it and confirm it passes; note anything flaky and how you made it deterministic.

Best for: Confidence across boundaries — an integration test catches the wiring bugs unit tests miss.

32. Generate Test Data and Mocks

Generate test data and mocks for @[path/to/code].

Do this:
- Produce varied, realistic fixtures covering normal, edge, and invalid cases (empty, unicode, boundary numbers, missing optional fields).
- Mock [external dependency / API / DB] with responses for success and failure paths.
- Match the shapes in the real types/schema — @[path/to/types].
- Return them where our tests expect them, ready to run.

Why it works: Realistic fixtures and both success/failure mocks exercise the edges, not just the happy path.

Advertisement

Review & docs

Four prompts to raise the bar before you merge. Give Cursor the change's intent and a clear role.

33. Staff-Engineer Review of the Diff

Act as a staff engineer reviewing my changes. Use @Git to read the diff.

What this change is meant to do: [intent].

Do this:
- List issues most severe first: correctness, security, edge cases, then style.
- Give the file/line and a concrete fix for each.
- Call out what I got right so I keep doing it.
- Don't rewrite whole files — point to specific lines.

Why it works: @Git gives Cursor the real diff, and ordering by severity keeps the review on risk, not formatting.

34. Security Pass on the Change

Review my changes for security issues only. Use @Git for the diff.

Context: this code [handles user input / touches auth / calls external services].

Do this:
- Flag injection, auth/authorization gaps, unsafe deserialization, secrets in code, and XSS/CSRF/SSRF where relevant.
- Rate each finding (high/medium/low) with the attack it enables.
- Give the fix for each.
- Note anything you can't judge without seeing more of the system.

Best for: A focused security pass — narrowing the scope makes Cursor thorough on the thing that matters most.

35. Write Docs or a README

Write documentation for @[path/to/module or the project].

Audience: [teammates / external users / future me].

Do this:
- A short "what and why" overview.
- Usage examples that actually run.
- Parameters, return values, and errors in a table.
- Gotchas and assumptions a newcomer would trip on.

Match the tone of docs a good open-source project would ship.

Why it works: Examples plus gotchas make docs people actually read, instead of a dry API dump.

36. Explain Unfamiliar Code

Ask mode. Explain @[path/to/file] to me like I'll have to maintain it.

Do this:
- Give a plain-English summary of what it does and why it exists.
- Walk through it in execution order, calling out anything non-obvious.
- Explain how it connects to the rest of the system (@Codebase if needed).
- Flag anything that looks like a bug, a smell, or a risky assumption.

Don't change anything — just explain.

Best for: Ramping onto inherited code — Ask mode explains without touching a thing.

Git & shipping

Four prompts for the last mile. Base everything on the actual diff with @Git, not assumptions.

37. Commit Message From the Diff

Write a commit message from my staged changes. Use @Git diff.

Do this:
- A conventional commit: subject under 72 chars, then a body explaining what and why.
- Group related changes; don't just list every file.
- Note any breaking change with a BREAKING CHANGE footer.

Base it on the actual diff, not assumptions.

Best for: Clean history — Cursor reads the real diff and writes the message you'd have rushed.

38. Write the PR Description

Write a PR description for this branch. Use @Git to read all the changes.

Do this:
- Summary: what changed and why.
- How it was tested (and how a reviewer can verify).
- Risks, migrations, or follow-ups.
- A short reviewer checklist, and the one or two things to look at most closely.

Keep it tight and skimmable.

Why it works: Reading the whole branch diff lets Cursor write a description grounded in what actually changed.

39. Update the Changelog

Update the changelog for this release. Use @Git for the changes since [last tag/version].

Do this:
- Group entries under Added / Changed / Fixed / Removed.
- Write each in user-facing language, not commit-speak.
- Call out breaking changes and any migration steps.
- Match the format already in @[path/to/CHANGELOG].

Best for: Release notes users understand — grouped, user-facing, and consistent with your existing format.

40. Resolve a Merge Conflict

Help me resolve the merge conflicts in @[path/to/conflicted-file]. Use @Git for context on both sides.

Do this:
- For each conflict, explain what each side was trying to do.
- Propose a resolution that preserves both intents where possible — don't just pick one blindly.
- Flag any conflict where the correct choice isn't obvious and ask me.
- After resolving, run the build and tests to confirm nothing broke.

Why it works: Explaining both sides before merging avoids silently dropping someone's change to make the conflict go away.

Keep the standing context — stack, conventions, "stay in scope", test commands — in .cursor/rules so Cursor carries it into every session. For the pattern behind these prompts, read how to prompt Cursor for coding, and for deeper packs see the Agent mode prompts and debugging prompts.

Frequently Asked Questions

What is Cursor?

Cursor is an AI-first code editor built as a fork of VS Code, so it keeps the same look, extensions, and keybindings while making AI a first-class part of editing. You chat with it in a side pane, edit selected code inline with Cmd/Ctrl+K, and let its Agent plan and make changes across many files. You pick the model per chat — Claude Opus 4.8, GPT-5.x, Gemini, or Auto.

What is the difference between Ask and Agent mode?

Ask mode is read-only: Cursor answers questions and plans, but it won't edit your files — good for understanding code or drafting an approach. Agent mode is autonomous: it plans, edits across multiple files, runs terminal commands and tests, reads the output, and iterates until the task is done. Use Ask to think, Agent to build.

How do @-symbols work in Cursor?

@-symbols point Cursor at exact context instead of hoping the model finds it. Type @ in the chat to attach @Files and @Folders, a symbol with @Code, the whole repo with @Codebase, library docs with @Docs, live results with @Web, diffs with @Git, and current problems with @Lint Errors or @Terminal. You can also add a file with # and run commands with /.

What are .cursor/rules?

Rules are persistent project instructions Cursor injects into every Ask, Agent, and inline run. The modern format is a .cursor/rules/ directory of .mdc files, each scoped by a glob and typed as Always, Auto Attached, Agent Requested, or Manual. The legacy single .cursorrules file at the repo root still works. Use rules for conventions, stack details, and things you'd otherwise repeat in every prompt.

Which model should I pick in Cursor?

You choose the model per chat. Claude Opus 4.8 is a strong default for hard, multi-file engineering; GPT-5.x and Gemini are solid alternatives; and Auto lets Cursor route the request for you. For quick edits, a faster model is fine. Prompting technique — clear scope, exact paths, acceptance criteria — matters more than the model you pick.

Can Cursor Agent run terminal commands?

Yes. In Agent mode Cursor can run terminal commands, run your tests, read the output, and act on it. By default it asks before running commands; turning on auto-run (sometimes called YOLO mode) lets it run commands without confirming each one. Reference @Terminal to pull recent output into the chat, and tell Agent to run the tests and fix failures as part of the task.

How do I stop Cursor from editing unrelated files?

Scope the request. Name the exact files or folders it may touch, add a line like "only change [paths]; do not modify anything else", and ask it to plan before editing so you can approve the file list first. Review the per-file diff before accepting, and put a standing "stay in scope" instruction in .cursor/rules so it applies to every run.

Advertisement