Rafter

From Raftersecurity/rafter-cli · View interactive version

Rafter is an AI agent skill from the GitHub repository Raftersecurity/rafter-cli. Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter agent audit`, policy checks, or command-risk evaluation. Scope by security surface, not task label: engage when the diff touches auth, cre

How to use this skill

Skill file

Rafter — Security Toolkit for AI Workflows

When Rafter applies (and when it doesn't)

Rafter is a surface-driven gate, not a task-label gate. Read the diff's actual security surface first; let that — not whether the work is called "research" — pick the branch.

Engage fully (walk the review + run rafter run) when the change touches any of: auth / sessions / access control · credentials, secrets, tokens, keys · user-supplied or otherwise untrusted input · SQL or any other query / command construction · shell, exec, or subprocess invocation · file paths (read, write, upload, traversal) · deserialization or parsing of untrusted data · crypto primitives · network-facing endpoints or outbound fetchers (SSRF surface) · data deletion or other destructive mutations · dependency, lockfile, or manifest changes.

Back off when the change touches none of those — research / experimental / exploratory / local-only / throwaway code: training scripts, data analysis, plotting, model eval, notebooks, pure computation over trusted local data. A quick surface check is enough; with no security surface, proceed without the full rafter-code-review + rafter run.

The rule that decides it: the "research" label buys nothing. Research code that reads a secret, shells out, hits the network, parses untrusted input, or bumps a dependency is on the engage list and gets the full gate. Judge by the surface of the diff, not by what the task is called.


Picking the right tier

The review you do yourself with rafter-code-review is the step that finds logic and authorization bugs; no scanner tier replaces it. The scanner tiers are not interchangeable:

  1. rafter secrets — hardcoded credentials only (regex + betterleaks). Fast, offline, no key. NOT a code security scan — it finds no SQL injection, SSRF, auth bugs, insecure deserialization, logic flaws, or dependency vulns. A clean rafter secrets . is secret-hygiene, not security review.
  2. rafter run (default mode) — the real code-analysis pass: SAST + SCA + secrets (dataflow, taint, known-vulnerable deps, crypto misuse, injection sinks). Needs RAFTER_API_KEY.
  3. rafter run --mode plus — agentic deep-dive: LLM-guided investigation of what the rules engine flags. Slower, higher signal; code is deleted server-side after the run. PAID tier — consumes the user's credits; ask before running it. If scan.plus_requires_approval is set, Plus refuses without --yes / RAFTER_CONFIRM=1.

For a security-relevant task: review it with rafter-code-review, run rafter secrets on the changed files, and add rafter run when RAFTER_API_KEY is set and the branch is pushed (it scans the pushed commit, not your working tree). Without a key, say that no SAST/SCA ran; don't claim the code was "scanned" without qualification. Deterministic findings, stable exit codes and JSON shapes — safe to chain in CI and in agent loops.


Choose Your Adventure

Pick the branch that matches what you're trying to do. Each branch points at a sub-doc — Read only the one you need so you don't flood context.

(a) I want to scan code or a repo for issues

Use this for: "Is this safe to push?", "Check for leaks", "Run a security scan", pre-merge / pre-deploy gating, post-dependency-update checks.

(b) I want to evaluate a command before running it

Use this for: "Is rm -rf $DIR safe?", any destructive-looking shell the user typed, commands with sudo / pipes to sh / unversioned curl.

(c) I want to review a plugin, skill, or extension before installing

Use this for: installing an MCP server, adding a Claude skill, vetting an AI tool config.

(d) I want to understand a finding I already have

Use this for: "What does HARDCODED_SECRET mean?", "Is this a real issue or noise?", triaging a scan report.

(e) I want to write secure code from scratch

Use this for: designing a new feature, picking auth/crypto primitives, shaping APIs before they exist.

(f) I want to analyze existing code for flaws

Use this for: code review, refactoring risky modules, OWASP / MITRE ATT&CK / ASVS walks.


Repo-Specific Security Rules

Projects can declare a docs: list in .rafter.yml pointing at repo-specific security guides, threat models, or compliance policies — files or URLs. Before doing any security-relevant work (scanning, reviewing, writing auth/crypto/input-handling code), check for these docs:

rafter docs list                    # enumerate available docs (no network)
rafter docs list --tag threat-model # filter by tag
rafter docs show secure-coding      # read one by id (fetches + caches URLs)
rafter docs show owasp              # id OR tag — if a tag matches, all tagged docs are concatenated

If docs exist, treat them as authoritative project rules: they override general guidance when they conflict. If no docs are configured (exit 3 / "No docs configured"), fall back to the standard OWASP / ASVS advice.

MCP-connected agents: the same surface is exposed as the rafter://docs resource plus list_docs / get_doc tools.

Fast Path (most common)

rafter run                   # remote SAST + SCA + secrets — the real code scan
rafter run --mode plus       # agentic deep-dive when fast mode flags something
rafter secrets               # secrets-only — offline, no key
rafter get <scan-id>         # fetch results by id
rafter usage                 # check API quota

Full CLI tree: Read docs/cli-reference.md. Full digest: rafter brief commands.

Scan budget: Remote scans spend the user's quota. rafter run scans the pushed branch, so re-running without a new push repeats it — run it once per task or before a PR and reuse rafter get <scan-id>; while iterating scan only changes (rafter secrets --staged / --diff <ref>); never loop, retry, or --watch from an agent session — exit 3 means quota exhausted, so stop, tell the user, and check rafter usage.

Configuration

rafter run (the full code scan) needs an API key:

export RAFTER_API_KEY="..."        # or put it in .env

Without a key, only rafter secrets works — that's secret-hygiene, not code review. If security matters for the task, flag the missing key to the user rather than silently accepting the narrower scan.

Setup

Not installed? npm i -g @rafter-security/cli (Node) or pip install rafter-cli (Python). npx form is npx @rafter-security/cli — the bare npx rafter-cli resolves to an unrelated package. Inside Cursor's sandbox or any session where writing ~/.rafter triggers a prompt, prefer rafter agent init --local --with-<platform> — writes ./.rafter/ + ./.<platform>/ instead of $HOME. Not wired yet? rafter agent install-hook (pre-commit), rafter ci init (CI), .rafter.yml (policy). Per-platform: rafter brief setup/<platform>.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.