ValGuard CLI
valguard runs deterministic validator rules against known-good and known-bad fixtures on your machine and in CI. It does not call a model, does not start a proxy, and does not need a ValGuard account.
The hosted product still sits on the request path for production agents (routing, playbooks, budgets, shadow mode, request proof). The CLI covers the part you can gate before merge: do these rules still catch the failures we care about?
Repo: github.com/valguard-ai/valguard. Docs sibling: How to test validators in CI/CD. The binary name is valguard. The PyPI distribution name is valguard-cli, and its console script is also valguard.
When to use which path
| Goal | Tool |
|---|---|
| Offline fixture regression, no network | valguard test |
Hosted CI against a staging agent (/internal/test-validators) | CI tutorial |
| Runtime enforcement on live LLM traffic | Hosted ValGuard (or Enterprise self-host) |
| Offline verify of a Growth+ HMAC proof envelope | valguard verify-proof (proof tutorial) |
HMAC-signed request evidence (Proof panel, export, offline verify) is Growth+ (Growth, Production, and Enterprise). The free CLI fixture runner is not proof of production enforcement.
Install
Release v0.1.3 on GitHub Releases. Pick one path — you do not need Go unless you use go install.
Linux or macOS (recommended)
Installs to ~/.local/bin and checks the archive against checksums.txt.
curl -fsSL https://raw.githubusercontent.com/valguard-ai/valguard/main/scripts/install.sh | bash valguard version
Other one-liners
| Command | What it does |
|---|---|
| brew install valguard-ai/tap/valguard | macOS (Homebrew; installs from valguard-ai/homebrew-tap) |
| pip install valguard-cli | Python on any OS; console script is still valguard |
| go install github.com/valguard-ai/valguard/cmd/valguard@v0.1.3 | Go 1.26+; builds from the public module |
pip install valguard is an unrelated PyPI project. The wrapper valguard-cli verifies downloads with checksums.txt on first run. Windows: use Homebrew on WSL, pip install valguard-cli, or go install. Tarballs and zip files are on Releases.
Quick start
1. Describe the policy in valguard.yaml. Rule IDs match the hosted catalog. v0.1 policy fields are version (must be 1), name, optional mode (enforce or shadow, default enforce), and rules. Each rule has id, optional params, and optional on_fail (block, warn, or log). This is the invoice example from examples/invoice/valguard.yaml:
version: 1
name: invoice_agent
mode: enforce
rules:
- id: valid_format
params:
format: json
on_fail: block
- id: required_fields
params:
fields: ["total", "currency"]
on_fail: block
- id: non_negative
params:
fields: ["total"]
on_fail: block2. valguard check validates one response against that file. valguard test does not take --policy. It reads a directory of JSON files, and each file embeds its own policy. That shape is not the fixtures.json array in the CI tutorial. One case looks like this:
{
"name": "required_fields blocks missing key",
"policy": {
"version": 1,
"name": "req",
"mode": "enforce",
"rules": [
{ "id": "valid_format", "params": { "format": "json" }, "on_fail": "block" },
{ "id": "required_fields", "params": { "fields": ["total"] }, "on_fail": "block" }
]
},
"output": "{\"currency\": \"USD\"}",
"input_text": "",
"expect_blocked": true,
"expect_would_enforce": true,
"expect_failed_rules": ["required_fields"]
}3. Run:
valguard check --policy valguard.yaml --file response.json cat response.json | valguard check --policy valguard.yaml valguard test --dir conformance/fixtures
check prints pass, blocked, or would block (shadow). With --json it prints the result object instead. A blocked enforce result, or a shadow result that would enforce, exits 1. A bad policy file, an unreadable input, or an output over 4 MiB exits 2. test prints nothing when every fixture matches. A mismatch exits 1 and names the file on stderr. A missing directory exits 2.
A worked policy and sample output live in the repo under examples/invoice/. Fixture files live under conformance/fixtures/.
Commands (v0.1)
| Command | What it does |
|---|---|
| init [--path valguard.yaml] | Writes a sample policy. Exits 2 if the file already exists. |
| check [--policy valguard.yaml] | Validates one response from --file, --output, or stdin. |
| test [--dir conformance/fixtures] | Runs each *.json fixture in the directory. Policy is inside the file. |
| verify-proof --file envelope.json | Verifies a downloaded Growth+ evidence envelope offline. |
| rules list | Prints the 40 offline rule IDs, one per line. |
| rules explain <rule-id> | Prints id, category, description, and doc URL. --json for the object. |
| report --shadow | Builds a shadow report. --format is markdown (default), junit, or json. |
| export [--policy valguard.yaml] | Writes a playbook-template JSON fragment for dashboard import. |
| version | Prints 0.1.3. |
The format flag exists only on report --shadow (markdown, junit, or json). check uses --json. verify-proof and test print their own fixed text. report --shadow exits 0 when it can write the file, including when rules would block. Use valguard test as the merge gate.
Exit 2 on check and test means usage or config (missing policy, bad YAML, missing fixture directory, input over the limit). Exit 1 means a fixture mismatch or a response that blocks. verify-proof uses a different split. See exit codes below. A missing evidence secret is not exit 2.
Rules in v0.1
v0.1 ships 40 rules that run fully offline, with no model and no network. That is a subset of the 160 built-in hosted validators. valguard rules list prints this set. Links below go to a public rule page when one exists.
- valid_format
- json_schema_validate
- required_fields
- type_checking
- enum_validator
- json_no_extra_fields
- no_duplicate_json_keys
- json_max_depth
- list_length
- output_shape
- regex_pattern
- forbidden_patterns
- max_length
- min_length
- no_markdown_fenced_wrapper
- code_block_balanced
- no_placeholder_text
- no_truncation_markers
- range_validator
- numeric_consistency
- line_item_math_valid
- cross_field_logic
- decimal_precision_max
- non_negative
- amount_requires_currency
- pii_detection
- pii_pesel
- pii_nip
- pii_ssn_us
- valid_iban
- valid_credit_card_luhn
- masked_card_only
- valid_email_rfc5322
- secrets_detection
- no_system_prompt_leakage
- no_role_marker_leakage
- no_thinking_tag_leakage
- no_stack_trace_leak
- prompt_injection
- internal_network_url
Passing these rules means the configured checks did not block. It does not mean the answer is true, complete, or useful. Heuristic rules catch patterns, not intent. See Trust.
Use in CI
# .github/workflows/validators.yml
name: validator tests
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26"
- run: go install github.com/valguard-ai/valguard/cmd/valguard@v0.1.3
- run: valguard test --dir conformance/fixturesPrefer the CLI when fixtures and policy live in the same repo and you want a merge gate with no staging credentials. Prefer the hosted CI tutorial when you need the exact agent configuration that already runs in ValGuard, including rules that are not in the offline set of 40. The hosted tutorial uses /internal/test-validators. A separate monorepo helper, valguard-cli, calls that endpoint over the network. It is not this offline binary.
Verify a proof (verify-proof)
verify-proof checks a ValGuard validation proof on your machine. You pass a JSON evidence envelope downloaded from a Growth+ Proof panel or from a Settings export. The command runs offline. It does not call an API and it does not need a ValGuard account.
The envelope is HMAC-SHA256 signed. The signed payload string includes the policy snapshot hash, the engine version (default valguard-engine/1), ordered validator verdicts, and SHA-256 digests of the request and the response. It does not store the raw prompt or the completion. A matching signature means that payload is intact for this deployment secret and key_id. It does not mean absolute non-repudiation. It is not a compliance certificate.
HMAC-signed proofs exist only on the Growth plan and above (Growth, Production, and Enterprise). The Proof panel and export also need analytics, which starts on Growth. The free fixture commands test and check are not proof that rules ran in production.
Full UI steps: How to verify guardrail proof. Claim language: How to prove AI guardrails actually executed.
Usage
Keep the downloaded file as it is. The signature covers the exact payload string. The CLI does not re-marshal it. Do not pretty-print that string and do not reorder its keys.
export EVIDENCE_HMAC_SECRET="your-deployment-secret" valguard verify-proof --file envelope.json
The CLI uses the same secret resolution as the hosted product. Set EVIDENCE_HMAC_SECRET first. If it is unset, the command falls back to OUTBOUND_WEBHOOK_HMAC_SECRET. Use the secret from the same deployment that signed the envelope. --file -, or omitting --file, reads the envelope from stdin.
Flags
| Flag | What it does |
|---|---|
| --file <envelope.json> | Path to the downloaded evidence envelope. - or an empty value reads stdin. |
--file is the only flag. verify-proof does not honor --format. An unknown flag is a usage error from the flag parser (exit 2). junit is not a verify-proof format.
Success output
When the signature matches, the command exits 0 and prints one word. It does not print key_id, engine version, or the policy snapshot hash. Those fields stay inside the envelope.
ok
Missing key
If neither secret is set and ENV is not production, the command does not exit with a missing-key error. It verifies against the built-in development secret. A production envelope will not match, so you get a signature mismatch (exit 1) instead of a config error.
If ENV=production and neither secret is set, the command exits 1 and prints:
EVIDENCE_HMAC_SECRET or OUTBOUND_WEBHOOK_HMAC_SECRET is required in production
If ENV=production and the chosen secret is the development placeholder, the command exits 1 and prints EVIDENCE_HMAC_SECRET must not use the development placeholder in production (or the same sentence for OUTBOUND_WEBHOOK_HMAC_SECRET).
Exit codes
| Code | Meaning |
|---|---|
| 0 | Signature matches. Stdout is ok. |
| 1 | Signature does not match (evidence signature mismatch). The secret may be wrong, the payload string may have been changed, or the key id may not match. The same code is used when the file cannot be read, and when ENV=production rejects a missing or placeholder secret. |
| 2 | The envelope is not valid JSON (invalid JSON envelope:), or it is missing key_id, payload, or signature. An unknown flag is also exit 2. |
Treat a failed signature as an incident, not as a soft warning.
What it does not do
- No OpenAI-compatible proxy, no playbooks, no budgets, no model calls
- No dashboard and no data storage
- No telemetry. check, test, report, export, and verify-proof make no network calls
- Not a substitute for hosted shadow mode or Enterprise self-host when you need runtime enforcement on live traffic