Skip to content
Report library
Purpose / Development

Git Guardrails Claude Code Skill Security Audit

What the author says it does (original text)

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

Independent security check

Do not install or run it yet

Files checked
3
Risks found
2
Could it run dangerous commands?Looks for programs run straight after downloading, remote control of your computer, and hidden commands.No risks found
Could it expose your files or keys?Looks for uploads of files containing passwords or keys, and keys written directly in the code.No risks found
Could it delete files or keep running?Looks for broad file deletion, disk overwrites, and programs set to start automatically.No risks found
Could it bypass safety checks?Looks for skipped website security checks, excessive file access, or actions that skip your approval.Risks found: 2
High risk

The guardrail is easily bypassed and allows commands when parsing fails

Source references: 4
What we found

The documentation claims all git push variants and several destructive commands are blocked, but the script only searches for fixed text fragments. Equivalent forms such as `git -C repo push`, extra whitespace, `git clean -df`, or long options do not match. It also relies on jq without checking success; extraction failure can leave COMMAND empty and the script still returns 0.

Why this matters

A user may believe dangerous Git operations are reliably prohibited while Claude can still push, permanently remove untracked files, or discard work through uncovered valid syntax.

The skill claims to block every `git push` variant, but the script only searches the full command for a short list of fixed regex fragments. Forms that insert `-C repo` between `git` and `push`, or vary whitespace or option order, may not match and can exit 0. It also relies on `jq` to extract the command without checking whether parsing succeeded; missing `jq`, invalid JSON, or a missing field may produce an empty value that reaches `exit 0`. This can give users more confidence than the implementation warrants. Users can ask for structured command parsing, fail-closed error handling, and tests of alternate command forms.

SKILL.md:12In the instructionsOpen original file
- `git push` (all variants including `--force`)- `git reset --hard`- `git clean -f` / `git clean -fd`- `git branch -D`- `git checkout .` / `git restore .`
Show 3 other places
scripts/block-dangerous-git.sh:3In the codeOpen original file
INPUT=$(cat)COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
scripts/block-dangerous-git.sh:6In the codeOpen original file
DANGEROUS_PATTERNS=(  "git push"  "git reset --hard"  "git clean -fd"  "git clean -f"  "git branch -D"  "git checkout \."  "git restore \."  "push --force"  "reset --hard")
scripts/block-dangerous-git.sh:18In the codeOpen original file
for pattern in "${DANGEROUS_PATTERNS[@]}"; do  if echo "$COMMAND" | grep -qE "$pattern"; then    echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2    exit 2  fidoneexit 0
Medium risk

Text-fragment matching can block harmless Bash operations

Source references: 4
What we found

The hook applies to every Bash call, while grep checks whether a fragment occurs anywhere in the full command instead of confirming that a Git subcommand will actually execute. Printing, searching, or writing content containing text such as `git push` is therefore also rejected.

Why this matters

Legitimate documentation generation, log analysis, tests, or explanatory commands may be unexpectedly interrupted and disrupt project workflows.

The hook applies to every Bash tool call, while the script merely searches the entire command text for listed regex fragments and does not determine which program would actually run. A harmless command that prints, searches for, or writes text such as `git push` or `reset --hard` may therefore be rejected with exit code 2. This is primarily an availability and decision-interference risk; it does not itself execute the dangerous Git operation. Users can ask the author to block only after parsing an actual Git invocation or to narrow the hook's scope.

SKILL.md:46In the instructionsOpen original file
  "hooks": {    "PreToolUse": [      {        "matcher": "Bash",        "hooks": [          {            "type": "command",            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"          }
Show 3 other places
scripts/block-dangerous-git.sh:18In the codeOpen original file
for pattern in "${DANGEROUS_PATTERNS[@]}"; do  if echo "$COMMAND" | grep -qE "$pattern"; then    echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2    exit 2  fidone
SKILL.md:45In the instructionsOpen original file
{  "hooks": {    "PreToolUse": [      {        "matcher": "Bash",        "hooks": [          {            "type": "command",            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"          }
scripts/block-dangerous-git.sh:3In the codeOpen original file
INPUT=$(cat)COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
Could it mislead the AI or hide text?Checks the skill instructions for requests to ignore you, influence the report, or hide text in invisible characters.No risks found
Could it change links or payment recipients without asking?Looks for forced referral or payment changes combined with instructions to hide the change.No risks found

Inside this skill

2 instruction sections

The Skill first asks the user to choose project-only or global installation, then copies the script, makes it executable, and registers it as a Claude Code PreToolUse hook for every Bash invocation. A global installation affects all projects.

View source
SKILL.md:24In the instructionsOpen original file
Ask the user: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?
SKILL.md:30In the instructionsOpen original file
Copy it to the target location based on scope:- **Project**: `.claude/hooks/block-dangerous-git.sh`- **Global**: `~/.claude/hooks/block-dangerous-git.sh`Make it executable with `chmod +x`.
SKILL.md:45In the instructionsOpen original file
{  "hooks": {    "PreToolUse": [      {        "matcher": "Bash",        "hooks": [          {            "type": "command",            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"          }

The hook reads JSON from standard input, extracts the Bash command with jq, and searches the command text against a list of regular expressions. It returns status 2 on a match and 0 otherwise. It does not itself execute the received command, and no network transmission is visible.

View source
scripts/block-dangerous-git.sh:3In the codeOpen original file
INPUT=$(cat)COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
scripts/block-dangerous-git.sh:18In the codeOpen original file
for pattern in "${DANGEROUS_PATTERNS[@]}"; do  if echo "$COMMAND" | grep -qE "$pattern"; then    echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2    exit 2  fidoneexit 0
Start here · InstructionsSKILL.md
git-guardrails-claude-code
Lines connect the instruction file to its sections, not an observed execution order. Select a section to read the source.

File reference map

References: 1
Files making referencesReferenced content
Lines show actual file references, not execution order. Select a node to highlight its connections and inspect the files and source locations. Dashed lines include files that still need locating.
Files and check records3 files

Coverage and gaps

Content covered in each file

These are the source ranges included in this check, not a guarantee that every issue has been resolved.

  • SKILL.mdFull text included
  • scripts/block-dangerous-git.shFull text included
  • agents/openai.yamlFull text included

This report is for the version above. We read the available code and instructions without running the skill or checking extra packages it installs. This is not a promise of safety: a different version or setup may behave differently.

  • SKILL.mdInstructions
  • agents/openai.yamlSupporting file
  • scripts/block-dangerous-git.shScript

Operations mentioned in code and instructions

Run commands
scripts/block-dangerous-git.sh:1In the codeOpen original file
#!/bin/bash
SKILL.md:48In the instructionsOpen original file
      {        "matcher": "Bash",        "hooks": [
SKILL.md:68In the instructionsOpen original file
      {        "matcher": "Bash",        "hooks": [
Lines read
126
File checksum (to compare versions)
4385cfe0137bd62417e104898fd8d830355d06abd173fb663eaf07cdd81feb9a