claude-code - 💡(How to fix) Fix Feature Request: Documented opt-out for built-in default-branch push guard (CLI) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52001Fetched 2026-04-23 07:39:13
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Claude Code CLI contains an undocumented harness-level safety guard that blocks assistant-initiated git push to the default branch. The guard fires even when permissions.allow contains Bash(git push:*) and permissions.defaultMode is auto. There is no documented setting, CLI flag, or permissions mode that overrides it.

This is a sensible default for team repositories with branch protection and a PR review workflow. It adds disproportionate friction, however, in docs-only repositories, solo-owned personal projects, and spec / guideline repositories that are vendored downstream via git subtree. This issue requests a narrowly-scoped, documented opt-out — not a change in the default.

Root Cause

The progression is concerning because the previously-effective workaround (explicit allowlist) has silently stopped working with no documented replacement.

Fix Action

Fix / Workaround

The progression is concerning because the previously-effective workaround (explicit allowlist) has silently stopped working with no documented replacement.

Current workarounds (all unsatisfying)

RAW_BUFFERClick to expand / collapse

Summary

Claude Code CLI contains an undocumented harness-level safety guard that blocks assistant-initiated git push to the default branch. The guard fires even when permissions.allow contains Bash(git push:*) and permissions.defaultMode is auto. There is no documented setting, CLI flag, or permissions mode that overrides it.

This is a sensible default for team repositories with branch protection and a PR review workflow. It adds disproportionate friction, however, in docs-only repositories, solo-owned personal projects, and spec / guideline repositories that are vendored downstream via git subtree. This issue requests a narrowly-scoped, documented opt-out — not a change in the default.

What happens

Assistant-initiated call:

git push origin main

is refused with:

Permission for this action has been denied.
Reason: Pushing directly to the default branch (main) bypasses
pull request review.

The same command succeeds when the user runs it via the ! prefix in the TUI. The guard is therefore strictly client-side / harness-level; there is no server-side block.

Related prior report: #50624 confirms the same guard message exists and separately describes a bug where the command actually executes despite the denial envelope. This issue is orthogonal to that bug — here the denial and the block are consistent, but there is no way to opt out.

Timeline

  1. Earlier CLI versions: assistant-initiated git push origin main worked without intervention.
  2. A few versions ago: the guard appeared. Adding Bash(git push:*) to permissions.allow in settings.json restored autonomous pushing.
  3. Today (CLI 2.1.117): the permissions.allow entry is no longer honored for default-branch pushes. The guard fires unconditionally, even in defaultMode: auto with skipAutoPermissionPrompt: true.

The progression is concerning because the previously-effective workaround (explicit allowlist) has silently stopped working with no documented replacement.

Environment

  • Claude Code CLI: 2.1.117
  • OS: Linux
  • ~/.claude/settings.json:
    • permissions.defaultMode: auto
    • permissions.allow contains Bash(git push:*)
    • skipAutoPermissionPrompt: true
  • Project-level .claude/settings.json also contains Bash(git push:*)
  • No hooks configured

Docs check

Searched settings.md, cli-reference.md, how-claude-code-works.md, security.md, and permissions.md. The CLI-side default-branch push guard is not documented in any of them. Only claude-code-on-the-web.md mentions a branch-scoped push restriction, and it is described as specific to web / cloud agents.

Why it matters

The friction concentrates in a specific class of repositories where the harness guard actively works against the user's authorized workflow:

  • Docs-only repositories: cutting a feature branch, opening a PR, and merging just to push a typo or link fix is disproportionate. The "review" step is vestigial when the sole reviewer is the sole author.
  • Solo-owned projects: the user is the only committer, reviewer, and approver. A PR workflow adds multiple UI round-trips for no review value.
  • Guideline / spec repositories consumed via git subtree: updates are typically single-commit clarifications that downstream projects pull via subtree merge. PR overhead on the upstream slows propagation without a matching quality benefit.

In all three cases the user has already consciously accepted the risk of direct pushes: no branch protection configured, no CI gate required. Running in defaultMode: auto — which exists precisely to authorize autonomous execution — does not cover this case either.

Current workarounds (all unsatisfying)

  • Manually run ! git push origin main in the TUI every time — breaks autonomous flows and defeats defaultMode: auto.
  • Set up GitHub branch protection + PR workflow — solves a problem that docs-only / solo projects don't have.
  • --dangerously-skip-permissions — too broad; disables all permission prompts, not just this guard.

Proposal

A narrowly-scoped, opt-in override that restores the previously-working behavior:

  • Setting: permissions.allowDefaultBranchPush: true (project-level or user-level settings.json)
  • Default: false (preserves current safe default)
  • Scope: CLI only. Web / cloud agents can keep their existing restriction since it is already documented and context-appropriate.
  • Documentation: a short section in settings.md or security.md describing when the guard fires, why it exists, and how to opt out.

Alternative forms also acceptable:

  • A CLI flag, e.g. --allow-default-branch-push
  • A safety.* namespace key distinct from permissions.*, to make clear this is a safety guard and not a permission prompt
  • Restoring the previous behavior where permissions.allow with Bash(git push:*) suffices

Thanks!

extent analysis

TL;DR

The proposed fix is to introduce a narrowly-scoped, documented opt-out setting, such as permissions.allowDefaultBranchPush: true, to override the default branch push guard in the Claude Code CLI.

Guidance

  • The current issue arises from an undocumented harness-level safety guard that blocks assistant-initiated git push to the default branch, even with permissions.allow containing Bash(git push:*) and permissions.defaultMode set to auto.
  • To verify the issue, attempt an assistant-initiated git push origin main and observe the "Permission for this action has been denied" error message.
  • A potential workaround is to manually run ! git push origin main in the TUI, but this breaks autonomous flows and defeats defaultMode: auto.
  • The proposed solution involves introducing a new setting, such as permissions.allowDefaultBranchPush: true, to opt-out of the default branch push guard.

Example

No code snippet is provided as the issue is related to configuration settings rather than code.

Notes

The proposed solution aims to restore the previously working behavior where permissions.allow with Bash(git push:*) sufficed to allow default branch pushes. The introduction of a new setting or flag would provide a narrowly-scoped opt-out for users who require this functionality.

Recommendation

Apply the proposed workaround by introducing a new setting, such as permissions.allowDefaultBranchPush: true, to opt-out of the default branch push guard. This approach preserves the current safe default while providing a documented and configurable override for users who require it.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING