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.
| 1 | # Shell integration |
| 2 | |
| 3 | ## Alias (advisory) |
| 4 | |
| 5 | ```bash |
| 6 | # ~/.bashrc or ~/.zshrc |
| 7 | agcheck() { |
| 8 | agent-guard check "$@" |
| 9 | } |
| 10 | ``` |
| 11 | |
| 12 | ## Enforcing wrapper |
| 13 | |
| 14 | ```bash |
| 15 | #!/usr/bin/env bash |
| 16 | # ag-run — evaluate then execute |
| 17 | set -euo pipefail |
| 18 | exec agent-guard run -- "$@" |
| 19 | ``` |
| 20 | |
| 21 | Usage: |
| 22 | |
| 23 | ```bash |
| 24 | chmod +x ag-run |
| 25 | ./ag-run git status |
| 26 | ./ag-run npm test |
| 27 | ``` |
| 28 | |
| 29 | ## Agents / CI |
| 30 | |
| 31 | In CI, prefer `agent-guard check` (analysis only). Do not enable interactive WARN prompts. |
| 32 | |
| 33 | ```bash |
| 34 | agent-guard check --json "$CMD" |
| 35 | case $? in |
| 36 | 0) echo ALLOW ;; |
| 37 | 10) echo WARN; exit 1 ;; |
| 38 | 20) echo BLOCK; exit 1 ;; |
| 39 | *) exit 30 ;; |
| 40 | esac |
| 41 | ``` |
| 42 | |
| 43 | ## PowerShell |
| 44 | |
| 45 | ```powershell |
| 46 | agent-guard check "Remove-Item -Recurse -Force .\src" |
| 47 | agent-guard run -- python -c "print('ok')" |
| 48 | ``` |
| 49 | |
| 50 | Always prefer `agent-guard run -- prog arg1 arg2` so argv is not re-parsed by an outer shell when avoidable. |