git-guardrails

Install a Git PreToolUse hook to block destructive commands.

2|Updated Aug 8, 2024
One-click install
npx skills add https://github.com/walid-mos/mac-config --skill git-guardrails
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails
Source: https://github.com/walid-mos/mac-config/tree/main/claude/.claude/skills/git-guardrails
Command: npx skills add https://github.com/walid-mos/mac-config --skill git-guardrails

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill prevents accidental or unauthorized execution of dangerous Git commands that could lead to data loss or unintended changes.

Core Features & Use Cases

  • Command Interception: Blocks destructive Git commands like push, reset --hard, clean -f, branch -D, checkout ., and restore ..
  • Safety Guardrails: Ensures that critical Git operations are reviewed or prevented, especially in automated or AI-assisted workflows.
  • Use Case: When an AI assistant is about to push changes to a production branch, this hook will block the action, prompting the user to confirm or reconsider.

Quick Start

Install the git-guardrails skill to protect your repository from dangerous Git commands.

Frequently Asked Questions about git-guardrails

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

FAQPage Schema
How do I block destructive git push commands before they execute?

To block destructive git push commands, you can install a Git PreToolUse hook that intercepts execution using bash pattern matching. This safety guardrail validates commands before they run, preventing unauthorized operations and prompting user confirmation.

Can I configure git hooks to prevent reset --hard and clean -f globally?

Yes, you can configure git hooks to prevent reset --hard and clean -f globally. The hook installation is configurable for both project-specific repositories and global environments, applying command interception across your workflow.

What git commands should I block to protect my repository from data loss?

To protect your repository from data loss, block commands including push, reset --hard, clean, branch -D, checkout ., and restore .. Intercepting these destructive operations ensures critical changes are reviewed before execution.

Does a PreToolUse hook work with automated AI-assisted git workflows?

Yes, a PreToolUse hook works with automated AI-assisted git workflows. It intercepts dangerous commands before execution, providing a safety layer that ensures destructive operations are blocked when an AI assistant attempts them.

How do I stop an AI assistant from pushing changes to a production branch?

To stop an AI assistant from pushing changes to a production branch, install a PreToolUse hook with command blocking. It intercepts the push command before execution, prompting the user to confirm or reconsider the action.