Skip to content

Block Claude Code from merging pull requests - #8

Merged
JakeSCahill merged 1 commit into
mainfrom
jake/deny-claude-merges
Oct 24, 2026
Merged

JakeSCahill merged 1 commit into
mainfrom
jake/deny-claude-merges

Conversation

@JakeSCahill

Copy link
Copy Markdown
Contributor

Adds a shared .claude/settings.json that stops Claude Code from merging pull requests in this repo. It blocks gh pr merge, merges through gh api (REST and GraphQL, including auto-merge), and the GitHub MCP merge tool.

Deny rules hold in every permission mode, including bypass. They apply to every PR, your own included, so merging is always done by hand. Reviews, comments, approvals, pushes and opening PRs are not affected.

Tested with a stubbed gh in bypass and auto mode: every merge route was refused and the read-only calls still ran. Without the file, every command ran.

@JakeSCahill
JakeSCahill requested a review from a team as a code owner October 14, 2026 10:54

@Feediver1 Feediver1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review: Block Claude Code from merging pull requests (#8)

Overall assessment: Approvable. .claude/settings.json is valid JSON, and its five deny rules match the first five rules of the docs team's standard merge-guard list (docs-team-standards, commands/setup.md, "Merge guard setup", from docs-team-standards#2975).

What the rules cover

  • Bash(gh pr merge:*): gh pr merge with any arguments.
  • Bash(gh api *pulls/*/merge*): REST merges such as gh api repos/<owner>/<repo>/pulls/8/merge -X PUT, including when flags come before the path.
  • Bash(gh api graphql *mergePullRequest*) and *enablePullRequestAutoMerge*: GraphQL merge and auto-merge mutations passed inline with -f query=....
  • mcp__github__merge_pull_request: the merge tool of an MCP server registered as github.

Critical issues (must fix)

None.

Suggestions

  1. The team list's close rules are missing. The standard list in setup.md also denies Bash(gh issue close:*) and Bash(gh pr close:*). That's fine if this PR is deliberately about merges only. But every repo created from this template would start out with a narrower guard than the team standard. Consider adding both rules, or saying in the PR why they're left out.
  2. A session started above the repo loads none of these rules. Claude Code reads a project's .claude/settings.json only when a session starts in that repo's root. A session started in a parent folder (for example ~/projects) loads none of it. setup.md already says so and asks each writer to add the same rules to ~/.claude/settings.json. This is the template other repos copy, so a line in its README pointing to that user-level setup would close the gap for new repos.
  3. The MCP rule covers one server name. mcp__github__merge_pull_request matches only an MCP server registered as github. A GitHub MCP server added under another name isn't blocked. That's fine for today's setup, where the only GitHub connector is read-only, but worth noting next to the rule.
  4. Known limits. These are already documented in setup.md. Text-matching rules can be worked around by a wrapped command (bash -c, a script, xargs) or by a GraphQL --input file, and they don't stop a direct git push to main. Branch protection is the guard for that.

What works well

  • Deny rules hold in every permission mode, including bypass and auto. That's the right mechanism after the hook-based guard proved unreliable in auto mode (docs-team-standards#2975).
  • The rules are identical to the team's standard list, so the template and writers' user-level settings can't drift apart on merges.
  • The PR body records a test with a stubbed gh in bypass and auto mode, covering both refused merges and read-only calls that still work.

Review checked against Claude Code's permission-rule syntax and the docs-team-standards merge-guard list.

@Feediver1 Feediver1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider the suggestions

@JakeSCahill
JakeSCahill merged commit 0240cd8 into main Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants