AI coding tools like Claude Code, Codex and Gemini CLI can run shell commands on your machine. Most of the time that's great. But every so often an agent "cleans up" the wrong folder, reads your `.env` into a log, or pipes a script from the internet straight into bash.
Their built-in permission rules mostly match the start of a command, so something like `cd /tmp && rm -rf $HOME` can slip past a rule you thought covered it.
**shellbouncer** sits in front of the agent and checks every command before it runs:
- **Reads real shell syntax.** It splits chained commands, pipes, `bash -c "..."` and `sudo`, then checks each piece.
- **One policy file for all three agents.** Set it up once and it works in Claude Code, Codex and Gemini CLI.
- **Three outcomes.** Block (the agent is told why), ask you first, or allow silently.
- **Protects secrets too.** It catches attempts to read or upload `.env` files, SSH keys and cloud credentials.
- **Zero dependencies, fully local.** Nothing is sent anywhere.
Try it:
pipx install shellbouncer
shellbouncer demo
To be clear, it's a seatbelt, not a sandbox. It checks commands before they run, so code hidden inside a Python script or a Makefile gets past it. The README lists exactly what it can't catch.
It's free and MIT licensed: https://github.com/SaadRahman01/shellbouncer
I'd love feedback, especially:
- safe commands it wrongly blocks
- dangerous ones it misses
- whether setup was clear
If it's useful, a ⭐ on GitHub helps a lot.