AI replaces entire file instead of editing it

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

On 2026-06-15, a Cursor agent commit (4fd63eda, co-authored by Cursor) refactored api/Makefile from ~110 lines to ~31 lines. The commit message said it “streamlined” migration commands and “removed deprecated commands.”

The agent did not accidentally truncate the file — it fully replaced the Makefile with a new migration/tunnel-only version. All previously documented targets were removed:

Dev/CI: install, dev, build, lint, format, test
Local migrations: migration-run, migration-revert, migration-fresh
Dashboard: dashboard-verify, dashboard-smoke
Local Redis: redis-up, redis-down, redis-logs, redis-cli
Deploy workflow: deploy (commit to development, merge to production, push both)
Only the new SSH-tunnel migration targets remained: migrate-both, migrate-dev, migrate-prod, tunnel-*, help.

Expected behavior

When adding new Makefile targets (e.g. migrate-both via scripts/db-migrate-both.sh), the agent should:

Read the existing Makefile first
Append or merge new targets alongside existing ones
Not remove working targets unless explicitly asked
Not label existing dev/deploy/redis shortcuts as “deprecated” without user confirmation
Actual behavior

The agent replaced the whole file with a migration-only Makefile. Existing targets were removed in the same commit that introduced the new migration scripts. The change was bundled into a large multi-file commit (~62 files) with unrelated feature work, so the deletion was easy to miss in review.

Why this looks like a process bug

The commit message frames the deletion as intentional (“Removed deprecated commands”), but the user did not ask to remove make deploy, make dev, make redis-up, etc.
Those targets were thin wrappers over npm run … / git workflows — still valid and in use.
This reads as replace-without-merge: the agent optimized for the new migration workflow and overwrote the file instead of extending it.
No sign the agent checked whether other docs, rules, or workflows referenced the removed targets before deleting them.
Impact

make deploy, make redis-up, make dev, etc. stopped working for anyone using the Makefile as documented since April 2026.
Users had to use raw npm run … commands or git promote scripts instead.
Fix required manually restoring pre-4fd63eda content and merging with the new migration targets.
Suggested fix for Cursor

When editing Makefile/package scripts/config files that aggregate shortcuts:

Default to additive changes unless the user explicitly asks to remove targets
Warn before deleting any existing target
Do not infer “deprecated” from the presence of a newer alternative path
For “streamline/refactor” requests, show a diff of removed vs added targets and ask for confirmation before replacing the whole file
Repro pattern (general)

Repo has an existing Makefile with multiple target groups (dev, deploy, infra helpers).
User or agent adds a new script/workflow and asks to wire it into the Makefile.
Agent replaces the entire Makefile with only the new targets.
Pre-existing targets disappear; commit message may describe removal as intentional cleanup.

Steps to Reproduce

sometimes it just happens. it has happened other occasions. the agent will either not read the file before replacing it, or it will not understand the context correctly and replace the file which removes functionality

Expected Behavior

the agent should have just added the additional commands to the file instead of replacing it with only the new commands

Operating System

Linux

Version Information

see previous post

For AI issues: which model did you use?

opus 4.8 or composer 2.5

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hi @HEMgreen Thanks for the post. Sounds like this could be an agent quality issue. If you’d like us to take a closer look, could you please disable privacy mode temporarily, re-create the scenario, and send us the request ID of the request? Thx!

To disable Privacy Mode:

  1. Open Cursor Settings with Cmd+Shift+J on macOS or Ctrl+Shift+J on Windows/Linux.
  2. Go to General.
  3. Turn Privacy Mode off / switch to Share Data.

To get the Request ID:

  1. Open the relevant conversation in the Chat sidebar.
  2. Click the ... menu.
  3. Select Copy Request ID.

no thanks. to encourage people to report bugs yall should not be creating friction for the user