The Firewall for Claude Code — A local-first security hook that protects against secrets leakage, dangerous commands, and unauthorized tool use.
Railgun sits between Claude Code and your system, inspecting every tool invocation before it executes. It blocks secrets from leaking, prevents dangerous commands, and gives you fine-grained control over what Claude can do.
┌──────────────┐ ┌─────────────┐ ┌──────────────────┐
│ Claude Code │ ──► │ Railgun │ ──► │ Tool Execution │
│ (LLM) │ │ (Inspect) │ │ (Bash, Write..) │
└──────────────┘ └─────────────┘ └──────────────────┘
│
▼
Block or Allow
- Secret Detection — Blocks AWS keys, GitHub tokens, private keys, and high-entropy strings
- Dangerous Command Blocking — Prevents
rm -rf /, fork bombs, and disk operations - Protected Path Detection — Blocks access to
~/.ssh/,~/.aws/credentials,.envfiles - Network Exfiltration Prevention — Blocks ngrok, pastebin, webhook.site
- Tool-Level Permissions — Allow/deny/ask rules for any Claude tool or MCP server
- Sub-Millisecond Latency — < 1ms p99 overhead, won't slow down your workflow
curl -fsSL https://raw.githubusercontent.com/douglance/railgun/main/install.sh | bashThis will:
- Download the correct binary for your platform
- Install it to
~/.local/bin/ - Configure Claude Code to use Railgun
brew tap douglance/tap
brew install railgun
railgun installcargo install railgun
railgun installDownload the latest release for your platform:
- darwin-arm64 (macOS Apple Silicon)
- darwin-x64 (macOS Intel)
- linux-arm64
- linux-x64
# Example: macOS Apple Silicon
tar -xzf railgun-darwin-arm64.tar.gz
mv railgun ~/.local/bin/
railgun installgit clone https://github.com/douglance/railgun.git
cd railgun
cargo build --release
cp target/release/railgun ~/.local/bin/
railgun install# Install the hook
railgun install
# Verify installation
railgun --versionCreate railgun.toml in your project or home directory:
[policy]
mode = "strict" # "strict" blocks, "monitor" logs only
[policy.secrets]
enabled = true
# Add custom patterns
patterns = [
{ name = "Slack Token", pattern = "xox[baprs]-[0-9a-zA-Z-]+" }
]
[policy.commands]
enabled = true
# Allow specific dangerous patterns if needed
allow_patterns = ["rm -rf ./node_modules"]
[policy.paths]
enabled = true
# Add custom protected paths
patterns = ["*.pem", "*.key"]
[policy.network]
enabled = true
blocked_domains = ["evil.com"]
# Tool-level permissions
[tools]
allow = ["Bash", "Read", "Write", "Edit", "Glob", "Grep"]
deny = ["mcp__*"] # Block all MCP tools by default
ask = [] # Prompt for confirmation
# MCP server permissions
[mcp.servers.github]
tools.allow = ["get_issue", "list_issues"]
tools.deny = ["delete_*"]# Test a safe command
railgun test Bash '{"command":"ls -la"}'
# Result: ALLOWED
# Test a dangerous command
railgun test Bash '{"command":"rm -rf /"}'
# Result: DENIED
# Reason: Dangerous command blocked
# Test secret detection
railgun test Write '{"content":"aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"}'
# Result: DENIED
# Reason: Secret detected in contentrailgun lint| Command | Description |
|---|---|
railgun install |
Configure Claude Code to use Railgun |
railgun uninstall |
Remove Railgun from Claude Code |
railgun lint |
Validate configuration file |
railgun test <tool> <json> |
Test policy against specific input |
railgun hook |
Run as hook (used internally by Claude Code) |
Railgun integrates with Claude Code's hook system. When Claude attempts to use a tool:
- Claude Code calls
railgun hookwith JSON input - Railgun inspects the tool name and input
- Policy engine checks: secrets, commands, paths, network, permissions
- Returns verdict:
allow,deny(with reason), orask(prompt user) - Claude Code proceeds or blocks based on verdict
railgun/
├── bin/rg/ # CLI binary
│ └── src/
│ ├── cli.rs # Argument parsing
│ ├── hook.rs # Hook implementation
│ ├── install.rs # Install/uninstall
│ └── lint.rs # Config validation
├── crates/
│ ├── rg-types/ # Config, Verdict, HookInput types
│ └── rg-policy/ # Policy engine
│ ├── secrets.rs # Secret detection
│ ├── commands.rs # Dangerous command blocking
│ ├── paths.rs # Protected path detection
│ ├── network.rs # Network exfiltration prevention
│ └── tools.rs # Tool permission matching
# Build
cargo build
# Test
cargo test
# Lint
cargo clippy
# Format
cargo fmtSee CONTRIBUTING.md for detailed guidelines.
See SECURITY.md for:
- How to report vulnerabilities
- Security best practices
- Supported versions
MIT - see LICENSE