Background-session git rule "Never push to main/master, force-push, or merge" has no precedence clause, so agents refuse merges their repo CLAUDE.md explicitly requires
What happens
Background sessions (CLAUDE_CODE_SESSION_KIND=bg) get this sentence in the # Background Session system prompt:
Never push to main/master, force-push, or merge.
In 2.1.235 it's a hardcoded constant with one use site, in the git paragraph of that block, emitted whenever session kind is bg and CLAUDE_JOB_DIR is set.
The surrounding paragraph has an escape clause, but it only tightens:
This holds unless the user's instructions, in the task, CLAUDE.md, or memory, reserve git for them.
Nothing covers the other direction. So when a repo's CLAUDE.md explicitly tells the agent to merge its own green PRs, the agent has to decide unaided whether that outranks a flat imperative in its system prompt. It goes both ways from session to session, which is worse than either consistent behavior.
Two things make it worse
1. --dangerously-skip-permissions has no effect on it. I launch every session with that flag. The block is gated solely on CLAUDE_CODE_SESSION_KIND and CLAUDE_JOB_DIR: there is no permission-mode condition anywhere in it. So a user who has explicitly opted out of every permission prompt still gets an agent refusing a merge on safety grounds. If bypass mode means anything, it should reach this.
2. The refusals get misattributed to the user. Actual quotes from my sessions:
- "I can't merge to main from this session: that's a hard restriction on background jobs here, not a judgment call I'm making about your change."
- "My instructions here bar me from merging or pushing to main, and your CLAUDE.md says the same." (It said the opposite.)
That sent me hunting for the rule in my own config, where it doesn't exist. It's only findable by grepping the binary. Seven sessions in six days refused a green, conflict-free PR the repo CLAUDE.md told them to merge.
The same gap misfires in reverse in #69156 and #48474: agents merging or pushing despite a CLAUDE.md forbidding it. One missing precedence statement, both bug classes.
Expected
State the precedence in the prompt, mirroring the clause that already exists for the tightening case: "...unless the repository's own CLAUDE.md sanctions merging, in which case follow the repo." Either precedence is fine, but saying it explicitly costs one clause and fixes both directions.
Existing settings don't cover it
worktree.bgIsolation: "none"removes the sentence only as a side effect of dropping the whole git paragraph, and disables background worktree isolation with it. Unusable if you want isolation and merges.includeGitInstructions: falsegates a different function, not this block.- The related closed issues (#58433, #58435, #59580, #62372) are all about the bgIsolation Edit/Write gate, not this sentence.
Environment
Claude Code 2.1.235 (also in 2.1.233, 2.1.234), macOS (Darwin 25.4.0, arm64), Opus 5, launched with --dangerously-skip-permissions.