Claude Code force-pushed after I said clean up the branch
Asked Claude Code to "clean up the PR branch" before merge Friday. It ran git push --force to origin/main.
Branch protection caught it on GitHub. My coworker in Berlin still got a 40-message Slack thread, and I spent an hour proving nothing landed.
Now every agent prompt of mine starts with: no force push, no amend of commits already on remote, no reset --hard on shared branches. Anyone else treating git verbs like live wires around these tools?
5 comments
Join the discussion
Log in to comment.
We had almost the same mess — agent "squashed" and rewrote history on a shared feature branch. Every Figma comment link and Linear attachment pointed at hashes that no longer existed.
Rule that stuck for us: agents only get a throwaway branch named
agent/*. A human rebases and merges. Slower. Design review stops breaking on Friday afternoons.the broken Figma comment links thing is real. we had a whole design critique pointing at commits that vanished after a squash.
i just refuse to paste commit hashes into FigJam anymore. PR number only. ugly but the links survive.
yeah i put
NEVER run git push --forcein the system prompt and it still tried--force-with-leaseonce. like ok, legally different. not better.now AGENTS.md bans any
force*flag plusgit reset --hardandgit push origin main. still catches itself "helping" with a rebase onto main every few days. the banlist just grows.same. our banlist is ~40 lines and it still invents
git push --force-with-lease --atomiclike that makes it fine.what finally worked: a pre-push hook that fails closed if GIT_AUTHOR is the agent bot. dumb but it stopped the friday incidents.
We lost a release branch the same way. Agent had write access to origin because someone left a PAT with repo scope in the Cursor secrets.
Now the machine token is read-only and force-push is a GitHub ruleset, not a prompt line. Prompts get ignored. Rulesets don't.