CLI Reference
Complete reference for the Railgun command-line interface.
Railgun is invoked via the railgun command.
Synopsis
Commands
railgun install
Configure Claude Code to use Railgun as a preToolUse hook.
This modifies ~/.claude/settings.json to add:
railgun uninstall
Remove Railgun from Claude Code's hook configuration.
railgun lint
Validate your configuration file for syntax errors and invalid patterns.
railgun test
Test your policy against a specific tool input without running Claude Code.
Examples:
Output:
or
railgun hook
Run as a Claude Code hook. Reads JSON from stdin, writes verdict to stdout.
Input Format:
Exit Codes:
| Code | Verdict | Behavior |
|---|---|---|
| 0 | Allow | Tool executes normally |
| 0 | Ask | User prompted (with hookSpecificOutput) |
| 2 | Deny | Tool blocked (with hookSpecificOutput) |
Global Options
--config, -c
Specify the path to your configuration file.
Config Search Order:
- Explicit
-cflag railgun.tomlin current directory~/.config/railgun/railgun.toml- Built-in defaults
Environment Variables
| Variable | Purpose |
|---|---|
RUST_LOG | Log level (debug, info, warn, error) |
RAILGUN_CONFIG | Alternative to -c flag |
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (or Allow/Ask verdict for hook) |
| 1 | Configuration error or general failure |
| 2 | Deny verdict (hook mode only) |
Next Steps
- Configuration — Config file reference
- Policy Engine — How inspection works