Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Run automatically on Claude Code events. Claude doesn't decide.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Safety checks for Bash commands in Claude Code - prevents dangerous operations, enforces timeouts, blocks commits to protected branches, and rate limits BashOutput polling.
bash-guard is a PreToolUse hook plugin that intercepts Bash and BashOutput tool calls before execution, checking them against configurable safety rules. It acts as a safety net to prevent dangerous commands, enforce git workflow conventions, ensure adequate timeouts for long-running operations, and prevent excessive polling of background processes.
Hook Type: PreToolUse (Bash, BashOutput)
Blocks Execution: Yes
Configuration File: bash-guard.json
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
Block dangerous commands with customizable patterns and helpful explanations:
Prevent direct commits to protected branches:
git commit on main/master branches by defaultEnsure minimum timeouts for long-running commands:
Prevent specific commands from running in background:
poe test from running with run_in_background: truePrevent excessive polling of background process output:
bash-guard can suggest command modifications instead of just blocking:
Current Status: Suggestion mode is enabled by default (use_updated_input: false)
The plugin uses Claude Code's updatedInput feature to modify commands before execution. However, this feature is currently broken in Claude Code v2.0.34 (see GitHub issue #4368). When disabled (default), the plugin blocks commands but provides detailed suggestions showing exactly what needs to be fixed.
Example Suggestion Output:
• Command needs modifications:
• Auto-setting timeout to 5 minutes for this command
• Reason: pytest requires at least 5 minutes for comprehensive test execution
•
• Suggested command:
• pytest tests/
• timeout: 300000
When the bug is fixed, you can enable auto-fix by setting use_updated_input: true in your configuration. The plugin will then automatically apply modifications instead of blocking with suggestions.
# Add the marketplace (if not already added)
/plugin marketplace add /data/ssd/sync/workspace/src/claude-code-plugins
# Install bash-guard
/plugin install bash-guard@werdnum-plugins
# Verify installation
/plugin list
The plugin works immediately after installation with sensible defaults. No configuration required!
What's protected by default:
# ❌ Blocked: Dangerous system commands
rm -rf /
mkfs.ext4 /dev/sda
chmod -R 777 /
# ❌ Blocked: Git commits to main branch
git checkout main
git commit -m "Fix"
# ❌ Blocked: Insufficient timeouts
pytest # Requires timeout: 300000 (5 minutes)
poe test # Requires timeout: 900000 (15 minutes)
# ❌ Blocked: Background execution
poe test # With run_in_background: true
# ✅ Allowed: Safe operations
pytest tests/unit/ # With timeout: 300000
git checkout -b feature/my-feature
git commit -m "Add feature"
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub werdnum/claude-code-plugins --plugin bash-guardPlugins from other owners that cover similar ground