published fresh until

Cursor: Refactor across files and preserve the public API

Summary Keep a cross-file refactor reviewable by mapping callers, recording the public contract in the plan, and reviewing the whole branch before accepting it. This case targets Cursor IDE 3.27. Start in Plan Mode

Not for Claude Code repository instructions; see case-write-project-rules-file-agent-follows-claude-md-agents-md-cursor-hooks Cursor downstream caller breaks public API compatibility wrapper .cursorignore alwaysApply refactor.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: enter Cursor Plan Mode with Shift+Tab and record the old public entry points, callers and validation commands before building the refactor.

Short answer

As of November 2026, this workflow targets Cursor IDE 3.27. Keep old consumer fixtures and serialized success/error contracts as acceptance checks. Rule activation and a passing internal build do not establish downstream compatibility.

Choose / don't choose

  • Always-applied compatibility rule: choose when implementation, declarations, callers and tests span several directories; don't depend on a narrow file glob matching every consumer.
  • Compatibility wrapper/re-export: choose when external or independently released consumers cannot migrate now; preserve old argument/default/error behavior while delegating internally. Don't remove the old entry point merely because in-repository callers moved.
  • Direct caller migration: choose only for consumers under one controlled release boundary; don't apply it to unknown downstream clients. This wrapper decision is project policy applied to Cursor's scope/consequence guidance.

Not for: Claude Code repository instructions; see case-write-project-rules-file-agent-follows-claude-md-agents-md-cursor-hooks

Settings that matter

Setting or flagValue / defaultApplies toSource
.cursor/rules/*.mdc, alwaysApplytrue includes the compatibility rule in every chat; description and globs then do not restrict itCurrent Cursor rulesactivation
alwaysApply, globsfalse plus comma-separated patterns auto-attaches for matching files; include implementations, declarations, callers and testsCurrent Cursor rulespatterns
alwaysApply, @compatibilityfalse with omitted description and globs is included only when @-mentioned; explicitly mention the compatibility rule in each relevant chatCurrent Cursor rulesmanual activation
.cursorignoreRoot file uses gitignore patterns; omit generated/private content while retaining public declarations and callersCurrent Cursor ignore docsignore
Hierarchical Cursor IgnoreEnable in Cursor Settings → Indexing → Ignore Files when parent ignore files must applyCurrent Cursor ignore docsparent scope
@BranchInclude the full current-branch diff for final reviewCurrent Cursor review docsreview

Order of operations

1. Identify the IDE under About Cursor (version display). In Plan, map declarations, import paths, overloads/defaults and all visible callers. Save the plan to the workspace, review it, then Build (planning). 2. Record serialized field names, null/omission behavior, errors and side effects as well as types. Keep an unchanged old-consumer fixture for each public boundary; an external caller cannot be inferred from repository search alone. 3. Activate the compatibility rule. Include the constraints directly in its body: a file mention tells Agent where to look; file contents are not inlined into the prompt. Inspect Customize → Rules status (rules). 4. Review ignore patterns before choosing context. Include declarations and representative callers explicitly; if a parent directory is ignored, a child negation may not re-include the file. .cursorignore does not restrict terminal or MCP tools, so enforce private-file access separately (ignore semantics). 5. Extract internals behind stable entry points, then migrate internal callers. Run recorded build/type/contract commands and old-consumer success/error/serialization fixtures. Review @Branch against the saved contract. If drift is broad, use Revert and refine the plan (review, recovery).

Known failures and fixes

Error or symptomCauseFixSource
Public signature changes despite a correct plan (symptom)Planning does not automatically lock implementation constraintsActivate explicit compatibility instructions and require old-consumer checks; keep wrapper if consumers cannot migrateYu Ishikawa, November 4, 2025, report
Local build passes, downstream caller breaks (symptom)Compare old imports/signatures and serialized errors; inspect ignore scope; restore compatible boundary and exercise unchanged fixturescope guidance, review

Jai Smith's October 7, 2025 introduction explains research and editable plans.

Missing

  • The linked source does not confirm: Yu Ishikawa's request is not a shipped automatic API-lock feature.
  • No Cursor setting proves binary/wire/API compatibility. Unknown external consumers and undocumented behavior require their own release policy and contract fixtures.
  • No .cursorindexingignore behavior is established by the current ignore reference; this recipe uses only documented .cursorignore controls.

Checked

2026-11-12; IDE release reference, rules/ignore/plan/review/modernization references, version/recovery help, Jai Smith introduction and Yu Ishikawa report read. No Cursor refactor or compatibility commands executed.

Started from a post by @Jai Smith, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cursor: Refactor across files and preserve the public API
Summary: Keep a cross-file refactor reviewable by mapping callers, recording the public contract in the plan, and reviewing the whole branch before accepting it. This case targets Cursor IDE 3.27. Start in `Plan Mode`
Copy for agent
get the whatworks thread cursor-cross-file-refactor-preserve-public-contract and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread cursor-cross-file-refactor-preserve-public-contract
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks