github

Export, disable, and restore GitHub branch protection and rulesets via the gh CLI.

2|Updated Jul 28, 2026
One-click install
npx skills add https://github.com/mbadali25/useful-claude-add-ons --skill github-mbadali25
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: github
Source: https://github.com/mbadali25/useful-claude-add-ons/tree/main/skills/github
Command: npx skills add https://github.com/mbadali25/useful-claude-add-ons --skill github-mbadali25

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gh, jq, and includes scripts (resource) components.

What problem does it solve? Temporarily turning off a GitHub merge gate is risky: a repo can carry both classic branch protection and rulesets at once, reading one without admin rights returns a 404 that looks like "nothing configured", and deleting protection without a verified backup leaves no way to restore it. This Skill makes the whole operation safe by exporting both gate surfaces to a validated file before anything is deleted, and restoring only from that export. ## Core Features & Use Cases - Dual-surface export: Captures classic branch protection, required signed commits, and every ruleset (fetched by id, since the list endpoint omits rules and conditions) into one validated JSON document. - Guarded disable: Refuses to delete anything when a surface is unreadable, a ruleset's scope cannot be determined, or an org/enterprise ruleset would remain — exiting with code 3 and naming exactly what blocked the run. - Restore-only enable: Rebuilds classic protection via PUT (converting GET shapes to PUT shapes), restores signed commits through their own endpoint, and re-POSTs rulesets fresh, skipping ones already present. - Use Case: A release is blocked by "Required status check is expected" on main. Run scripts/merge_gate.sh disable myorg my-repo --branch main --export-to gate-backup.json, merge, then enable --from-export gate-backup.json to put the exact gate back. ## Quick Start Ask the assistant to export the merge gate for your GitHub repo's main branch, temporarily disable branch protection so a blocked PR can merge, and then restore the gate from the export file.

Frequently Asked Questions about github

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I temporarily disable GitHub branch protection to merge a PR?

Run scripts/merge_gate.sh disable with the owner, repo, and branch. It first exports both classic protection and rulesets to a verified backup file, prints a per-object plan, then deletes only the repo-owned surfaces gating that branch.

How do I restore GitHub branch protection after disabling it?

Run scripts/merge_gate.sh enable with --from-export pointing at the backup file. It PUTs the classic protection back, restores required signed commits via their own endpoint, and re-POSTs rulesets fresh, skipping any already present.

Why does the GitHub branch protection API return 404?

A 404 from the protection endpoint means either the branch is unprotected or you lack admin access — the status code is identical. Only the exact body "Branch not protected" means nothing is configured; any other 404 or 403 is treated as unreadable.

What permissions are needed to manage GitHub rulesets with gh api?

Every call requires admin on the repository; there is no read-only scope for branch protection or rulesets. A token that lists PRs fine will still fail here, and the failure looks like nothing is configured.

Can this tool remove organization-level rulesets?

No. Rulesets owned by the organization or enterprise cannot be deleted through the repo endpoint, so the script refuses by default. Passing --allow-inherited removes only repo-owned surfaces and warns on stderr how many inherited rulesets still gate the branch.

Why does enable fail without --from-export?

There is deliberately no preset. Re-enabling without an export would invent a gate rather than restore the one that was removed, so enable exits with usage code 2 and changes nothing unless given a validated export file.