Shell command guard
A bounded Claude Code PreToolUse hook that rejects catastrophic filesystem, disk, Git remote, GitHub, credential-store, and internet-to-shell command patterns without executing or rewriting input.
Runs on
Scope
$npx @youdede/toolkit add shell-command-guard --target claude-code
What it does
Block high-confidence destructive shell commands before Claude Code executes them.
When it fires
- implementation
- operations
How it behaves
Evaluate structured runtime input and deterministically allow or block the guarded operation.
It does not execute, rewrite, sanitize, or automatically approve a submitted command.
It does not claim to be a sandbox or a complete shell parser.
It does not provide a hidden bypass for blocked destructive actions.
Configuration
targets/claude-code/shell-command-guard.mjs
- Version
- 1.0.0
- Requires
- node
- Licence
- RiskThis automatic gate blocks high-confidence destructive shell commands before Claude Code executes them; a false denial can interrupt legitimate work, but it does not execute the blocked action.
- Medium
- ModeHow it works: fixed rules, model instructions, or both.
- Deterministic only
- Behaviour
- Enforces, blocks on violation
- On failure
- Denies and blocks
- LatencyThe entrypoint handles one intercepted event to block high-confidence destructive shell commands before Claude Code executes them without deferred work.
- Immediate
- Data retentionWhether data remains after use and who manages its storage.
- Not retained
- In packs
- Daily driver
- Data change safety
- Mobile release readiness
- Release readiness
- Reviewable change
- Secure agent boundaries
Often used with
All in Security