agentleFS
fotowizzardfotowizzard/taskctl-oss/skills/branch-guard/SKILL.md

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

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. BK202503/open-claude-all★ 7same name
    2. 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.

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
  1. Distinctive:

    If it is in the protected set (the configured integration branch + any others), the hook blocks the action and points at the worktree + …

    line 26
  2. Very specific:

    Never bypass a secret scanner or this guard with --no-verify without manually verifying the underlying finding first.

    line 27
  3. Very specific:

    If the base is wrong, detect and report it — surface the mismatch (actual vs.

    line 32

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 commit or git push that 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 --base to 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)

  1. A pre-action hook intercepts git commit / git push and reads the current/target branch.
  2. 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.
  3. Never bypass a secret scanner or this guard with --no-verify without manually verifying the underlying finding first.

§B PR-base guard (fires after PR creation)

  1. On PR creation, assert the base == the configured PR-target branch.
  2. Re-read the base after the PR opens — do not trust that --base was honored.
  3. If the base is wrong, detect and report it — surface the mismatch (actual vs. expected) and STOP. gh pr edit --base is 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 --base was honored without re-reading the opened PR's base.
  • Loading only §A and missing the §B postcondition (or vice versa).
  • --no-verify to 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
fi

The 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).

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.