Skip to main content

Rafter CLI — the default security agent for AI workflows. Free for individuals and open source.

Project description

rafter-cli (Python)

Python CLI for Rafter — the security toolkit for developers. Full feature parity with the Node.js package.

Local security toolkit — Fast, deterministic secret scanning (21+ patterns, Gitleaks), policy enforcement with risk-tiered rules, pre-commit hooks, pretool hooks, extension auditing, custom rule authoring, and full audit logging. Works with Claude Code, Codex CLI, OpenClaw, and 5 more platforms. No API key required. No data leaves your machine.

Remote code analysis — Deep security audits that combine agentic analysis with a full SAST/SCA toolchain. The engine examines your codebase the way a professional cybersecurity auditor would — tracing data flows, reasoning about business logic, and surfacing vulnerabilities that static rules alone miss — then cross-references findings with industry-standard static analysis and dependency scanning. Structured JSON reports with documented exit codes. Your code is deleted immediately after analysis completes.

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 Code Analysis

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 code analysis engine runs against the remote repository on GitHub, not your local files. Your code is deleted immediately after analysis completes.

Local Security

rafter agent init                # initialize config + detect environments
rafter agent init --all          # install all detected integrations
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 --with-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 (or RAFTER_API_KEY env var)
  • -f, --format <format>json or md (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>json or md (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: claude or codex
  • --output <path> — Write to file instead of stdout

Piping and Automation

# Filter high-severity vulnerabilities (SARIF levels: error, warning, note)
rafter get SCAN_ID --format json | jq '.vulnerabilities[] | select(.level=="error")'

# 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rafter_cli-0.7.1.tar.gz (175.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rafter_cli-0.7.1-py3-none-any.whl (219.2 kB view details)

Uploaded Python 3

File details

Details for the file rafter_cli-0.7.1.tar.gz.

File metadata

  • Download URL: rafter_cli-0.7.1.tar.gz
  • Upload date:
  • Size: 175.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for rafter_cli-0.7.1.tar.gz
Algorithm Hash digest
SHA256 f79fbcb5dfe91c9bc79edf613c5cdca846fdc3f14f9866f0d98390a58fdce8b8
MD5 413018d45214ed673d8f77bec8c45f8f
BLAKE2b-256 25f7dc4f507a1ec0742c414fdf4c4a244f0fd163e64d76acaa734a21d76dffdd

See more details on using hashes here.

File details

Details for the file rafter_cli-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: rafter_cli-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 219.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for rafter_cli-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5016914f0b54290f32917d7a3d4651e651a57f5c0eaf47ba6113799491081a2
MD5 d5b30842d0e94ecbae53b141e16e5279
BLAKE2b-256 0821b5a620e50b9e54ef9b331aeb6b090c9e048842f4a1e4ef4c049135e2afe0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page