branch-guard
Skill1 starsChanged 5 months agoMITView on GitHub
Hooks, not vigilance — block direct commits/pushes to protected branches, and assert the PR base is the configured target. Activates before any commit or push (protected-branch guard) and immediately after a PR is created (PR-base guard, because a CLI can silently ignore --base).
- Commits and pushes
2 other projects use a version of this.
Adopted by
Most recently taken up by
- BK202503/open-claude-alltheir own version, first seen Nov 8, 2026
- gerivdb/SKILLStheir own version, first seen Aug 7, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- BK202503/open-claude-all★ 7same name
- gerivdb/SKILLS★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- cross-model-reviewSkill
- empirical-firstSkill
- orchestrator-verifySkill
- review-loop-autopilotSkill
- worktree-isolateSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
If it is in the protected set (the configured integration branch + any others), the hook blocks the action and points at the worktree + …
- Very specific: line 27
Never bypass a secret scanner or this guard with --no-verify without manually verifying the underlying finding first.
- Very specific: line 32
If the base is wrong, detect and report it — surface the mismatch (actual vs.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Branch-guard
Hooks, not vigilance. A guard blocks direct commits/pushes to protected branches before they happen, and a second guard asserts the PR base after the PR opens — because a CLI can silently ignore --base.
Contract
Protection is enforced by hooks, not by remembering. (§A) A pre-action guard blocks direct commits/pushes to protected branches and fires before the commit/push. (§B) A PR-base guard asserts the PR base equals the configured PR-target branch and fires after the PR is created — and because a CLI can silently ignore --base, the base is re-read after the PR opens; on a mismatch it reports and stops, requiring explicit authorization before any retarget (gh pr edit is an outward action).
When to trigger
- §A — before any
git commitorgit pushthat could land on a protected branch (the configured integration branch and any other protected names). - §B — immediately after a PR is created, before treating it as correct.
- You just passed
--baseto a PR-create command — verify it was actually honored. - You are about to rely on discipline ("I'll just remember not to commit to the integration branch") instead of a hook.
Protocol
§A Protected-branch guard (fires before commit/push)
- A pre-action hook intercepts
git commit/git pushand reads the current/target branch. - If it is in the protected set (the configured integration branch + any others), the hook blocks the action and points at the worktree + feature-branch + PR flow.
- Never bypass a secret scanner or this guard with
--no-verifywithout manually verifying the underlying finding first.
§B PR-base guard (fires after PR creation)
- On PR creation, assert the base == the configured PR-target branch.
- Re-read the base after the PR opens — do not trust that
--basewas honored. - If the base is wrong, detect and report it — surface the mismatch (actual vs. expected) and STOP.
gh pr edit --baseis an outward state-mutating action: require explicit authorization before retargeting. Do not auto-correct the live PR.
Anti-patterns
- Relying on vigilance instead of a hook to stay off a protected branch.
- Trusting that
--basewas honored without re-reading the opened PR's base. - Loading only §A and missing the §B postcondition (or vice versa).
--no-verifyto get past the guard or a secret scanner without verifying the finding.
Worked micro-example
# §A — a PreToolUse-style guard, before the action:
on git commit|push:
if target_branch in PROTECTED: block → "use worktree + feature branch + PR"
# §B — after the PR opens (DETECT + REPORT; do NOT auto-edit):
gh pr create --base <pr-target> ...
actual=$(gh pr view <n> --json baseRefName -q .baseRefName)
if [ "$actual" != "<pr-target>" ]; then
echo "PR #<n> base is '$actual', expected '<pr-target>' — CLI ignored --base. STOP."
# gh pr edit <n> --base <pr-target> # outward action: run ONLY after explicit human OK
fiThe near-miss this guards against: a PR-create CLI silently ignored --base and opened against the
wrong branch — caught only because §B re-read the base instead of trusting the flag. The guard
reports the mismatch; retargeting the live PR is an outward action that waits for explicit
authorization (it is never auto-applied).
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
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.

