git-guardrails-claude-code

Block dangerous git commands before execution in Claude Code environments.

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/flowel/AiSkills --skill git-guardrails-claude-code-flowel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/flowel/AiSkills/tree/main/skills/codex/git-guardrails-claude-code
Command: npx skills add https://github.com/flowel/AiSkills --skill git-guardrails-claude-code-flowel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill stops dangerous git commands from executing in Claude Code, enhancing the security and safety of code operations.

Core Features & Use Cases

  • Block Dangerous Commands: Prevents operations like git push, git reset --hard, git clean, git branch -D, and git checkout . to avoid unintended changes to the codebase.
  • Scope Customization: Choose to install the blockage at a project or global level in .claude/settings.json.
  • Customization Option: Customize which commands are blocked by editing the hook script.

Quick Start

To set up Git Guardrails, copy the script to .claude/hooks/block-dangerous-git.sh or ~/.claude/hooks/block-dangerous-git.sh, make it executable, and add it to PreToolUse hooks in your settings file.

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 git push and git reset in Claude Code?

You can block dangerous git commands by installing a hook script into `.claude/hooks` and configuring it within the PreToolUse hooks in your `.claude/settings.json` file. This prevents operations like git push and git reset from executing.

Can I restrict destructive git operations across all my projects globally?

Yes, you can apply git safety restrictions globally by placing the blockage script in `~/.claude/hooks` and configuring the settings globally. This applies command blocking across all projects using the Claude Code environment.

What is the best way to prevent unintended codebase changes from AI coding assistants?

The best way to prevent unintended changes is to block destructive git operations before execution. Adding a customized shell script to your PreToolUse hooks stops commands like `git clean` and `git checkout .` from running.

How do I customize which specific git commands are blocked in my development environment?

You can customize blocked git commands by directly editing the hook script. This allows you to define specific command patterns to intercept and prevent from executing within your Claude Code setup.

Does this git safety hook require any special dependencies to run?

No special dependencies are required. You only need a properly configured Claude Code environment to set up the hook script, make it executable, and add it to your settings to start blocking dangerous git commands.

Why should I use a PreToolUse hook for git security instead of manual command reviews?

Using a PreToolUse hook automates git security by intercepting dangerous commands before execution. This provides consistent code protection against operations like `git branch -D` without relying on manual oversight.