DOCS
CLI reference
The binary is balerx. These are the commands it accepts.
| Command | Purpose |
|---|---|
scan | Scan the system for AI agents and security issues |
lock | Generate or update agent lockfile |
diff | Show diff between current state and lockfile |
guard | Guard hooks management |
hook | Hook handler (called by agent hooks) |
log | Activity log management |
canary | Canary credential management |
upload | Upload scan results or Guard activity-log metadata to a Monitor project |
setup | Choose a local Guard policy and write ~/.balerx/policy.yaml. Offline |
policy | Manage the local Guard policy. Offline unless you explicitly pull |
uninstall | Remove Guard hooks for Claude Code and Cursor. Offline |
doctor | Show version, data directory, Guard hooks, and policy. Parses the policy file. Empty or invalid YAML exits 1. Does not use the network |
completions | Print a shell completion script |
version | Print this version |
self-update | Print the install command for this OS |
help | Print this message or the help of the given subcommand(s) |
Flags for each command are below. This block is generated from the CLI. If a flag is not listed, the command does not accept it.
Update check
balerx --version, balerx -V, balerx version, balerx doctor, balerx completions, and balerx self-update do not use the network. balerx doctor parses policy.yaml and exits 1 when that file is empty or invalid.
balerx version --check and balerx self-update --check send one HTTPS GET to https://api.github.com/repos/wrjewski/balerx/releases/latest. The request times out after 5 seconds. The User-Agent is balerx/<version>. No account, machine, or scan data is sent. Drafts and pre-releases are ignored.
This release is 0.1.8. An up-to-date build prints balerx 0.1.8 is up to date. A build newer than the latest published release prints balerx 0.1.8 is ahead of the latest release (0.1.7), with the published version in parentheses. A newer stable release prints the install command self-update already prints, then the release notes URL. That command matches this OS: curl and sh on macOS and Linux, PowerShell and install.ps1 on Windows. The Windows command includes -ExecutionPolicy Bypass for that one installer process. The numbers below are an example of that message on macOS or Linux, with 0.1.9 standing in for a later release:
A new version is available: 0.1.9 (you have 0.1.8). Update: curl -fsSL https://raw.githubusercontent.com/wrjewski/balerx/main/install.sh -o install.sh && sh install.sh
Release notes: https://github.com/wrjewski/balerx/releases/tag/v0.1.9On Windows the Update: line is:
A new version is available: 0.1.9 (you have 0.1.8). Update: Invoke-WebRequest "https://raw.githubusercontent.com/wrjewski/balerx/main/install.ps1" -OutFile install.ps1; powershell -ExecutionPolicy Bypass -File .\install.ps1The check does not download or replace the binary. If GitHub is unreachable, rate-limits the request, or the call times out, the command prints the reason and exits 0.
--json prints one object. On version, --json without --check prints only current and stays offline. On self-update, --json requires --check. The text is plain. --no-color and NO_COLOR do not add color. install_command is the same OS-specific string.
balerx version --check
balerx self-update --check --json{
"current": "0.1.8",
"latest": "0.1.9",
"update_available": true,
"release_url": "https://github.com/wrjewski/balerx/releases/tag/v0.1.9",
"install_command": "curl -fsSL https://raw.githubusercontent.com/wrjewski/balerx/main/install.sh -o install.sh && sh install.sh",
"message": "A new version is available: 0.1.9 (you have 0.1.8). Update: curl -fsSL https://raw.githubusercontent.com/wrjewski/balerx/main/install.sh -o install.sh && sh install.sh",
"ok": true
}On Windows, install_command and message use Invoke-WebRequest "https://raw.githubusercontent.com/wrjewski/balerx/main/install.ps1" -OutFile install.ps1; powershell -ExecutionPolicy Bypass -File .\install.ps1 in place of the curl/sh command.
Setup banner
balerx setup and balerx policy init print a Balerx Gate banner before the checklist. A color terminal at least 70 columns wide shows the dragon mark beside a large BALERX GATE wordmark, the tagline Security for AI agents, and the version. The wordmark runs from #8e1024 to #b0122e, the brand reds from the site theme. A narrower terminal prints one line: a small dragon glyph, Balerx Gate, and the version.
COLORTERM=truecolor or COLORTERM=24bit uses 24-bit color. Other color terminals use 256 colors. Width comes from COLUMNS, then the terminal size. On Windows, the block glyphs are used when Windows Terminal, VS Code, or ConEmu is the host. NO_COLOR, --no-color, and a pipe print plain text with no ANSI codes:
Balerx Gate
Security for AI agents
v0.1.8balerx scan, balerx hook, --help, --version, and machine-readable output (--json, SARIF, HTML, and hook stdout) leave the banner out, so hooks and CI can parse that output. The installers print the same banner on the Installed screen, then the next steps. They do not run balerx setup.
Uninstall
balerx uninstall removes Balerx hook commands from Claude Code and Cursor. A command matches when it contains balerx and hook and it runs the balerx binary, or balerx.exe, with a separate hook argument. my-balerx-webhook.sh stays. Empty hook lists left behind are removed. The command prints every path and asks before it changes anything. --yes skips the question. A pipe without --yes changes nothing and prints Run: balerx uninstall --yes and Run: balerx uninstall --purge --yes. --purge also deletes known files only: policy.yaml, policy.yaml.bak copies, planted canary files in ~/.balerx/canaries, canaries.json, and logs/activity.jsonl. Unknown files stay. A directory is removed only when it is empty afterward and its name is .balerx or balerx. A custom BALERX_DATA_DIR is never removed wholesale. Purge exits nonzero when the home directory or the data directory is not an absolute path.
Without --purge the command keeps ~/.balerx and the activity log and prints Policy and logs stay. Pass --purge to delete them. On macOS and Linux, $HOME/.local/bin/balerx is removed only when that file is the running binary. On Windows the command does not delete the running balerx.exe. It prints Remove-Item -Recurse -Force "$env:LOCALAPPDATA\balerx" and the PowerShell that drops that folder from the user Path and the current process Path. The command stays offline.
balerx guard uninstall claude-code and balerx guard uninstall cursor still remove one agent's hooks without asking, and they do not touch policy, logs, or the binary.
Guard status
balerx guard status prints the Claude Code and Cursor hook files, fail_open, timeout_ms, and the activity log path. An empty or invalid policy file is reported as fail-closed instead of showing the built-in default. A fresh install exits 0 and prints:
Not installed — run: balerx guard install claude-code
Not installed — run: balerx guard install cursorbalerx guard status --strict and balerx guard status --check exit 1 when no hook is installed. Use that in a CI script. A machine that already has one of those hooks exits 0, unless the recorded hook binary is missing or not executable: then guard status and doctor exit non-zero and say so. PowerShell & "..." paths are unescaped; a POSIX hook command whose binary directory contains a backtick is checked as stored.
balerx --help
Balerx Gate - Security scanner for AI coding agents
Usage: balerx [OPTIONS] <COMMAND>
Commands:
scan Scan the system for AI agents and security issues
lock Generate or update agent lockfile
diff Show diff between current state and lockfile
guard Guard hooks management
uninstall Remove Guard hooks for Claude Code and Cursor. Offline
hook Hook handler (called by agent hooks)
log Activity log management
canary Canary credential management
upload Upload scan results or Guard activity-log metadata to a Monitor project
setup Choose a local Guard policy and write ~/.balerx/policy.yaml. Offline
policy Manage the local Guard policy. Offline unless you explicitly pull
doctor Show version, data directory, Guard hooks, and policy. Parses the policy file. Empty or invalid YAML exits 1. Does not use the network
completions Print a shell completion script
version Print this version
self-update Print the install command for this OS
help Print this message or the help of the given subcommand(s)
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
-V, --version Print version
Common commands:
balerx scan
balerx setup
balerx guard install claude-code
balerx guard install cursor
balerx guard status
balerx uninstall
balerx doctor
balerx self-update --check
Docs: https://balerxgate.com/docs/cli
Guard is a guardrail, not a sandbox.
balerx scan --help
Scan the system for AI agents and security issues
Usage: balerx scan [OPTIONS] [PATH]
Arguments:
[PATH] Project directory or a single config file to scan
Options:
--format <FORMAT> Write the report to stdout as json, sarif, or text [possible values: json, sarif, text]
--no-color Disable color. Same as setting `NO_COLOR`
--fail-on <SEVERITY> Exit 1 when a finding is at or above this severity [possible values: critical, high, medium, low, info]
--fail-on-unreadable Exit 1 when a config file could not be read
--json <FILE> Output JSON to file
--sarif <FILE> Output SARIF to file
--html <FILE> Output HTML report to file
-q, --quiet Quiet mode - only output files, no terminal
--exclude <PATH> Skip findings under this path or glob (`**/.cursor/**`). Repeat the flag to skip more than one
--baseline <FILE> JSON file of findings to hide. `rule_id` is the SARIF code (`MCP-REMOTE-001`); the old Rust name still matches. Shape: `{"ignore":[{"rule_id":"...","resource":"..."}]}`
--write-baseline <FILE> Write current findings as a baseline JSON file. `rule_id` is the SARIF code
-h, --help Print help
balerx lock --help
Generate or update agent lockfile
Usage: balerx lock [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-o, --output <OUTPUT> Output lockfile path [default: balerx.lock]
-h, --help Print help
balerx diff --help
Show diff between current state and lockfile
Usage: balerx diff [OPTIONS]
Options:
-l, --lockfile <LOCKFILE> Lockfile to compare against [default: balerx.lock]
--no-color Disable color. Same as setting `NO_COLOR`
--fail-on <SEVERITY> Exit 1 when a drift is at or above this severity [possible values: critical, high, medium, low, info]
-h, --help Print help
balerx guard --help
Guard hooks management
Usage: balerx guard [OPTIONS] <COMMAND>
Commands:
install Install guard hooks for an agent
uninstall Uninstall guard hooks for an agent
status Show whether Guard hooks are installed
help Print this message or the help of the given subcommand(s)
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx guard install --help
Install guard hooks for an agent
Usage: balerx guard install [OPTIONS] <AGENT>
Arguments:
<AGENT> Agent type to install hooks for [possible values: claude-code, cursor]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx guard uninstall --help
Uninstall guard hooks for an agent
Usage: balerx guard uninstall [OPTIONS] <AGENT>
Arguments:
<AGENT> Agent type to uninstall hooks for [possible values: claude-code, cursor]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx guard status --help
Show whether Guard hooks are installed
Usage: balerx guard status [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
--strict Exit 1 when no hook is installed [alias: --check]
-h, --help Print help
balerx hook --help
Hook handler (called by agent hooks)
Reads at most 1 MB of stdin. A larger body returns ask. A missing policy file uses the built-in default. An empty or unreadable policy file fails closed with ask. The `timeout_ms` wait starts when the evaluation thread is spawned after stdin is read, not at process start. A timeout asks. A stdin that never closes can still hang. A completed deny or ask is kept even after that budget. An evaluation that does not finish asks, regardless of `fail_open`. `fail_open` chooses allow or deny only after invalid JSON or an internal error, and that allow is written to the activity log and stderr.
Usage: balerx hook [OPTIONS] --event-type <EVENT_TYPE>
Options:
--event-type <EVENT_TYPE>
Event type
--no-color
Disable color. Same as setting `NO_COLOR`
-h, --help
Print help (see a summary with '-h')
balerx log --help
Activity log management
Usage: balerx log [OPTIONS] <COMMAND>
Commands:
view View recent activity
help Print this message or the help of the given subcommand(s)
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx log view --help
View recent activity
Usage: balerx log view [OPTIONS]
Options:
-l, --limit <LIMIT> Number of entries to show [default: 50]
--no-color Disable color. Same as setting `NO_COLOR`
-a, --agent <AGENT> Filter by agent name
-t, --event-type <EVENT_TYPE> Filter by event type
-h, --help Print help
balerx canary --help
Canary credential management
Usage: balerx canary [OPTIONS] <COMMAND>
Commands:
plant Plant a canary credential. Refuses to overwrite an existing file unless --force is passed. Symbolic links and symlinked parent directories are always refused, even with --force
remove Remove a canary credential
list List all planted canaries
check Check if a path is a canary
help Print this message or the help of the given subcommand(s)
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx canary plant --help
Plant a canary credential. Refuses to overwrite an existing file unless --force is passed. Symbolic links and symlinked parent directories are always refused, even with --force
Usage: balerx canary plant [OPTIONS] <CANARY_TYPE>
Arguments:
<CANARY_TYPE> Type of canary to plant [possible values: aws, env, ssh, generic]
Options:
-l, --location <LOCATION> Location to plant the canary
--no-color Disable color. Same as setting `NO_COLOR`
-f, --force Overwrite existing file if it exists. Symbolic links and symlinked parent directories are always refused, even with --force
-h, --help Print help
balerx canary remove --help
Remove a canary credential
Usage: balerx canary remove [OPTIONS] <CANARY_ID>
Arguments:
<CANARY_ID> Canary ID to remove
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx canary list --help
List all planted canaries
Usage: balerx canary list [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx canary check --help
Check if a path is a canary
Usage: balerx canary check [OPTIONS] <PATH>
Arguments:
<PATH> Path to check
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx upload --help
Upload scan results or Guard activity-log metadata to a Monitor project
`--scan` needs the `scan:upload` scope. `--activity-log` needs `activity:write`.
Usage: balerx upload [OPTIONS]
Options:
--api-url <API_URL>
API base URL from your Balerx Gate dashboard onboarding. No host is compiled in. Overrides `BALERX_API_URL` when set
--no-color
Disable color. Same as setting `NO_COLOR`
--api-key <API_KEY>
Project ingest API key (hashed at rest on the server). Pass "-" to read from stdin, or set `BALERX_API_KEY`. A literal value is rejected for security
--scan <SCAN>
Findings v1 JSON produced by `balerx scan --json`
--activity-log <ACTIVITY_LOG>
Guard activity log (JSONL). Tool arguments are dropped before upload
--lockfile <LOCKFILE>
Lockfile to diff. Drift is attached to the scan upload
--allow-insecure
Allow plain `http://` to a non-loopback host. Sends the ingest key in the clear. Loopback HTTP (`localhost`, `127.0.0.0/8`, `::1`) is already allowed
-h, --help
Print help (see a summary with '-h')
balerx setup --help
Choose a local Guard policy and write ~/.balerx/policy.yaml. Offline.
A terminal shows a checklist. Arrow keys move, space toggles, and enter confirms. `--yes` writes the balanced preset. `--preset strict|balanced|minimal` writes that preset. A new strict or balanced file sets `timeout_ms` to 250. Strict also sets `fail_open: false`. Existing files keep their values; a kept timeout below 250 prints a warning. When stdin is not a terminal, the balanced preset is written and this command does not prompt. `--yes` and `--preset` leave an existing file in place. Pass `--replace` to copy it to `policy.yaml.bak` and write a new file. A checklist confirms before it replaces an existing file. The previous file is copied to `policy.yaml.bak`.
Usage: balerx setup [OPTIONS]
Options:
--no-color
Disable color. Same as setting `NO_COLOR`
--preset <PRESET>
Write strict, balanced, or minimal without the checklist. Balanced and strict write timeout 250ms. Strict writes `fail_open` false. An existing file requires --replace
[possible values: strict, balanced, minimal]
--yes
Write the balanced preset without prompting. An existing file requires --replace
--replace
Replace an existing policy. The current file is copied to policy.yaml.bak first
-h, --help
Print help (see a summary with '-h')
balerx policy --help
Manage the local Guard policy. Offline unless you explicitly pull
Usage: balerx policy [OPTIONS] <COMMAND>
Commands:
init Same as `balerx setup`
show Print the active policy. The built-in policy is shown when no file exists
edit Open the checklist again, pre-filled from the current policy file
pull Fetch the organization policy with an ingest key and write it locally
help Print this message or the help of the given subcommand(s)
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx policy init --help
Same as `balerx setup`
Usage: balerx policy init [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
--preset <PRESET> Write strict, balanced, or minimal without the checklist. Balanced and strict write timeout 250ms. Strict writes `fail_open` false. An existing file requires --replace [possible values: strict, balanced, minimal]
--yes Write the balanced preset without prompting. An existing file requires --replace
--replace Replace an existing policy. The current file is copied to policy.yaml.bak first
-h, --help Print help
balerx policy show --help
Print the active policy. The built-in policy is shown when no file exists
Usage: balerx policy show [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx policy edit --help
Open the checklist again, pre-filled from the current policy file.
`--preset` or `--yes` rewrites the file without a terminal. The previous file is copied to `policy.yaml.bak`. `global.fail_open` and `global.timeout_ms` are kept from the current file. A kept timeout below 250 prints a warning.
Usage: balerx policy edit [OPTIONS]
Options:
--no-color
Disable color. Same as setting `NO_COLOR`
--preset <PRESET>
Write strict, balanced, or minimal without the checklist. Balanced and strict write timeout 250ms. Strict writes `fail_open` false. An existing file requires --replace
[possible values: strict, balanced, minimal]
--yes
Write the balanced preset without prompting. An existing file requires --replace
--replace
Replace an existing policy. The current file is copied to policy.yaml.bak first
-h, --help
Print help (see a summary with '-h')
balerx policy pull --help
Fetch the organization policy with an ingest key and write it locally.
Needs the `policy:read` scope. Does not contact the network unless `--api-url` and `BALERX_API_KEY` are set, or `--api-key -` is passed to read from stdin.
Usage: balerx policy pull [OPTIONS]
Options:
--api-url <API_URL>
API base URL from your Balerx Gate dashboard onboarding. No host is compiled in. Overrides `BALERX_API_URL` when set
--no-color
Disable color. Same as setting `NO_COLOR`
--api-key <API_KEY>
Project ingest or enrollment API key. Pass "-" to read from stdin, or set `BALERX_API_KEY`. A literal value is rejected for security
--output <OUTPUT>
Destination. Defaults to `~/.balerx/policy.yaml`
--allow-insecure
Allow plain `http://` to a non-loopback host. Sends the ingest key in the clear. Loopback HTTP (`localhost`, `127.0.0.0/8`, `::1`) is already allowed
-h, --help
Print help (see a summary with '-h')
balerx uninstall --help
Remove Guard hooks for Claude Code and Cursor. Offline.
Deletes only Balerx hook commands from Claude Code and Cursor. A command matches when it contains `balerx` and `hook` and a token names `balerx` or `balerx.exe` with a separate `hook` argument. Other hooks stay. Empty hook lists left by those commands are removed. Without `--purge`, policy files and the activity log stay, and the command says so. `--purge` deletes known files only: `policy.yaml`, `policy.yaml.bak` copies, planted canary files in `~/.balerx/canaries`, `canaries.json`, and `logs/activity.jsonl`. Unknown files stay. A directory is removed only when it is empty afterward and its name is `.balerx` or `balerx`. A custom data directory is never removed wholesale. The command prints every path and asks before it changes anything. `--yes` skips the question. When stdin is not a terminal and `--yes` is absent, nothing is removed. Purge stops without deleting anything when the home directory or the data directory is not an absolute path. On macOS and Linux, `$HOME/.local/bin/balerx` is removed only when that file is the running binary. On Windows, purge deletes known data files and does not delete `balerx.exe`. The command prints the PowerShell that deletes `%LOCALAPPDATA%\balerx` and that folder's user Path entry.
Usage: balerx uninstall [OPTIONS]
Options:
--no-color
Disable color. Same as setting `NO_COLOR`
--purge
Delete known policy files and activity logs. Unknown files stay
--yes
Remove the listed files without asking
-h, --help
Print help (see a summary with '-h')
balerx doctor --help
Show version, data directory, Guard hooks, and policy. Parses the policy file. Empty or invalid YAML exits 1. Does not use the network
Usage: balerx doctor [OPTIONS]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx completions --help
Print a shell completion script
Usage: balerx completions [OPTIONS] <SHELL>
Arguments:
<SHELL> bash, zsh, fish, or powershell [possible values: bash, zsh, fish, powershell]
Options:
--no-color Disable color. Same as setting `NO_COLOR`
-h, --help Print help
balerx version --help
Print this version.
`--check` makes a single request to the public GitHub releases API. Every other command stays offline except `upload` and `policy pull`. `balerx --version` and `-V` stay offline and do not accept `--check`.
Usage: balerx version [OPTIONS]
Options:
--check
Check GitHub for a newer release. Opt-in: nothing is checked unless you ask.
Makes a single request to the public GitHub releases API. Every other command stays offline except `upload` and `policy pull`. A timeout, rate limit, or missing network prints a message and exits 0.
--no-color
Disable color. Same as setting `NO_COLOR`
--json
Print JSON. With `--check`, include the release comparison. Without it, print this version only
-h, --help
Print help (see a summary with '-h')
balerx self-update --help
Print the install command for this OS.
Without `--check`, this prints the install command and does not download or replace the binary. Windows prints the PowerShell installer with `-ExecutionPolicy Bypass` for that one process. macOS and Linux print curl and sh. `--check` makes a single request to the public GitHub releases API. Every other command stays offline except `upload` and `policy pull`.
Usage: balerx self-update [OPTIONS]
Options:
--check
Check GitHub for a newer release. Opt-in: nothing is checked unless you ask.
Makes a single request to the public GitHub releases API. Every other command stays offline except `upload` and `policy pull`. A timeout, rate limit, or missing network prints a message and exits 0.
--no-color
Disable color. Same as setting `NO_COLOR`
--json
Print the check result as JSON. Requires `--check`
-h, --help
Print help (see a summary with '-h')