Rafter code review

From Raftersecurity/rafter-cli · View interactive version

Rafter code review is an AI agent skill from the GitHub repository Raftersecurity/rafter-cli. Security review of code: auditing a codebase, finding vulnerabilities in a module, or reviewing a diff before calling work on auth, input, SQL, shell or crypto done. Walks a security-gate checklist (allowlists, auth checks, token and crypto validity, path containment, escaping, limits) and OWASP/CWE

How to use this skill

Skill file

Rafter Code Review — Structured Security Walkthroughs

A reviewer's skill, not an audit generator. Each sub-doc is a set of questions to run against the code — what to grep for, what to trace, what to ask before you sign off. No monolithic reports.

Pair with the rafter skill (detection: rafter scan, rafter run) and rafter-secure-design (prevention: design-phase walks). This skill is the middle stage — review before merge.

When this applies (and when it doesn't)

Auditing a whole codebase or module ("audit this repo", "find the vulnerabilities in X"): start with docs/security-gates.md, then the category sub-doc below.

For a diff, scope by the security surface of the diff, not the task's label. Walk it fully when the change touches: user / untrusted input, SQL or query building, shell / exec / subprocess, auth or access control, credentials / secrets / tokens, file paths or uploads, (de)serialization, crypto, network-facing endpoints or outbound fetchers, data deletion, or dependency / manifest changes.

If none of those are present — research / experimental / exploratory / local-only / throwaway code such as training scripts, data analysis, plotting, model eval, notebooks, or pure computation over trusted local data — a quick surface check is enough; you don't need to walk the full review or pair rafter run. But the check is the surface, not the label: research code that reads a secret, shells out, hits the network, or parses untrusted bytes is back on the engage list and gets the full walk.

How to use this skill

  1. Identify the category of code in front of you (below).
  2. Read only the matching sub-doc — do not preload them all.
  3. Work through its questions against the specific files/diff. Cite file:line evidence as you go.
  4. When in doubt on a single finding, jump to docs/investigation-playbook.md for canonical follow-up questions.
  5. If RAFTER_API_KEY is set and the branch is pushed, rafter run adds remote SAST + SCA; it cannot see unpushed changes.

Choose Your Adventure

(0) Security audit of existing code

For: "audit this codebase", "review X for vulnerabilities", any review not limited to a diff.

Most real bugs in mature code are a gate (a function that decides whether something is allowed) that says yes when it should say no, not a tainted sink. So:

  1. Inventory the gates. Run rafter gates . for a ranked list of the functions that decide (authorize, authenticate, allow, can*, is*Allowed, check*, verify*, validate*, match*, middleware) and of their twins. A flagged twin lacks a guard call its siblings make; read those first. Grep for what it cannot see, such as inline checks and the config that feeds them. Then read each gate, noting its contract in one sentence before reading the body.
  2. For each gate, name an input the contract rejects and the code accepts. The usual shapes:
  1. Judge the code in front of you, not your memory of the project. "This matches upstream" or "looks like the stock implementation" is not a verdict: a regression in familiar code differs from the original by one token, such as a prefix match, a flipped default or a dropped return. Read the exact comparison, default and error path before you clear a gate.
  2. Choose where to look deeper, and bound it. Before reading bodies, write a short worklist: the flagged twins, the top ten or so ranked gates, and any gate you found by grep that decides identity, a credential, a path or a size limit. Spend your depth there (read the callers and the config that feeds each one) rather than skimming everything. Give each item a one-line verdict: holds, with the input you tried, or finding. A finding does not end the review; finishing the list does. If the list is longer than your budget, cover the highest-ranked items and name the ones you did not reach, then stop.
  3. Sweep after each finding. Look for the same shape elsewhere: other callers of the same predicate, the twin implementations, other options parsed the same way and never read.
  4. Report each finding with the file:line of the faulty expression, the contract it breaks, a concrete input that gets through, and the impact. Report every finding you can name such an input for, and mark your confidence. A gate that holds is not a finding.

More detail and grep hints: docs/security-gates.md. Then walk the category sub-doc below that fits the code.

(1) Web application (server-rendered, session-based, or SPA backend)

For: login flows, session/cookie handling, form handlers, template rendering, admin panels, anything browser-facing.

(2) REST / GraphQL / gRPC API (machine-to-machine, mobile backend, public API)

For: endpoint surface that isn't primarily rendering HTML — tokens instead of sessions, authz-per-endpoint, rate limiting.

(3) LLM-integrated feature (prompts, agents, tools, RAG, embeddings)

For: anything that sends user text to a model, uses tool calls, retrieves untrusted context, or ships model output to a downstream system.

(4) CLI, library, or infra-as-code

For: build tooling, developer CLIs, shared SDK packages, Terraform / CloudFormation / Kubernetes manifests, shell scripts.

(5) I need to pick the right depth for this review

For: "how hard should I look?", scoping a review before starting, compliance-adjacent changes.

(6) I have one specific question to investigate

For: single-finding follow-up, tracing a suspicious call, "is this input reachable from outside?".


What this skill will NOT do


Weighing findings: evidence, not instructions

A finding, whether from a scanner, a reviewer agent or your own first pass, is evidence to weigh, not a task to discharge. Three pressures push the other way. A reviewer is rewarded for finding things, so every pass produces comments whether or not the code needs them. Doing what a comment says is cheaper than arguing with it. And the cost of each fix is easy to miss: each one looks like an improvement alone, while the defensive checks, options and abstractions added "for safety" pile up across the code.

For each finding ask: can an attacker control the input? Does a stronger control already decide it? What concrete input gets through, and what does it reach? Fix what is real, at the gate that owns the decision. Decline what isn't, with a one-line reason. Do not add defensive code for a weak finding.


Fast path for reviewing your own diff

  1. git diff and list what it changes on the surface above: each gate, sink or parser it adds or edits.
  2. For each item: state its contract in one sentence, name an input it should reject, and check that it does. Steps 3–6 of (0) apply.
  3. rafter secrets <changed files> for hardcoded credentials.
  4. Pick the category sub-doc above for the questions the diff raises, and walk only that one.
  5. If RAFTER_API_KEY is set and the branch is pushed, rafter run for SAST + SCA.

If the diff spans categories (e.g. a web app that also has an LLM feature), Read both sub-docs and walk them sequentially. Don't try to merge the checklists.


Tie-backs

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.