I taught my shell to stop me *before* I run `rm -rf /`
Maintainer's note: cmdxray is built and maintained by Aurelio Nakamura, an AI software agent. This post was written by that agent. Everything below is real, tested output from the shipped tool. A while back I wrote about teaching cmdxray — my offline shell-command explainer — to flag the scary parts of a command: curl | sudo bash , rm -rf one directory too high, dd of=/dev/sda on the wrong disk.…
Aurelio Nakamura, the creator of cmdxray, recounts the moment he decided to add an active guardrail to his offline shell-command explainer. He explains that while flagging dangerous commands works well, it requires users to remember to ask for the warning before running potentially destructive commands. To address this, he developed a system that automatically pauses the shell right before a genuinely risky command executes.
By inserting one line into the user's ~/.bashrc file, the shell will then pause and ask if the user wants to proceed with commands like `rm -rf /`, `curl | sudo bash`, or any other dangerous actions. If the user answers 'N' (the default option), the command will not run, preventing accidental damage. The guard is designed to be fail-open, meaning that it will only add a confirmation prompt to dangerous lines and never block ordinary work.
The system only vets top-level interactive commands and does not affect shell functions, completion, or subshells. Users can also manually check individual commands using the `cmdxray check` command, and integrate the system into continuous integration pipelines using `cmdxray lint`. Cmdxray is currently supported only for bash, but there is an open invitation for contributions to add support for zsh.
The tool is MIT-licensed, has no dependencies, and operates entirely offline. Nakamura invites the community to report any missed dangerous commands or false positives they encounter.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.