Stdlib-only safety hooks plugin for Claude Code
Project description
guard
Stdlib-only safety hooks for Claude Code.
$ 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) |
| 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 | malformed/missing commit messages |
| agent_output_guard | oversized raw-data reads in subagent output |
| protected_files | edits to user-marked protected files |
| subagent_scope | subagent edits outside declared scope |
Install
/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.0.0
Requirements
- Claude Code v2.0.0+ (plugins entered public beta on 2025-10-09)
- Python 3.11+ available on
python3PATH (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 orcmd.exeequivalents. CI runs onubuntu-latestandmacos-latest.
Configuration
Guard reads a small set of environment variables. See SKILL.md for the canonical descriptions and defaults.
| Variable | Purpose |
|---|---|
CLAUDE_AUTONOMOUS |
Strict default-deny in subagents / driven runs |
GUARD_DECISIONS_PATH |
Override the JSONL decision-log path |
GUARD_AUTONOMOUS_QUEUE_PATH |
Override the autonomous-deny queue path |
GUARD_DEBUG |
Emit per-hook debug to stderr |
GUARD_DATA_DIR |
Override guard's data directory |
To disable an individual hook, remove its entry from ~/.claude/settings.json PreToolUse, or comment the line in hooks/hooks.json if you forked the plugin.
What it doesn't do
- Not a security boundary. A determined attacker who controls input to Claude Code can bypass any client-side hook.
- Defense-in-depth, not an exclusive safety mechanism.
- Logs decisions for observability; doesn't enforce server-side.
Output log
Every decision is appended to ~/.claude/guard-decisions.jsonl (NDJSON, one record per line). The schema is stable and documented in docs/JSONL_FORMAT.md.
Tail and pretty-print:
tail -f ~/.claude/guard-decisions.jsonl | jq
Or use the built-in guard CLI for read-side queries:
guard status # installation status + log location + line count
guard noisy --since 7d # top hit rules in the last week
guard silent --since 30d # rules that haven't fired in 30 days
guard trace <session-id> # all records for a single session
guard test "<command>" # what would each hook decide?
guard diff # effective merged config (stub)
Development
just check
Runs lint, typecheck, and tests. See CONTRIBUTING.md for setup, test tiers, and commit conventions.
Known limitations
Guard is defense-in-depth, not a security boundary. The validators trade exhaustive coverage for low false-positive rates and stdlib-only portability, which means a determined attacker who controls Claude Code's input can bypass any client-side hook. Pattern-matching is conservative on purpose: rules deny shapes that have a clear safer alternative and pass shapes that are ambiguous. For the threat model, the disclosure process, and a list of areas guard explicitly does not cover, see SECURITY.md.
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracine_guard-1.0.0rc2.tar.gz.
File metadata
- Download URL: tracine_guard-1.0.0rc2.tar.gz
- Upload date:
- Size: 184.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42b518d8507cc3fc4fad208384b1701e5d7a54ca6e6a1cdc98e7ea3cc184b9be
|
|
| MD5 |
74ab48d332f3c507963c4095a3b44d2e
|
|
| BLAKE2b-256 |
67833efc9c84cfa71948000179d77cfd7183353c953662b4ea8e8d5696ed2c31
|
Provenance
The following attestation bundles were made for tracine_guard-1.0.0rc2.tar.gz:
Publisher:
release.yml on TracineHQ/guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracine_guard-1.0.0rc2.tar.gz -
Subject digest:
42b518d8507cc3fc4fad208384b1701e5d7a54ca6e6a1cdc98e7ea3cc184b9be - Sigstore transparency entry: 1429973472
- Sigstore integration time:
-
Permalink:
TracineHQ/guard@e61b392e647dd2428fb16b5b508ff446ad734ec6 -
Branch / Tag:
refs/tags/v1.0.0rc2 - Owner: https://github.com/TracineHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e61b392e647dd2428fb16b5b508ff446ad734ec6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tracine_guard-1.0.0rc2-py3-none-any.whl.
File metadata
- Download URL: tracine_guard-1.0.0rc2-py3-none-any.whl
- Upload date:
- Size: 85.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c3f4e356ace991e08478e50996de91b880a848445cc038fb87aeebb6bbbb926
|
|
| MD5 |
a5ec9df91d6165b46f85e740b9f4d4ef
|
|
| BLAKE2b-256 |
dab7419e6b4b9f78923ead67a5005de4a01d1dc5c547a4e8db2b1c35786f9a0e
|
Provenance
The following attestation bundles were made for tracine_guard-1.0.0rc2-py3-none-any.whl:
Publisher:
release.yml on TracineHQ/guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracine_guard-1.0.0rc2-py3-none-any.whl -
Subject digest:
7c3f4e356ace991e08478e50996de91b880a848445cc038fb87aeebb6bbbb926 - Sigstore transparency entry: 1429973474
- Sigstore integration time:
-
Permalink:
TracineHQ/guard@e61b392e647dd2428fb16b5b508ff446ad734ec6 -
Branch / Tag:
refs/tags/v1.0.0rc2 - Owner: https://github.com/TracineHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e61b392e647dd2428fb16b5b508ff446ad734ec6 -
Trigger Event:
push
-
Statement type: