agentleFS
syangasyanga/astack/skills/claude-merge-gate/SKILL.md

claude-merge-gate

Skill0 starsChanged 57 days agoMITView on GitHub

Claude Code hook that denies an agent's PR merge until a signed review exists on the head commit.

The file

Files
SKILL.md

Deny merges without a signed review

scripts/hook.py is a Claude Code PreToolUse hook for the Bash tool. It allows a pull request merge only as a lone command:

gh pr merge [<number> | <url> | <branch>] [--repo <owner>/<repo>] --match-head-commit <sha> [flags]

The command must be one line of letters, digits, spaces, and . _ : / = @ + , % -, so the shell passes every word through unchanged. Each flag must be a separate, literal gh pr merge flag. The hook runs gh pr view in the session's working directory and allows the merge when both hold:

  • The head commit has a review whose first line carries the header that pr.py review writes, from the repository's owner, a member, or a collaborator. The hook ignores the review's outcome.
  • --match-head-commit names that head commit.

--disable-auto, --help, and -h pass without a check.

The hook denies every other Bash command that mentions a PR merge: pr merge (also with flags between the words), a pulls/.../merge endpoint, mergePullRequest, enablePullRequestAutoMerge, or enqueuePullRequest. That includes chains, pipes, redirects, sh -c, heredocs, and quoted text such as a commit message that mentions gh pr merge. Its deny message asks for the lone form and says how to write or search for text that mentions a PR merge.

Once the hook checks a merge, it fails closed. It denies the merge when gh fails or times out. If the event is malformed, or the script or python3 is missing, the hook exits with code 1, and Claude Code reports the hook error and runs the command.

The hook has no override. It misses merges in the GitHub web interface, in non-Bash tools, through gh or shell aliases, in scripts that run the merge themselves, in text built to hide the words, and pushes straight to the base branch. A header typed by hand with gh pr review also passes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.