Cursor

Verified against Cursor · 2026-08-11

Give Cursor's Agent mode a security invariant list before it touches an authentication flow

A brief for modifying or extending an authentication or session flow that states non-negotiable security invariants up front and requires the agent to check its own diff against each one before finishing, so a working feature doesn't ship with a quietly weakened security check.

Cursor 2.25 fillable variables

The prompt

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

AUTH CHANGE
Add refresh-token rotation: each refresh issues a new refresh token and invalidates the one used, instead of reusing the same refresh token indefinitely.

CURRENT FLOW
Access tokens expire after 15 minutes; refresh tokens are long-lived (30 days) and currently reusable without rotation.

SECURITY INVARIANTS — none of these may change as a side effect of this work, even temporarily during development
An expired access token is always rejected, no exceptions for internal service calls. A revoked refresh token can never mint a new access token, even once. No endpoint issues a token without passing through the shared verifyCredentials() path.

TOKEN / SESSION HANDLING RULES
Refresh tokens are compared using a constant-time hash comparison, never a plain string equality check, and are never stored in plaintext in the database.

AFFECTED CLIENTS / SERVICES RELYING ON CURRENT TOKENS
The mobile app caches a refresh token client-side for up to 30 days; roughly 40,000 active refresh tokens exist under the current non-rotating scheme at any time.

Implement the change above. While doing it:
- Never log a raw token, password, or secret value, even at debug level and even temporarily to check something — log an identifier or a boolean instead.
- Never weaken an existing check (an expiry, a signature verification, a scope check) to make a test pass or unblock local development with a plan to "tighten it back up later" — if a check is genuinely in the way of the change, say so explicitly and ask, don't route around it.
- Do not add a new code path that can produce a valid session or token without going through the same verification the existing paths use, even for a supposedly low-risk case like a test harness or an internal admin tool — that becomes the eventual weakest link.
- If the change touches token expiry, refresh, or revocation, state explicitly what happens to a token that's mid-flight — issued before the change, used after it ships — since a change that silently orphans or silently keeps trusting an old-format token is a real gap even when new tokens are handled correctly.

BEFORE FINISHING
Go through SECURITY INVARIANTS one at a time and state, for each, whether it still holds after your change and how you'd verify that — not just an assertion that it does. If any invariant is genuinely in tension with the requested change, stop and name the conflict rather than silently deciding which one wins.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

A model implementing an auth change optimizes for the functional signal it's actually given — the feature works, the test suite passes — and a security check that was never named as an invariant is invisible to that optimization, which is exactly how a check gets loosened during development to unblock a local test and never gets tightened back, since nothing in "make refresh rotation work" flags that as a regression on its own. Stating security invariants as literal checkable facts, and requiring the model to walk through each one individually before finishing rather than give a single overall "looks secure" impression, forces an audit against a fixed list instead of a vibe check, which is the only format that reliably catches a narrow regression buried inside an otherwise-working diff. The explicit ban on logging raw secrets targets one of the most common and most easily forgotten transient habits in agent-assisted debugging: adding a console.log of a token to check why a comparison is failing is a completely reasonable debugging instinct, and it is also exactly the kind of line that survives into a shipped diff because nothing about "the feature now works" prompts its removal. The rule against a new bypass path for internal tooling addresses the single most common way a real backdoor actually ships — not through malice, but through a supposedly low-risk shortcut for a test harness or an admin script that's added with good intentions, works fine, and is never revisited once the real feature is done, quietly becoming the weakest link in the whole system. Naming mid-flight token behavior explicitly matters because an auth change is deployed against a live population of already-issued tokens, not a fresh empty database, and a quick local test only ever exercises newly issued tokens — the failure mode of a change that silently keeps trusting or silently orphans an old-format token in production is invisible to any test that doesn't specifically construct that scenario.

What you get back

Invariant check: - Expired access token always rejected: holds — no change to the access-token verification path, confirmed by re-reading verifyAccessToken(), untouched by this diff. - Revoked refresh token can never mint a new access token: holds, and now stronger — rotation means a used refresh token is marked revoked and refresh_used_check now runs before every mint, verified by a new test that reuses an already-rotated token and expects a 401. - All tokens pass through verifyCredentials(): holds — no new issuance path added.

Mid-flight tokens: refresh tokens issued before this deploy have no rotation record yet; first refresh attempt on one of these is treated as a first use and rotated normally rather than rejected, so the ~40,000 existing tokens keep working without requiring a forced re-login.

Verified against

Cursor 2.2 · 2026-08-11

Changelog

  • 2026-08-11 — Initial publish, verified against Cursor 2.2 Agent mode on a refresh-token rotation change.

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
Brief Cursor's Agent mode to build a multi-file feature without wandering into untouched filesA Composer/Agent-mode brief that names the files in scope, the data contract between them, the codebase's existing conventions, and what to leave alone, plus a forced pre-edit plan, so an autonomous multi-file build stays inside the feature you actually asked for instead of expanding into whatever the semantic index surfaces as related.Cursor 2.22026-08-05Force Cmd+K to change only the highlighted lines, not the whole block around themA Cmd+K inline-edit instruction that states the transformation, an explicit byte-identical preserve list, and a fallback rule for when the transformation can't be done cleanly, tuned for the selection-scoped inline editor rather than a whole-file Agent pass.Cursor 2.22026-07-22Point Cursor BugBot at the actual risk in a PR instead of a generic pass over the diffA PR description written for BugBot, Cursor's automated PR-review agent, that states risk areas and known trade-offs up front and defines exactly how findings must be classified and cited, so its comment thread concentrates on real logic and security risk instead of restating the diff or re-litigating a deliberate choice.Cursor BugBotCursor 2.22026-07-30Write a Background Agent brief that survives running with nobody watchingA self-contained task brief for Cursor's Background Agents — the async, remote-run agent mode — with success criteria, a conservative-default policy for ambiguity, and a reviewable-PR requirement, since no one answers follow-up questions while it works in an isolated container.Cursor Background AgentsCursor 2.22026-08-02
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