gh-protect-default-branch

Automate branch protection enforcement on GitHub repositories via gh CLI.

1|Updated Feb 14, 2026
One-click install
npx skills add https://github.com/mir-am/skills-agents-ai-coding --skill gh-protect-default-branch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh-protect-default-branch
Source: https://github.com/mir-am/skills-agents-ai-coding/tree/main/skills/gh-protect-default-branch
Command: npx skills add https://github.com/mir-am/skills-agents-ai-coding --skill gh-protect-default-branch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill automates the process of applying and removing branch protections on GitHub repositories, helping developers enforce safe workflow rules efficiently.

Core Features & Use Cases

  • Automatic Detection: Finds the default branch of a GitHub repository.
  • Apply Protection: Sets branch protections that require pull requests for merging and block force pushes and deletions.
  • Remove Protection: Removes existing branch protections upon user request.
  • Use Case: When managing a team repository, you can ensure all changes are reviewed via pull requests, preventing accidental direct pushes.

Quick Start

Use the github protect skill to automatically enforce branch protections on the main branch of your current repository.

Frequently Asked Questions about gh-protect-default-branch

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

FAQPage Schema
How do I enforce branch protection rules on a GitHub default branch?

GitHub branch protection is enforced by applying rules that mandate pull request reviews and block force pushes or deletions. This automation requires admin permissions and the gh CLI to configure repository workflow policies.

What is the best way to prevent direct pushes to a main branch in a team repository?

Preventing direct pushes to a main branch is achieved by applying automated branch protection policies that require pull requests for merging. This workflow enforcement stops accidental commits and deletions on the default branch.

Can I remove branch protection from a GitHub repository when I no longer need it?

Existing branch protection can be removed upon request from a GitHub repository. This allows repository administrators to easily disable mandated pull request reviews and restore direct push permissions.

Do I need admin permissions to use GitHub branch protection automation?

Admin permissions are required to automate GitHub branch protection. You also need the gh CLI installed and access to the target repository to enforce pull request workflows and block force pushes.

Does GitHub branch protection automation automatically detect the default branch?

GitHub branch protection automation automatically detects the default branch of a repository. It then applies the configured security policies to prevent direct pushes and deletions on that specific branch.

When should I not use automated branch protection on my GitHub repository?

Automated branch protection should not be used if your repository lacks an enforced pull request workflow or if you need to allow direct pushes without reviews. It mandates PRs for merging, which may hinder solo development.