git-guardrails-claude-code

Block dangerous git commands using a PreToolUse hook.

Updated Mar 21, 2026
One-click install
npx skills add https://github.com/CidLucas/repo_platform --skill git-guardrails-claude-code-cidlucas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/CidLucas/repo_platform/tree/main/.github/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/CidLucas/repo_platform --skill git-guardrails-claude-code-cidlucas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Prevents destructive git commands (push, reset --hard, clean, branch -D, etc.) from executing, enhancing security and preventing accidental data loss.

Core Features & Use Cases

  • Git Command Blocking: Blocks dangerous git commands like push, reset --hard, and clean.
  • PreToolUse Hook: Intercepts git commands before they execute.
  • Scope Selection: Choose to apply the hook to a single project or globally across all projects.
  • Customization: Allows customization of the blocked commands list.
  • Verification: Provides a test command to verify the hook is functioning correctly.

Quick Start

Install the git-guardrails-claude-code Skill for your project, and follow the provided steps to set up the PreToolUse hook.

Frequently Asked Questions about git-guardrails-claude-code

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

FAQPage Schema
How do I block dangerous git commands like reset --hard and clean in Claude Code?

To block dangerous git commands in Claude Code, you can use a PreToolUse hook to intercept and prevent destructive operations before they execute. This stops commands like push, reset --hard, and clean from causing accidental data loss.

Can I apply git safety hooks globally across all my projects?

Yes, you can apply git safety hooks globally across all projects or select a single project scope. This flexibility allows you to enforce git command blocking consistently or target specific repositories needing code protection.

How do I set up a PreToolUse hook to prevent accidental git data loss?

You set up a PreToolUse hook by installing the git safety skill and following the quick start steps to configure it. The hook intercepts git commands before execution, preventing destructive operations and accidental data loss.

What destructive git commands should I intercept for code protection?

For code protection, you should intercept destructive git commands such as push, reset --hard, clean, and branch -D. You can customize the blocked commands list to include any specific git operations you want to prevent from executing.

How do I verify that my git command blocking hook is working?

To verify your git command blocking hook is working, you can use the provided test command. This checks that the PreToolUse hook is functioning correctly and successfully intercepting dangerous git commands before execution.

Does git hooks safety work with Claude Code environments?

Yes, git hooks safety is designed specifically for Claude Code environments. It uses a PreToolUse hook to block dangerous git commands, providing safety checks in environments where destructive commands can lead to accidental data loss.