Claude Code Bash Guardian banner
RoaringFerrum RoaringFerrum

Claude Code Bash Guardian

Security community

Description

Automated security layer for Claude Code PreToolUse Bash Tool hooks. Provides bash command filtering, bypass prevention, and intelligent path control for safe, unattended AI agent sessions.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Code Bash Guardian

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

A security hook for **Claude Code's PreToolUse Bash Tool**. Designed for **unattended agent runs** (non-interactive sessions), it ensures safer automated operations by providing:

  • Robust bash command filtering
  • Advanced bypass prevention
  • Intelligent path access control

**Hook Type:** PreToolUse (Bash Tool) **Operation Mode:** Fully automated, no user interaction **Target Users:** Developers using Claude Code (unattended / automated workflows)

⚠️ Security Disclaimer

**This tool provides defense-in-depth security for Claude Code bash operations, but is not infallible.**

While Claude Code Bash Guardian has been extensively tested against common attack patterns and bypass techniques, no security tool can guarantee 100% protection against all possible threats. Key considerations:

  • Residual Risk: Despite comprehensive testing, false negatives (dangerous commands being allowed) remain theoretically possible due to the complexity of bash syntax and potential zero-day bypass techniques
  • Threat Model: The primary threat actor is an AI agent making mistakes or being prompted inappropriately, not a deliberate attacker with system access
  • Risk-Benefit Analysis: The security benefits of filtering automated agent commands significantly outweigh the residual risks in most development environments
  • Best Practices:
    • Always maintain current backups of critical data and code
    • Use version control (git) to track and revert unwanted changes
    • Run in isolated environments when working with sensitive systems
    • Review logs periodically
    • Test custom configurations thoroughly before production use

This tool is provided "as is" under the MIT License, without warranty of any kind. Users assume all risks associated with its deployment and operation.


🛡️ Security Features

  • **Enhanced Wrapper Command Det