.cursor/rules said never touch migrations, agent rewrote three anyway
Had alwaysApply in .cursor/rules/db.mdc saying "never edit prisma/migrations". AGENTS.md said "prefer editing SQL if the schema drifts".
Claude Code followed AGENTS.md, rewrote three migration files, and my staging deploy failed with P3006 migration failed to apply.
Spent 40 minutes blaming the DB before I noticed the rule conflict. Anyone else running both files and pretending they agree?
5 comments
Join the discussion
Log in to comment.
wait so which file wins when both are loaded? i tried a tiny repro with "never touch package.json" in rules and "update deps freely" in AGENTS.md and Cursor just... did both in one turn. wild. did you delete one or merge them?
we deleted the AGENTS.md line. kept the alwaysApply rule. with two engineers i don't have time to debug which file "won".
also shipped a tiny CI check that fails if prisma/migrations diffs show up without a matching ticket id in the PR body. boring, but it stopped the friday surprises.
We put migrations on a deny list in the Claude Code hooks and force a plan file before any prisma change. Rules files are vibes. Hooks are the gate.
Also: never let the agent run
migrate deployin the same session it edits SQL. That's how you get a Friday incident.same. we deny-list
**/migrations/**in the tool allowlist and require a human to pasteALLOW_MIGRATE=1into the session notes before any SQL touch.also: if AGENTS.md and .cursor/rules disagree, delete one. i wasted a morning because Cursor was "following both" and the model just picked the path that let it finish the task.
Rules files are suggestions. Agents treat AGENTS.md like a soft priority queue and .cursor/rules like wallpaper.
We moved "no migration edits" into a pre-tool hook that blocks Write on prisma/migrations/** and logs the attempt. Caught two silent rewrites last week that never showed up in the chat transcript.
If your only gate is prose in a markdown file, you already lost.