Prevent an AI coding agent from accidentally running sudo or destructive commands
Block rm, mv, or rsync commands that target paths outside the current project
Add a safety checkpoint before shell commands in Claude Code, Codex CLI, or Devin CLI
Adapt the hook for other agents that support JSON-based command hooks
| dabit3/bash-guard | fivetaku/fablize | chitransh-cj/kimchi | |
|---|---|---|---|
| Stars | 43 | 43 | 42 |
| Language | Shell | Shell | Shell |
| Setup difficulty | easy | easy | easy |
| Complexity | 2/5 | 2/5 | 2/5 |
| Audience | developer | developer | vibe coder |
Figures from each repo's GitHub metadata at analysis time.
Only needs Bash and jq, setup is copying a script and editing one JSON config file.
Bash Guard is a small safety hook that stops risky shell commands before an AI coding agent gets to run them. It works with agents that support a PreToolUse hook, which is a checkpoint that runs right before a tool executes, including Claude Code, Codex CLI, and Devin CLI. Instead of trusting the agent to always run safe commands, this script sits in front of the terminal and checks each one first. It blocks two kinds of commands. First, anything that uses sudo, diskutil, or mkfs, which are commands that can change system-level settings or reformat storage. Second, destructive commands like rm, mv, rsync, or shred, but only when they are pointed at paths outside the current project folder, so normal file operations inside your project still work fine. To install it, you copy the bash-guard.sh script into a local folder and make it executable. Then you add a small JSON snippet to your coding agent's configuration file, telling it to run this script before every shell command. The exact configuration file and matcher pattern differ slightly by agent: Claude Code, Codex CLI, and Devin CLI each have their own settings file and hook format, and the README lists all three. After updating the configuration, you restart the agent, and in Codex CLI you also need to open its hooks menu to trust the new hook. Once installed, Bash Guard runs automatically and silently for every command the agent tries to run. Safe commands pass through without any change in behavior. Blocked commands are rejected with an explanation instead of running. The tool only requires Bash and the jq command-line JSON processor, so there is nothing else to install. It can also be adapted by other agents that pass command and working-directory information as JSON and respect a blocking exit status.
A shell hook that blocks risky commands like sudo, rm, or mkfs before AI coding agents can run them.
Mainly Shell. The stack also includes Shell, Bash, jq.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
double-check against the repo, no cap.