Verified against Cursor · 2026-08-06
Turn Cursor's Agent-mode checkpoints into a real rollback plan for a risky refactor
A refactor brief that breaks a risky change into checkpoint-sized steps and tells the agent to stop and name the last good checkpoint on failure — instead of patching a bad step with a second speculative fix — plus a named rollback trigger phrase for mid-session use.
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 independently checkpointable. Treat each of the following as a checkpoint boundary — after completing each one, pause, report what changed and what you verified, and wait for acknowledgment 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). VERIFICATION AT EACH CHECKPOINT Run the existing date-formatting test suite (npm test -- date) and manually diff three sample outputs against the old function for each swapped caller. If a step fails verification, do not patch around it with a second speculative change layered on top. Stop, name the last good checkpoint by its step number, describe exactly what went wrong and what you observed, and wait — do not attempt a fix-forward on your own initiative once a step has already failed once. ROLLBACK SIGNAL If I say "roll it back" at any point, treat it as an unambiguous instruction to stop immediately, tell me exactly what to roll back to relative to the last acknowledged checkpoint, and take no further action until told otherwise. Do not interpret it as feedback to fix forward, and do not treat any other phrasing as equivalent to it, even something that sounds similar — this exact phrase is the only trigger. BUDGET No more than 6 checkpoint steps total — if the dashboard callers alone need more than 2 steps, stop and report before splitting further. If you're about to exceed the step budget before reaching the refactor goal, stop at the next checkpoint and report that explicitly rather than continuing past it assuming it doesn't matter.
Customize
Optional — swap in your own details for the highlighted parts above.
Why this works
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 a bad one gets caught. Breaking the refactor into named RISKY_STEPS gives you several small checkpoint boundaries to actually roll back to instead of one large diff where checkpoint granularity is worthless because the whole change landed in a single turn — a checkpoint before and after one 40-file diff isn't a safety net, it's a coin flip. The instruction to stop and name the last good checkpoint on failure, rather than patch around it, targets a specific and well-documented agent tendency: once an edit doesn't work, the model's default next move is a second corrective change layered on top of the first rather than a clean rollback, and every layer on top makes the eventual rollback point harder to identify and the accumulated diff harder to review as a single decision. VERIFICATION_METHOD matters because "safe to checkpoint" is meaningless without a stated bar for what counts as verified — without it, the agent's own confidence that a step worked is the only signal, and that confidence is exactly what's unreliable enough to need a checkpoint system in the first place. Naming a literal ROLLBACK_SIGNAL phrase gives you a one-word interrupt that unambiguously means stop and undo, distinct from any other correction you might type mid-session — a plain "that's not right" is genuinely ambiguous between "fix it" and "undo it," and an agent mid-edit will default to the interpretation that lets it keep working rather than the one that stops it.
What you get back
Step 1 complete: unified formatDate written in src/lib/date.ts, covers all 4 format strings found. Verification: npm test -- date passes (12/12). Safe to checkpoint here — waiting for acknowledgment. Step 2 complete: swapped 3 callers in src/reports/. Verification: same test suite passes; manually diffed sample outputs for all 3 callers against the old function, identical. Safe to checkpoint here. Step 3: swapping callers in src/dashboard/ — verification failed. 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 silently accept both types. Last good checkpoint: end of Step 2. Waiting for direction.
Verified against
Cursor 2.2 · 2026-08-06
Changelog
- 2026-08-06 — Initial publish, verified against Cursor 2.2'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
