yodaisgaming/claude-code-command-guard — explained in plain English
Analysis updated 2026-05-18
Prevent an AI coding agent from accidentally running rm -rf on important directories.
Block database drop or truncate commands before an agent executes them.
Stop force pushes to a main or default git branch from an AI agent.
Configure custom protected and safe folders for your own projects and production sites.
| yodaisgaming/claude-code-command-guard | 00kaku/gallery-slider-block | 0xkinno/vellum | |
|---|---|---|---|
| Stars | 0 | — | 0 |
| Language | JavaScript | JavaScript | JavaScript |
| Last pushed | — | 2021-05-19 | — |
| Maintenance | — | Dormant | — |
| Setup difficulty | moderate | easy | hard |
| Complexity | 2/5 | 2/5 | 4/5 |
| Audience | developer | general | developer |
Figures from each repo's GitHub metadata at analysis time.
Requires Node.js 18+ and correctly registering an absolute path in Claude Code's settings.json hooks config.
claude-code-command-guard is a small safety tool for Claude Code, an AI coding agent, that steps in before the agent runs a shell command and blocks the ones that could cause serious, unrecoverable damage. Examples include deleting an entire home directory, dropping a database table, wiping a disk, or force pushing over the main branch of a git repository. It works as a single JavaScript file with no external dependencies, plugged into a feature of Claude Code called a PreToolUse hook that runs right before any command executes. The tool is designed around the idea that agents rarely destroy things on purpose. Damage usually happens because a file path expanded incorrectly, a variable was empty, or the model matched the general shape of a command without checking exactly what it targets. To catch this reliably, the guard splits apart compound commands joined with things like double ampersands, and it looks inside commands that run other commands, such as one passed to bash minus c, rather than only checking the surface text. When it cannot confidently understand a command, it denies it by default rather than letting it through, since the author considers a false block far less costly than an accidental deletion. The author is explicit that this tool defends against accidental self inflicted damage from a cooperative agent, not against a determined attacker deliberately trying to hide a dangerous command, which is a different problem needing sandboxing and restricted credentials instead. Out of the box, with no setup, it already blocks deletion of common sensitive locations like the home directory, drive roots, and folders such as dot ssh or dot git, while allowing deletion of known safe build folders like node underscore modules. Users can also define their own protected folders, such as a live production site, and their own safe folders in a small configuration file. Installing it means copying two JavaScript files into a stable location and registering the hook in a Claude Code settings file with the correct absolute path, since the tool warns that a broken or unexpanded path will cause the guard to silently never run. It requires Node.js 18 or later and works on Linux, macOS, and Windows.
A zero-dependency safety hook for Claude Code that blocks destructive shell commands like recursive deletes, database drops, or force pushes before they run.
Mainly JavaScript. The stack also includes JavaScript, Node.js, Claude Code hooks.
Setup difficulty is rated moderate, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.