agentleFS
FuDesign2008FuDesign2008/open-skills/skills/git-branch-protect/SKILL.md

git-branch-protect

Skill6 starsChanged 6 days agoMITView on GitHub

Use when checking or changing who can push or merge release/*, an exact release branch, or main/master. Read the live rule with glab or gh, then whitelist the active release, freeze a finished release, set trunk protection, or roll a release branch back to a chosen commit. Also use when git-release-start or git-release-finish needs that check. Triggers — 「分支权限」「保护分支」「冻结 release」「release 白名单」「回退保护分支」 / branch protection, freeze release branch, release whitelist, protected branch permission. Do NOT use for creating the release branch, tagging and merging the release, or merging an ordinary change. A protection write waits for the user to confirm that command.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 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.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep one active release/X.Y.Z mergeable, keep every other release branch closed, and keep trunk push closed.

    line 12
  2. Distinctive:

    Run the reference's read first.

    line 41
  3. Very specific:

    After acceptance, run that one command, read the rule again, and print the report.

    line 49
  4. Very specific:

    Run the matching section in the host reference.

    line 55
  5. Very specific:

    When blocked-layer is set, stop.

    line 85

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

Git Branch Protect

Overview

Keep one active release/X.Y.Z mergeable, keep every other release branch closed, and keep trunk push closed. GitLab and GitHub combine overlapping rules differently, so the host procedure lives in one reference file. Read that file before any API call.

The condition is the live protection rule on the host. Read it with glab or gh and compare it with the operation's effect. There is no committed config file.

Pairing: after the remote branch exists, git-release-start asks this skill to read the default and the new branch. After the tag and the trunk merge have both succeeded, git-release-finish asks it to read whether that branch is frozen, and it reads trunk during fingerprinting. A release skill naming an operation is a request to compare the live rule. The write itself waits for the user. Neither release skill calls rollback.

Use when / Do not use for

Use when:

  • The user asks to freeze a release branch, open one release branch for merge, set main or master protection, or roll a release branch back to an older commit
  • git-release-start or git-release-finish needs the live rule compared with the expected push and merge result

Do not use for:

  • Creating the release branch (git-release-start)
  • Tagging and merging the release into trunk (git-release-finish)
  • Deciding whether an ordinary merge request may land (merge-discipline)

Judge from the remote rule

From the repo's origin URL, choose one reference and do not mix procedures:

OriginReferenceRead command
GitLab hostreferences/gitlab.mdglab api
GitHub hostreferences/github.mdgh api
Anything elseStop. Say this skill covers GitLab and GitHub only—

Run the reference's read first. When the live push and merge results already match the operation, print the report and stop. When they differ, print the live rule and the target rule.

Confirm a write

Creating, updating, or deleting a protection rule is a high-risk change. Show the branch, the operation, the live rule, the target rule, and the exact command, then wait.

Acceptance is an explicit yes to that branch and that operation. Workflow auto-advance is not acceptance. A release skill naming the operation is not acceptance. A yes for a different branch or a different operation is not acceptance.

After acceptance, run that one command, read the rule again, and print the report. When the user declines, leave the rules as they are and set confirmation to declined.

check-trunk and every other read run immediately.

Operations

Run the matching section in the host reference. After a write the user accepted, verify with that file's permission check. merge_status, mergeable, and mergeable_state are not the verdict.

OperationEffect
ensure-defaultUnmatched release/* branches deny push and deny merge. Leave an existing default that already does this unchanged. List every exact rule that still allows merge
allow-merge <branch>That exact branch denies push and allows maintainer merge. Other allow entries stay
freeze <branch>When a wider rule already denies merge, remove only that branch's allow entry. When no matching rule denies merge, set the exact rule to deny push and deny merge. If a wider rule still allows merge, report the branch as not frozen and name the rule
check-trunk [name]Compare trunk with "push denied, maintainer merge allowed". Report a mismatch. Do not write
rollback <branch> <sha>Only when the user invoked this operation and confirmed the sha, the force-push, and the temporary protection change. Backup, move the branch, restore the frozen policy

For a new release, compare ensure-default first, then allow-merge. Each write waits for its own acceptance. freeze is offered only after the tag exists and the trunk merge has succeeded, and it runs only after acceptance.

Trunk writes happen only when the user asks this skill directly to set trunk policy and then accepts set-trunk. Use the same push-denied, maintainer-merge policy. A release skill reports trunk drift and does not run set-trunk.

Report

Print this after every operation:

branch: <name>
operation: <ensure-default|allow-merge|freeze|check-trunk|rollback|set-trunk>
push: denied | allowed
merge: denied | maintainers
confirmation: already-met | accepted | declined | read-only
evidence: <permission field or rule computation>
observed-mr: <iid or none>
still-open: <exact branches that remain mergeable, or none>
blocked-layer: <group or organization rule the caller cannot edit, or none>

When blocked-layer is set, stop. Do not claim the branch is frozen or whitelisted.

Examples

Input: "冻结 release/1.2.3"

Output: read the live rule. When the branch is already frozen, the report says confirmation: already-met. When it is not, show the command that removes only that allow entry and wait. After the user accepts, run it and print the report. On GitLab, when release/* already denies merge, the accepted write deletes the exact allow rule. When no matching rule denies merge, the accepted write sets the exact rule to deny push and deny merge. On GitHub it removes the exception for that branch on every layer that targets it, or locks the exact rule when no wildcard is in use.

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.