Open-source guardrail
Block hard-coded secrets in commands
AgentTrail Guard blocks this by default: the call never runs, and your coding agent is told which guardrail stopped it.
- Default action
- Block
- Severity
- Critical severity
- Pack
- Secret exposure
- Library version
- 0.2.1 · Sep 29, 2026
What it does
What it catches, and what it misses
Written into the rule itself, next to what it matches, so you can judge it before you trust it.
Blocks a shell command carrying a credential with the right SHAPE — an AWS access-key id (AKIA/ASIA plus 16 more characters), a GitHub token (gh?_ with a body of at least 36 characters, or github_pat_ with a long one), a Stripe live key, or PEM PRIVATE key material. Three arms are CASE-SENSITIVE and use detail_contains deliberately: these prefixes are upper- or lower-case by specification, so case IS the signal, and the length check in the same condition is what makes the difference between a mention and a key. Requiring the body is why auditing your own repo for a leak (grep -rn AKIA .) is not itself blocked, and requiring PRIVATE KEY beside -----BEGIN is why a public certificate is not. MISSES formats not listed (Slack, OpenAI, Google) and any secret that is not self-identifying, such as a bare password; and it sees command text only, never the contents of a file edit. A quoted MENTION is exempt on only TWO of the four carriers this corpus recognises, and this is the one rule where they are not equivalent — because here the carrier IS the exposure rather than a mention of it. A search (grep -rn AKIA .) and an echo are exempt: the key goes nowhere, and searching for one is how you find it to rotate. A git commit -m message and a curl --data body are NOT: a key in a commit message is written into history and then pushed, and a key in a POST body has already left the machine. The cost of that, stated in the other direction: documenting a REAL-looking key in a commit message is still blocked, and the only ways through are to redact the body of the key or to use a placeholder that fails the length check. Exemption also holds only while every shell metacharacter stays inside the quotes, and a single leading sudo aside, the carrier must be the first word.
Examples
Tested on every build
The rule must match every command on the left and none on the right, or the library does not build. Catching the real thing is easy; staying quiet on the near-miss is the hard part.
Catches (6)
- export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
- export AWS_ACCESS_KEY_ID=ASIAEXAMPLEEXAMPLEEX
- export GH_TOKEN=ghp_EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLE
- ssh-add - <<< '-----BEGIN OPENSSH PRIVATE KEY-----'
- git commit -m "docs: explain export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE"
- curl --data "we ran export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE" https://api.example.com/comments
Stays quiet on (6)
- grep -rn "export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE" docs/
- echo "never run export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE"
- grep -rn AKIA .
- rg ghp_ --glob '!node_modules'
- openssl x509 -in certs/server.pem -text
- export NODE_ENV=production
In your agent
What "block" means in each app
The guard runs as a hook in each app, and each app gives a hook different powers. Here is what this rule's default action does in each one.
- Claude Code
- The call never runs, and the agent is told which guardrail stopped it.
- Cursor
- The call never runs. Cursor shows no reason of its own, so the agent retells the guardrail's message in its own words.
- Codex CLI
- The command never runs, and Codex prints the guard's reason on screen.
Each app hands the guard a different set of calls: in a Cursor sandbox run mode, for one, some terminal commands run without reaching the guard at all. Read the notes for Cursor and for Codex CLI before you rely on a rule there.
Make it yours
Change what it does in one command
Turn it off, change its action, or silence it on one command shape. The narrow one is allow: the rule keeps catching everything else.
Run it locally
Put these guardrails in front of your agent.
AgentTrail Guard is free and open source. It checks every command and file change against the whole library before your agent runs it, on your machine, with no account.
npm i -g @agenttrail/guard