plugins/enforce/skills/branch-protection-enforcement-patterns/SKILL.md
Comprehensive branch protection configuration patterns with enforcement automation. Security tiers, IaC at scale, GitHub App enforcement, audit reporting, and bypass controls.
npx skillsauth add adaptive-enforcement-lab/claude-skills branch-protection-enforcement-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
graph TD
T[Terraform Module] -->|Applies| BP[Branch Protection Rules]
GA[GitHub App] -->|Monitors| BP
GA -->|Detects| DRIFT[Configuration Drift]
DRIFT -->|Triggers| REM[Automated Remediation]
REM -->|Restores| BP
BP -->|Enforces| PR[Pull Requests]
PR -->|Generates| AUDIT[Audit Evidence]
%% Ghostty Hardcore Theme
style T fill:#a7e22e,color:#1b1d1e
style GA fill:#65d9ef,color:#1b1d1e
style DRIFT fill:#f92572,color:#1b1d1e
style BP fill:#fd971e,color:#1b1d1e
Key Components:
Start with Security Tiers to select the appropriate protection level for your repositories.
Manual (single repository):
gh api --method PUT \
repos/org/repo/branches/main/protection \
--input protection-config.json
Automated (organization-wide):
Deploy GitHub App Enforcement to detect drift and maintain compliance.
Implement Audit Evidence patterns for compliance reporting.
Multiple enforcement layers: local configuration, drift detection, audit verification.
Don't document the policy. Enforce it automatically.
Standard, Enhanced, Maximum tiers prevent both under-protection and over-restriction.
GitHub API provides tamper-proof evidence of all enforcement actions.
Bypass controls with approval workflows, time-boxing, and automatic re-enablement.
Most organizations have branch protection policies. Few enforce them consistently.
The Problem:
The Solution:
Automated enforcement with multiple defense layers:
Different repositories require different protection levels.
| Tier | Use Case | Enforcement Level | |------|----------|-------------------| | Standard | Internal tools, documentation | Required reviews, basic status checks | | Enhanced | Production services, customer-facing apps | Multi-reviewer, comprehensive checks, code owners | | Maximum | Security-critical, compliance-regulated | Full enforcement, no admin bypass, mandatory signing |
Right-Sized Security
Not all repositories need maximum protection. Documentation repos can use Standard tier. Production infrastructure requires Maximum tier. Choose based on blast radius.
See Security Tiers for detailed configuration templates.
graph TD
T[Terraform Module] -->|Applies| BP[Branch Protection Rules]
GA[GitHub App] -->|Monitors| BP
GA -->|Detects| DRIFT[Configuration Drift]
DRIFT -->|Triggers| REM[Automated Remediation]
REM -->|Restores| BP
BP -->|Enforces| PR[Pull Requests]
PR -->|Generates| AUDIT[Audit Evidence]
%% Ghostty Hardcore Theme
style T fill:#a7e22e,color:#1b1d1e
style GA fill:#65d9ef,color:#1b1d1e
style DRIFT fill:#f92572,color:#1b1d1e
style BP fill:#fd971e,color:#1b1d1e
Key Components:
This section covers comprehensive branch protection enforcement:
Start with Security Tiers to select the appropriate protection level for your repositories.
Manual (single repository):
gh api --method PUT \
repos/org/repo/branches/main/protection \
--input protection-config.json
Automated (organization-wide):
Deploy GitHub App Enforcement to detect drift and maintain compliance.
Implement Audit Evidence patterns for compliance reporting.
See reference.md for additional techniques and detailed examples.
See examples.md for code examples.
See reference.md for complete documentation.
documentation
Workload Identity Federation implementation guide. GKE setup, IAM bindings, ServiceAccount configuration, migration from service account keys, and troubleshooting patterns.
development
Secure GitHub Actions trigger patterns for pull requests, forks, and reusable workflows. Preventing privilege escalation and code injection through trigger misconfiguration.
development
Structured framework for evaluating GitHub Actions security before adoption. Trust tiers, risk assessment checklist, and decision tree for action evaluation.
testing
Securely store GitHub App credentials across different environments. GitHub Actions secrets, external CI, Kubernetes, and automated rotation patterns.