Created and pushed branches without asking
不打招呼就建分支并推送
The agent creates branches and pushes them to the shared remote on its own, so work-in-progress shows up for the team (and triggers CI and bots) before you decided to share it.
Applies to: Claude Code · Cursor · Codex · Copilot agent
Symptom
Branches you don't recognise appear on GitHub, often with CI runs and review-bot comments attached. Your local session shows a `git push` you never asked for.
Why it happens
Replying to "Why are you still using pull requests?", @rakesh_at_tweet answered: "because my agent creates and pushes new branches without asking me". Pushing is externally visible and hard to take back, but to an agent finishing a task it looks like the natural last step.
Example
Illustrative.
textYou: fix the date parsing bug
Agent: $ git checkout -b fix/date-parsing
$ git commit -am "Fix date parsing"
$ git push -u origin fix/date-parsing <- nobody asked for this
Copy-paste fixes
Pick the files for the agents you use. Snippets are in English so they work in any repo.
Claude Code: add to CLAUDE.md
CLAUDE.md## Don't push unless asked
- Never run `git push`, create remote branches, or open PRs unless the user asked for that in this
session. Commit locally and say the branch is ready to push.
- Creating a local branch is fine; tell the user its name.
- Anything that other people or systems will see (remote branches, PRs, comments, releases)
needs explicit permission each time.
Codex, Copilot coding agent and others: add to AGENTS.md
AGENTS.md## Don't push unless asked
- Never run `git push`, create remote branches, or open PRs unless the user asked for that in this
session. Commit locally and say the branch is ready to push.
- Creating a local branch is fine; tell the user its name.
- Anything that other people or systems will see (remote branches, PRs, comments, releases)
needs explicit permission each time.
Cursor: project rule
.cursor/rules/pushed-without-asking.mdc---
description: "AgentFails: Created and pushed branches without asking"
alwaysApply: true
---
## Don't push unless asked
- Never run `git push`, create remote branches, or open PRs unless the user asked for that in this
session. Commit locally and say the branch is ready to push.
- Creating a local branch is fine; tell the user its name.
- Anything that other people or systems will see (remote branches, PRs, comments, releases)
needs explicit permission each time.
Claude Code permissions: hard-deny sensitive paths, ask before installs
Rules in CLAUDE.md are context; permission rules are enforced by the tool. Adjust the paths to your repo.
.claude/settings.json{
"permissions": {
"deny": [
"Edit(./migrations/**)",
"Edit(./.env*)",
"Edit(./package-lock.json)",
"Edit(./pnpm-lock.yaml)",
"Edit(./src/generated/**)"
],
"ask": [
"Bash(npm install:*)",
"Bash(pnpm add:*)",
"Bash(yarn add:*)",
"Bash(pip install:*)",
"Bash(git push:*)"
]
}
}