gh-protect-default-branch

gh-protect-default-branch is a skill for Claude Code, Codex from mir-am/skills-agents-ai-coding. It costs 21 tokens per session (859 once invoked), scanned A, original, MIT.

A repository setup tool that protects a GitHub project's default branch from direct changes. It requires changes to arrive through pull requests and blocks force-pushes and branch deletion.

In plain words
What is it for?
Use it in a GitHub repository to find the default branch, apply basic protection rules, verify them, or remove them when requested.
Why use it?
It reduces the risk of accidental or unauthorized changes to the main development branch. It also checks that the protection rules were applied correctly.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it in a GitHub repository to find the default branch, apply basic protection rules, verify them, or remove them when requested.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mir-am/skills-agents-ai-coding --skill gh-protect-default-branch
Clone the repo
git clone --depth 1 https://github.com/mir-am/skills-agents-ai-coding

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gh-protect-default-branch

README.md
[![agentmods](https://agentmods.dev/badge/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch/github.svg)](https://agentmods.dev/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch)
Your own site
<a href="https://agentmods.dev/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch"><img src="https://agentmods.dev/badge/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for gh-protect-default-branch

Your own site · 80×15
<a href="https://agentmods.dev/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch"><img src="https://agentmods.dev/badge/skills/mir-am/skills-agents-ai-coding/gh-protect-default-branch.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 859 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00021 $0.00859
Opus 5.5 $0.00008 $0.00344
Sonnet 5.5 $0.00004 $0.00172
Haiku 4.5 $0.00002 $0.00086

Measured 2mo ago against content hash c971d9253dfd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

gh-protect-default-branch scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/gh-protect-default-branch/SKILL.md · 104 lines

How it starts

The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.

What I do

  • Detect the repository's default branch automatically
  • Apply minimal branch protection: require a pull request before merging, block force pushes and deletions
  • Verify the protection was applied correctly
  • Optionally remove protection if the user asks

When to use me

Use this skill when the user wants to protect the default branch from direct pushes so that changes can only be merged through pull requests.

Prerequisites

  • GitHub CLI (gh) must be installed and authenticated
  • Must be inside a git repo with a GitHub remote
  • The authenticated user must have admin permissions on the repository
  • If gh not installed -> error: Error: GitHub CLI not found. Install: https://cli.github.com/
  • If not authenticated -> error: Error: Not authenticated with GitHub. Run: gh auth login
  • If not admin -> error: Error: Admin permissions required to set branch protection

Apply Protection Workflow

  1. Validate GitHub access

    gh auth status
    
  2. Detect default branch and repo

    gh repo view --json nameWithOwner,defaultBranchRef --jq '"\(.nameWithOwner) \(.defaultBranchRef.name)"'
    

    Parse the output to get OWNER/REPO and BRANCH.

  3. Apply minimal branch protection

    gh api -X PUT \
      -H "Accept: application/vnd.github+json" \
      "repos/{owner}/{repo}/branches/{branch}/protection" \
      --input - <<'EOF'
    {
      "required_status_checks": null,
      "enforce_admins": true,
      "required_pull_request_reviews": {
        "required_approving_review_count": 0
      },
      "restrictions": null,
      "allow_force_pushes": false,
      "allow_deletions": false
    }
    EOF
    

    Replace {owner}/{repo} and {branch} with the values from step 2.

  4. Verify protection

    gh api -H "Accept: application/vnd.github+json" \
      "repos/{owner}/{repo}/branches/{branch}/protection" \
      --jq '{pr_required: (.required_pull_request_reviews != null), force_push_blocked: ((.allow_force_pushes.enabled // false) == false), deletions_blocked: ((.allow_deletions.enabled // false) == false)}'
    

    All three fields should be true.

Read the full file on GitHub · 104 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago Changed · -1 lines c971d9253dfd
  2. 3mo ago First seen · 105 lines · 21 tokens per session scan A 9acb679b48ca

Subscribe to this mod's changes

gh-protect-default-branch is a skill published in the GitHub repository mir-am/skills-agents-ai-coding (2 stars, last pushed 2mo ago), licensed MIT. It adds 21 tokens to every session and 859 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

gh-protect-default-branch compared with skills from other repositories

gh-protect-default-branch next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
gh-protect-default-branchmir-am/skills-agents-ai-codingSkill22mo agoMITA21Claude Code, Codex
skill-upstream-prluongnv89/asmSkill976yesterdayMITA56Claude Code
skill-changelogluongnv89/asmSkill976yesterdayMITA53Claude Code
release-notesRealDealCPA-VR/Iron-JarvisSkill70todaynoneA19Claude Code, Codex
git-workflowandreibesleaga/GABBESkill24yesterdaynoneA47Claude Code, Codex
ci-autofixandreibesleaga/GABBESkill24yesterdaynoneA59Claude Code, Codex
swe-worktreeSNIKO/agent-skillsSkill23mo agoMITA33Claude Code