Cursor

Verified against Cursor · 2026-08-01

Refactor with Cursor checkpoints as a named safety net, not a fallback nobody uses

A refactor brief that breaks the change into checkpoint-sized steps and tells Cursor's agent to stop and name the last good checkpoint on failure, instead of patching a bad step with a second speculative fix.

Cursor 2.1

The prompt

Ready to copy — highlighted parts are example details you can swap.

REFACTOR GOAL
Replace the three separate date-formatting utilities with one shared formatDate function, no behavior change anywhere it is used.

Break this into the smallest steps that each leave the codebase working and checkpointable. Treat each of these as a checkpoint boundary — after completing each one, pause and tell me it's safe to checkpoint before continuing to the next:
1. Write the unified formatDate covering all existing format strings. 2. Swap callers in src/reports/ first (lowest traffic). 3. Swap callers in src/dashboard/ (highest traffic, do last).

If a step fails, do not patch around it with a second speculative change on top. Stop, name the last good checkpoint, and describe exactly what went wrong — then wait.

ROLLBACK SIGNAL
If I say "roll it back", treat that as an instruction to stop immediately and tell me exactly what to roll back to the last checkpoint — not to keep going and fix forward.
Customize the highlighted detailsoptional — the prompt above already works

Why this works

Cursor's agent mode checkpoints the workspace after each turn, so you can roll back to before a specific edit without discarding the whole session — but that safety net is only as useful as the granularity of the steps between checkpoints and how quickly you catch a bad one. Breaking the refactor into named risky_steps gives you several small checkpoint boundaries to roll back to instead of one large diff where checkpoint granularity is useless because the whole thing landed in one turn. The instruction to stop and name the last good checkpoint on failure, rather than patch around it, targets a specific documented agent tendency: once an edit doesn't work, the model's next move is usually a second corrective change layered on top rather than a clean rollback, and every layer on top makes the eventual rollback point harder to identify and the diff harder to review. Naming a literal ROLLBACK SIGNAL phrase also matters — it gives you a one-word interrupt that unambiguously means stop and undo, distinct from any other correction you might type mid-session that the agent could otherwise read as 'keep going, differently.'

What you get back

Step 1 complete: unified formatDate written in src/lib/date.ts, covers all 4 format strings found in the codebase. Safe to checkpoint here. Step 2 complete: swapped 3 callers in src/reports/. Tests pass. Safe to checkpoint here. Step 3: swapping callers in src/dashboard/ — hit a failure. DashboardHeader.tsx passed a Date object where the other callers passed an ISO string; formatDate assumed string input and threw. Stopping here rather than patching formatDate to accept both types silently. Last good checkpoint: end of Step 2. Waiting for direction — options are (a) normalize the caller to pass a string, or (b) widen formatDate's input type deliberately.

Verified against

Cursor 2.1 · 2026-08-01

Changelog

  • 2026-08-01 Initial publish, verified against Cursor 2.1's agent-mode checkpoint/rollback behavior.

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All Cursor prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY