branch-protection

Block dangerous Git operations on protected branches via PreToolUse hook.

1|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/hypeJunction/ai-assistant-starter --skill branch-protection-hypejunction
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: branch-protection
Source: https://github.com/hypeJunction/ai-assistant-starter/tree/main/skills/branch-protection
Command: npx skills add https://github.com/hypeJunction/ai-assistant-starter --skill branch-protection-hypejunction

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents accidental or malicious destructive Git operations (like force-pushing or deleting) on critical branches, safeguarding your codebase's integrity.

Core Features & Use Cases

  • Real-time Git Operation Interception: Hooks into Bash commands to analyze Git operations before execution.
  • Protected Branch Enforcement: Automatically blocks or warns against dangerous commands targeting branches like main or master.
  • Use Case: An AI assistant attempting to force-push to the main branch will be blocked, preventing accidental history rewriting.

Quick Start

Configure your AI assistant to use the branch-protection hook by adding it to your Claude Code settings.

Frequently Asked Questions about branch-protection

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

FAQPage Schema
How do I prevent force-pushes and branch deletions on my main Git branch?

You can prevent force-pushes and branch deletions on a main Git branch by using a hook system that intercepts and blocks dangerous operations before execution. This safeguards collaborative development environments from accidental history rewriting.

Can I block an AI assistant from running destructive Git commands on master?

Yes, you can block an AI assistant from running destructive Git commands on master by executing a Node.js script via the PreToolUse hook system. It analyzes Bash commands in real-time to automatically block dangerous operations targeting protected branches.

What is branch protection and how does it enforce code safety in collaborative environments?

Branch protection is the enforcement of security rules that intercept and block dangerous Git operations on designated branches. It manages code safety in collaborative environments by preventing force-pushes, hard resets, and branch deletions on main or master branches.

How do I set up a PreToolUse hook to intercept Git operations?

To set up a PreToolUse hook to intercept Git operations, you configure your AI assistant settings to include the branch-protection hook. This Node.js script hooks into Bash commands to analyze and block dangerous Git operations before they are executed.

Does branch protection work without any additional dependencies?

Yes, branch protection works without additional dependencies because it utilizes a standalone Node.js script executed directly through the Claude Code PreToolUse hook system. You only need to configure your AI assistant settings to enable the interception mechanism.

What are the limitations of using hooks for Git branch protection?

The limitation of using hooks for Git branch protection is that it specifically intercepts Bash commands executed by the AI assistant, meaning it focuses on preventing force-pushes, hard resets, and deletions rather than providing server-side repository policy enforcement.