guard
Stdlib-only safety hooks for Claude Code.
Every decision is logged to JSONL — query and trace in place with guard status|noisy|silent|trace.

$ rm -rf /
guard: deny - rm -rf against /, /*, ~, $HOME, ., or ./ is catastrophic.
Guardrails not walls: guard catches the obvious foot-guns at the Claude Code hook layer so a stray tool call doesn't turn into a bad day. It is defense-in-depth, not a security boundary.
What it does
| Hook | What it catches |
|---|
| bash_command_validator | dangerous shell commands (rm -rf, eval/source, env-var hijack, shell-wrapper bypass) + admin-CLI default-deny for aws/gcloud/az/kubectl/launchctl (only read-only verbs pass) |
| git_c_validator | git -C path traversal, git -c key=value config injection, git commit -C silent message reuse |
| credential_check | hardcoded credentials in tool inputs |
| commit_message_validator | AI-attribution trailers (Co-Authored-By: Claude…) and missing/file-backed commit messages |
| agent_output_guard | reads of subagent transcript files (/tmp/claude-<uid>/.../tasks/*.output); background command output stays readable |
| protected_files | edits to the guard install that's running, its allowlist, and subagent scope, plus your own patterns (lockdown adds agent-instruction, git-hook and MCP config files) |
| subagent_scope | file edits outside the declared .claude/subagent-scope.json allowlist |
| permission_request_logger | observation-only: logs every Claude Code permission prompt as a permission_request JSONL row (no enforcement) |
Install
Inside Claude Code:
/plugin marketplace add TracineHQ/plugins
/plugin install guard@tracine
This installs guard from the unified TracineHQ plugin catalog. The same marketplace also hosts convo; once the marketplace is registered you can install either with one command.
Standalone alternative (skip the catalog and install guard directly from this repo):
/plugin marketplace add TracineHQ/guard
/plugin install guard@tracinehq
TracineHQ/guard is the GitHub owner/repo shorthand for the marketplace source. guard@tracinehq is the <plugin>@<marketplace> reference Claude Code uses to install. To pin a specific tag:
/plugin marketplace add TracineHQ/guard#v1.3.0
Requirements
- Claude Code v2.0.0+ (plugins entered public beta on 2025-10-09)
- Python 3.11+ available on
python3 PATH (no third-party dependencies)
- POSIX shell environment (Linux, macOS, WSL). Windows is not supported in v1 — the matchers target POSIX shell shapes (
rm -rf, cat ~/.aws/credentials, process substitution) and offer no meaningful protection against PowerShell or cmd.exe equivalents. CI runs on ubuntu-latest and macos-latest.
Optional: power-user CLI
The marketplace install above wires up the safety hooks. To query the decision log without tail | jq, install the read-side CLI from PyPI:
pipx install tracine-guard
Then guard status shows the log location and last record, guard noisy --since 24h ranks rules by hit count, guard trace <session_id> dumps a chronological view, and guard silent lists rules that fired historically but not recently. Query subcommands are read-only against ~/.claude/guard-decisions.jsonl; guard allowlist disable-rule / enable-rule and guard mode <mode> write ~/.claude/guard/allowlist.json. The two install paths complement each other; they aren't alternatives.
Configuration
Guard reads a small set of environment variables. See SKILL.md for the canonical descriptions and defaults.
Guard never asks. Every block is a deny whose reason tells the agent what
to do instead: usually stop and tell you, with the command or allowlist
override you can run. You get the context in the conversation, not a
confirm dialog without it.
Healthcheck: guard healthcheck exits 0 on healthy, non-zero on
failure. Suitable for CI gates and cron-based monitors.
Mode (enforce / shadow / off / lockdown): a top-level "mode" field in
~/.claude/guard/allowlist.json, set with guard mode <mode>. Default is
"enforce". One file, one place to look: there are no per-repo overrides,
so a repo you clone can't switch guard off.
Every hook honors the mode: