Add a security review or a gate reviewer
Add the two review skills that no shipped chain runs to a copy of the default
chain: a security review inside verification, and an agent that reviews a gate
before a person is asked.
kraft:security-reviewreviews a change that touches authentication, sessions, tokens, secrets, or permission checks. It reports findings the waykraft:code-reviewdoes, so they enter the same fix loop.kraft:gate-reviewreads the document a gate is about and reports a verdict, so a gate that needs no person's decision no longer waits for one. It never clears the gate itself.
Both are opt-in because both cost money. A security pass costs an extra agent session per review round on every item. A gate reviewer is a paid agent session on every item that reaches the gate with auto-gate on, and it decides whether a person sees that gate at all. Neither runs unless you add it to your chain.
Before you start
- A running Kraft server.
- A chain of your own to edit. Step 2 makes
chains/reviewed.yaml; if you already have a chain, edit that one. - Your config directory:
~/.kraft/config/, or$KRAFT_HOME/config/if you setKRAFT_HOME.
Add a security review to verification
- Add the task to
library.yaml, undertasks::config/library.yamlsecurity_review: kind: agent harness: claude prompt: Review this work item's change for security defects. skill: kraft:security-review inputs: [review_package, carried_findings, previous_review] - Copy the default chain to a chain of your own.
cp -nnever overwrites a file, so ifchains/reviewed.yamlexists, skip this step and keep editing it:cd "${KRAFT_HOME:-$HOME/.kraft}/config" cp -n chains/default.yaml chains/reviewed.yaml - In
chains/reviewed.yaml, changeid: defaulttoid: reviewed. - Replace the existing
- id: verificationentry with one that runs the security review beside the code review. A list replaces the parent's when a node extends (howextendsmerges), so write both steps out:config/chains/reviewed.yaml- id: verification extends: verification steps: - id: tests tasks: - id: test_changed_scopes extends: verify_changed_scopes - id: review tasks: - id: code_review extends: code_review - id: security_review extends: security_review
Tasks in one step run in parallel, so both reviews read the same tests-green change. Their findings share the node's fix loop.
Add a gate reviewer to a gate
- Open
chains/reviewed.yaml, or your own chain, and find the gate node to review. This guide usesspec_approval. - Add
auto_reviewto it. It takes an agent task, which you write out as below orextendsfrom the library:config/chains/reviewed.yaml- id: spec_approval kind: gate message: Review and approve the specification. artifact: spec reject_to: spec auto_review: id: reviewer kind: agent harness: claude prompt: Decide whether this gate needs a person. skill: kraft:gate-review - Leave out
fallback:. A gate review launches its reviewer once, so Kraft refuses the task at launch if it selects an agent profile (profile:) whose tier has afallback:list.
Auto-gate is on by default for an item you file, so adding auto_review starts a
paid reviewer agent on every such item that reaches the gate. An item filed by a
schedule, POST /api/triggers or auto-intake has it off, and --no-auto-gate
opts one more item out. Filing a work item
has the rule.
What the reviewer can decide
The reviewer runs as a worker, so Kraft refuses it if it tries to approve or
reject. It reports one of approve, reject, fixed, or undecided, and Kraft
applies the verdict. Result file
says what each one does.
If the reviewer reports nothing or an unknown value, Kraft records undecided:
the gate waits for a person, who sees the reviewer's concerns first.
auto_review_attempts in policy.yaml
(default 1) bounds how many attempts one pending gate gets.
Check it worked
- Lint the files, make the server read them, and print the chain with the
library expanded:
kraft admin templates lint kraft admin reload kraft admin templates show reviewed --resolved
A pass prints these lines (the counts are your own):3 chain(s), no errors reloaded 3 template(s) and policy.yaml and intake.yaml
The first line islint's, the secondreload's. In theshowoutput, look forsecurity_reviewunderverification, andauto_reviewon the gate. - File an item on the chain:
kraft item create "title" --chain reviewed - When the item has passed the tests in
verification, list the findings, and when it reaches the reviewed gate, list the reviewer's start:kraft view events ID --type findings_measured kraft view events ID --type gate_auto_review_started
A security finding shows infindings_measuredlike any review finding. A gate review that ran shows onegate_auto_review_startedrow. Agate_auto_review_skippedrow means the reviewer left the gate to a person.
Next steps
- Chain file keys: every key a gate takes,
auto_reviewincluded. - Filing a work item: which items have auto-gate on, and how to turn it off.
- Events: the events a gate review records.
- Write your own chain: add a node of your own to the same chain.