Rafter CLI — security for AI builders
Project description
rafter-cli (Python)
Python CLI for Rafter — zero-setup security for AI builders. Full feature parity with the Node.js package.
Backend scanning — Remote SAST/SCA via Rafter API. Trigger scans, retrieve structured vulnerability reports, pipe to any tool.
Agent security — Local-first protection for autonomous AI agents. Secret scanning (21+ patterns, Gitleaks), command interception with risk-tiered approval, pre-commit hooks, pretool hooks, and full audit logging. Works with Claude Code, Codex CLI, and OpenClaw. No API key required.
MCP server — Expose Rafter security tools to any MCP-compatible client (Cursor, Windsurf, Claude Desktop, Cline) over stdio.
Installation
pip install rafter-cli
Requires Python 3.10+.
Quick Start
Backend Scanning
export RAFTER_API_KEY="your-key" # or add to .env file
rafter run # scan current repo (auto-detected)
rafter scan --repo myorg/myrepo --branch main # scan specific repo
rafter get SCAN_ID # retrieve results
rafter get SCAN_ID --interactive # poll until complete
rafter usage # check quota
Important: The scanner analyzes the remote repository on GitHub, not your local files.
Agent Security
rafter agent init # initialize + auto-detect agents
rafter agent scan . # scan for secrets
rafter agent scan --diff HEAD~1 # scan changed files
rafter agent exec "git commit" # execute with risk assessment
rafter agent audit # view security logs
rafter agent config show # view configuration
Pretool Hooks (Claude Code)
rafter agent init --claude-code # install PreToolUse hooks
rafter hook pretool # hook handler (reads stdin, writes decision)
rafter policy export --format claude # export hook config
MCP Server
rafter mcp serve # start MCP server over stdio
Add to any MCP client config:
{
"rafter": {
"command": "rafter",
"args": ["mcp", "serve"]
}
}
Tools: scan_secrets, evaluate_command, read_audit_log, get_config
Resources: rafter://config, rafter://policy
Commands
rafter run [options]
Alias: rafter scan
Trigger a new security scan for your repository.
-r, --repo <repo>— org/repo (default: auto-detected from git remote)-b, --branch <branch>— branch (default: current branch or 'main')-k, --api-key <key>— API key (orRAFTER_API_KEYenv var)-f, --format <format>—jsonormd(default:md)--skip-interactive— don't wait for scan completion--quiet— suppress status messages
rafter get <scan-id> [options]
Retrieve results from a scan.
-k, --api-key <key>— API key-f, --format <format>—jsonormd(default:md)--interactive— poll until scan completes--quiet— suppress status messages
rafter usage [options]
Check API quota and usage.
-k, --api-key <key>— API key
rafter mcp serve [options]
Start MCP server over stdio transport.
--transport <type>— Transport type (default:stdio)
rafter hook pretool
PreToolUse hook handler. Reads tool input JSON from stdin, writes decision to stdout.
rafter policy export [options]
Export Rafter policy for agent platforms.
--format <type>— Target format:claudeorcodex--output <path>— Write to file instead of stdout
Piping and Automation
# Filter critical vulnerabilities
rafter get SCAN_ID --format json | jq '.vulnerabilities[] | select(.level=="critical")'
# CI gate
if rafter get SCAN_ID --format json | jq -e '.vulnerabilities | length > 0'; then
echo "Vulnerabilities found!" && exit 1
fi
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error / secrets found |
| 2 | Scan not found |
| 3 | Quota exhausted |
Documentation
Full docs at docs.rafter.so.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rafter_cli-0.5.5.tar.gz.
File metadata
- Download URL: rafter_cli-0.5.5.tar.gz
- Upload date:
- Size: 46.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f03863e1dca4481ebe2393d32e77af2037a8c8ad707419f0d5b367009ab72c8
|
|
| MD5 |
c54f51cf0526074f1a49956d64afc5fa
|
|
| BLAKE2b-256 |
04e882ad87c5e923b3061a593c44e97caa7d71223126c52c07268c9bc0ada220
|
File details
Details for the file rafter_cli-0.5.5-py3-none-any.whl.
File metadata
- Download URL: rafter_cli-0.5.5-py3-none-any.whl
- Upload date:
- Size: 58.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f8b22d8c873dcf8cd5ed20f21a66185a1118afaa8961e4ddd175ee1c6c7181
|
|
| MD5 |
4464708a0c50dd3c027e90456fedcf60
|
|
| BLAKE2b-256 |
2e5ae7a08f486a2b549e88618ca4a75349466163bb8052ceb388e0e318f9cad5
|