AI coding agents can edit files, run shell commands, and touch infrastructure. One bad rm -rf, force-push, or docker compose down -v can wipe hours of work or production data.
This is a pattern, not a native Claude Code plugin.
Before approving a shell tool call, ask Claude Code (or a wrapper script) to run:
agent-guard check --json "<proposed command>"
Interpret:
decision | Suggested agent behavior |
|---|---|
| ALLOW | Proceed |
| WARN | Ask the human / show reason |
| BLOCK | Refuse; propose a safer alternative |
Exit codes: 0 / 10 / 20.
Replace direct bash execution with:
agent-guard run -- <command> [args...]
WARN prompts the human (default N). Non-interactive sessions need --allow-risk for WARN only. BLOCK never runs.
cd your-project
agent-guard init
agent-guard scan
Commit .agent-guard.yml so agents and humans share the same policy.
run -- git status over nested shells.