git-guardrails-claude-code

Blocks dangerous git commands via a PreToolUse hook for Claude Code.

29|1|Updated Jan 18, 2026
One-click install
npx skills add https://github.com/bohdanbirdie/cloudstash --skill git-guardrails-claude-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-guardrails-claude-code
Source: https://github.com/bohdanbirdie/cloudstash/tree/main/.agents/skills/git-guardrails-claude-code
Command: npx skills add https://github.com/bohdanbirdie/cloudstash --skill git-guardrails-claude-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq, and includes scripts (resource) components.

What problem does it solve?

Blocks dangerous git commands before Claude Code executes them, preventing destructive operations from occurring in automated workflows.

Core Features & Use Cases

  • PreToolUse hook installation for project scope or global scope to enforce safety before code runs.
  • Bundled guard script at scripts/block-dangerous-git.sh that blocks risky commands like git push, git reset --hard, git clean -f/-fd, git branch -D, and git checkout/restore.
  • Two deployment scopes: apply to a single project (via .claude/settings.json) or globally (via ~/.claude/settings.json), suitable for developer teams and CI environments.
  • Safe collaboration by preventing accidental destructive commands in shared repos and automated tasks.

Quick Start

Install the bundled guard script and configure the scope (project or global) as described to start blocking dangerous git operations.

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 in Claude Code before they execute?

To block dangerous git commands in Claude Code, you can use a PreToolUse hook configured by a bundled bash script. This setup prevents risky operations like git push, git reset --hard, and git clean from executing automatically.

What is a PreToolUse hook and how does it prevent destructive git operations?

A PreToolUse hook intercepts tool execution before it runs, allowing you to block destructive git operations. It checks requested commands against a blocklist and stops execution of operations like git branch -D and git checkout.

Can I apply git guardrails globally or do I need to configure them per project?

You can apply git guardrails globally or per project. The installation script configures either the local .claude/settings.json for a single repository or ~/.claude/settings.json for global enforcement across all environments.

Do I need jq to install the git guardrails hook for Claude Code?

Yes, you need jq installed to use this Skill. The bundled bash script relies on jq to parse and update the .claude/settings.json file during the PreToolUse hook installation and configuration process.

Which specific git commands are blocked by the PreToolUse guard script?

The guard script blocks destructive git commands including git push, git reset --hard, git clean -f, git clean -fd, git branch -D, and git checkout/restore. This prevents accidental data loss in shared repositories.