claude-code - 💡(How to fix) Fix Push-to-main rail in auto mode: wildcard allow rules don't override; only exact-match works [2 comments, 3 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#54079Fetched 2026-04-28 06:39:46
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

In auto mode, attempting git push origin main is denied by a built-in safety rail with the message:

Pushing directly to the default branch (main) bypasses pull request review. ...the user can add a Bash permission rule to their settings to allow this in the future.

I had Bash(git push:*) in ~/.claude/settings.json allow list. The wildcard rule was ignored by the rail. Only adding the exact string Bash(git push origin main) to the allow list overrode the rail and let the push proceed.

Error Message

  1. Misleading error message. It implies any push allow rule will work, but only an exact-match rule does. The message should say so explicitly, or the rail should respect wildcard allow rules the user has explicitly set (the user has already opted into pushing on this CLI by allowlisting git push:*).

Root Cause

In auto mode, attempting git push origin main is denied by a built-in safety rail with the message:

Pushing directly to the default branch (main) bypasses pull request review. ...the user can add a Bash permission rule to their settings to allow this in the future.

I had Bash(git push:*) in ~/.claude/settings.json allow list. The wildcard rule was ignored by the rail. Only adding the exact string Bash(git push origin main) to the allow list overrode the rail and let the push proceed.

RAW_BUFFERClick to expand / collapse

Summary

In auto mode, attempting git push origin main is denied by a built-in safety rail with the message:

Pushing directly to the default branch (main) bypasses pull request review. ...the user can add a Bash permission rule to their settings to allow this in the future.

I had Bash(git push:*) in ~/.claude/settings.json allow list. The wildcard rule was ignored by the rail. Only adding the exact string Bash(git push origin main) to the allow list overrode the rail and let the push proceed.

Friction points

  1. Misleading error message. It implies any push allow rule will work, but only an exact-match rule does. The message should say so explicitly, or the rail should respect wildcard allow rules the user has explicitly set (the user has already opted into pushing on this CLI by allowlisting git push:*).

  2. No "approve once" affordance in auto mode. With skipAutoPermissionPrompt: true plus auto mode enabled, the rail auto-denies rather than prompting. The only paths forward are: toggle auto mode off, do the push, toggle it back on; or add the exact-match allow rule. For solo / personal repos where pushing directly to main is the normal workflow, neither is great. An option to surface the prompt even in auto mode for this specific rail would help.

Suggested fixes (any one helps)

  • Update the rail's denial message to specifically call out exact-match-only behavior.
  • Have the rail honor wildcard Bash(git push:*) allow rules.
  • Surface a "approve this push once" prompt even in auto mode for the push-to-main rail (since it's a single discrete action, not a class of repeatable risky operations).

Environment

  • Claude Code: 2.1.119
  • macOS: 26.3.1 (build 25D771280a)
  • Repo context: personal solo repo on GitHub, no branch protection on main, all prior commits on the branch were direct pushes to main (auto-sync workflow).

extent analysis

TL;DR

To resolve the issue, update the allow list in ~/.claude/settings.json to include the exact string Bash(git push origin main) or modify the rail's behavior to respect wildcard allow rules.

Guidance

  • Verify that the Bash(git push:*) wildcard rule is correctly formatted and located in the ~/.claude/settings.json file.
  • Consider adding the exact string Bash(git push origin main) to the allow list as a temporary workaround.
  • To improve the user experience, the rail's denial message could be updated to explicitly state that only exact-match rules are respected.
  • The rail's behavior could be modified to honor wildcard allow rules, such as Bash(git push:*), to provide more flexibility.

Example

No code snippet is provided as it is not necessary for this issue.

Notes

The issue is specific to the Claude Code version 2.1.119 and the described environment. The suggested fixes may not apply to other versions or environments.

Recommendation

Apply the workaround by adding the exact string Bash(git push origin main) to the allow list, as this provides a immediate solution to the issue.

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

claude-code - 💡(How to fix) Fix Push-to-main rail in auto mode: wildcard allow rules don't override; only exact-match works [2 comments, 3 participants]