Cursor Composer Made Sweeping Wrong Edits

Composer rewrote 10+ files and broke working code — prompt was too open and the agent had too much default scope.

You typed “clean up this section” or “make the style consistent” into Composer. git status now shows 14 files changed, 500+ lines moved, naming conventions rewritten, three tests broken. The model wasn’t being greedy — Composer defaults to treating any ambiguous instruction as “do what you think is right,” and agent mode pushes that harder.

Stopping the bleed is git checkout. Stopping the next over-edit is fixing the boundaries you hand Composer.

Common causes

1. Unbounded verbs in the prompt

“Clean up,” “refactor,” “improve,” “polish,” “modernize” — no implicit limit. The model treats them as “do everything you’d consider good,” so renames, extractions, reordered params and added comments all happen at once.

How to judge: lift the first verb in your prompt. “Clean up” is unbounded; “rename foo to bar” is not.

2. Agent mode has multi-file + shell power by default

In Agent mode Composer can chain read_file → grep → edit_file across the whole repo. You asked one thing; it “also fixed” eight more it considered related.

How to judge: Composer’s mode dropdown shows “Agent”; one reply expanded into a dozen tool calls.

3. No “do not touch” list

The model doesn’t know which files are sacred. migrations/, generated/, vendor/, schema.prisma, vendored SDK wrappers — all high-risk and silently edited if you don’t say “off limits.”

How to judge: git diff --stat and look for changes in directories you’d never have asked it to touch.

4. No commit between multiple prompts

Prompt → edits → unhappy → next prompt → more edits. After three rounds the diffs are tangled and you can’t separate what came from where.

How to judge: git log --oneline — if the last commit is from this morning or days ago, you’re in tangled territory.

5. Wrong model picked for the task

opus / gpt-5 in agent mode lean toward sweeping rewrites; sonnet / haiku stay closer to surgical patches. Using a big model for a surgical task tends to over-edit.

How to judge: look at the model name bottom-right; opus on a surgical task is a mismatch.

6. .cursorrules doesn’t enforce “minimal diff”

Without rules the model defaults to “good-engineer style” learned in training — which includes refactoring code it considers ugly. You must say “don’t refactor unless asked.”

How to judge: cat .cursorrules at repo root. No “minimal edits” / “don’t refactor” clause means you need one.

Before you start

  • Identify which entry point misbehaved: Composer / Cmd+K / chat. Cmd+K is local, Composer is global; very different behavior.
  • The moment you see misedits, stop prompting. git diff > /tmp/diff.patch first; then decide whether to revert.
  • Note Cursor version and active model. The same prompt on a different model often behaves very differently.

Info to collect

  • The exact prompt that triggered the misedit.
  • git diff --stat showing which files changed by how many lines.
  • Current model + mode (Ask / Edit / Agent) + whether Max mode is on.
  • Contents of .cursorrules; whether .cursorignore exists.

Shortest fix path

In “stop bleeding first, fix workflow second” order.

Step 1: Triage and preserve evidence

git diff > /tmp/composer-misedit.patch   # keep the patch as evidence
git stash                                # set it aside, don't drop
# Or revert outright:
git checkout HEAD -- .                   # discards all uncommitted changes

Step 2: Cherry-pick what to keep

If 5 of 14 files are worth keeping:

git stash pop                            # bring the patch back
# Use Cursor source control panel to discard per-file
# Or via CLI:
git checkout HEAD -- path/to/unwanted-file

Or git add -p for interactive hunk staging.

Step 3: Rewrite the prompt with explicit scope

Swap unbounded verbs for surgical ones:

Before: refactor the auth module
After:  In src/auth/login.ts only:
        1. Replace the magic string "DEFAULT_TIMEOUT" with the constant from config.
        2. Do NOT change function signatures.
        3. Do NOT touch any other file.
        4. Do NOT add or remove comments.
        Output a unified diff, ≤ 30 lines.

Step 4: Drop to Edit mode or Cmd+K

Composer input → mode dropdown → “Edit” instead of “Agent.” Edit mode only modifies files you @ and won’t iterate across the repo.

For surgical work, use Cmd+K (select the lines first, then trigger) — power is limited to the selection.

Step 5: Bake “stay conservative” into .cursorrules

# .cursorrules
- Make the minimum change required to satisfy the prompt.
- Do NOT refactor, rename, or reformat code that is not explicitly mentioned.
- Do NOT touch files in: migrations/, generated/, vendor/, schema.prisma.
- If the task seems to require changes outside the listed files, STOP and ask first.
- Preserve existing comments and import order unless asked to change them.

Step 6: Commit before dangerous tasks

Make git commit -m "wip: before composer" a habit before any big Composer task. Reverting then costs seconds.

How to verify the fix

  • Rerun the same prompt; confirm changes stay inside @ed files.
  • Have a teammate open the same workspace and run the same prompt — should match.
  • Run tests + lint to confirm no style or behavior drift slipped through.

If it still fails

  • Reduce the prompt to its smallest: single verb + single file + single target line.
  • Roll back the most recent .cursorrules change and confirm which rule wasn’t taking effect.
  • Search forum.cursor.com for “composer over-edits”; include version + model + prompt + diff.
  • Grab View → Output → Cursor logs and post to Bug Reports.

Prevention

  • Commit before every Composer session so you start clean.
  • Standardize a prompt template with a “Constraints” section: allowed files / forbidden files / max diff lines.
  • Default to Edit mode or Cmd+K; only flip to Agent when you genuinely need multi-step work.
  • Lock in .cursorrules “minimum diff” and a sacred-paths list.
  • Drop loud comments in critical files: // DO NOT MODIFY without ticket #1234 — models usually skip them.

Tags: #Troubleshooting #Cursor #Debug #Wrong edit