git-safety-guard

Block destructive git and filesystem commands before execution using an allowlist.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/terraphim/terraphim-skills --skill git-safety-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-safety-guard
Source: https://github.com/terraphim/terraphim-skills/tree/main/skills/git-safety-guard
Command: npx skills add https://github.com/terraphim/terraphim-skills --skill git-safety-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Blocks destructive git and filesystem commands before execution to protect uncommitted work.

Core Features & Use Cases

  • PreToolUse guard: Intercepts Bash commands and blocks dangerous operations using a safe allowlist of patterns.
  • CLI integration: terrraphim-agent guard provides runtime decision results for integration hooks.
  • Fail-open semantics: If the guard is unavailable or patterns fail, commands are allowed to avoid workflow disruption.

Quick Start

Install terraphim-agent from GitHub releases, then configure a PreToolUse Bash hook in your project. Copy the guard script to your repository at .claude/hooks/git_safety_guard.sh and reference it in .claude/settings.local.json: { "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": ".claude/hooks/git_safety_guard.sh" }] }] } } Validate behavior by piping commands through terraphim-agent guard, e.g.: echo "git reset --hard" | terraphim-agent guard --json echo "git checkout -b feature" | terraphim-agent guard --json

Frequently Asked Questions about git-safety-guard

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

FAQPage Schema
How do I block destructive git commands like git reset --hard before execution?

You can block destructive git commands by configuring a PreToolUse Bash hook that intercepts execution and validates commands against a safe allowlist of patterns before they run.

How do I prevent rm -rf and git clean -f from deleting uncommitted work?

Prevent file deletion by installing a guard script that applies regex pattern matching to identify and block dangerous filesystem commands, protecting your uncommitted work from accidental loss.

Can I use a PreToolUse hook to intercept bash commands in Claude Code?

Yes, you can configure a PreToolUse hook in your project settings to match Bash commands and execute a guard script that blocks dangerous operations using an allowlist.

What happens if the command guard is unavailable or pattern matching fails?

The guard uses fail-open semantics, meaning if the guard is unavailable or regex patterns fail, commands are allowed to execute to avoid disrupting your workflow.

How do I validate that my git safety guard is blocking dangerous commands correctly?

Validate your guard by piping commands through the terrraphim-agent guard CLI with the JSON flag, such as echoing 'git reset --hard' to see the runtime decision result.

Do I need to manually list every dangerous command to protect my repository?

No, the guard uses regex pattern matching alongside a safe allowlist of patterns to identify destructive operations, so you do not need to manually list every dangerous command.