Customize and automate

Add a security review or a gate reviewer

Add the shipped security-review skill to a chain of your own, and change or turn off the gate reviewer the default chain runs at every gate.

Kraft ships two review skills besides the code review. The default chain runs one of them at every gate; no shipped chain runs the other.

  • kraft:gate-review reads the document a gate is about and reports a verdict before you're asked. Checking first, it sends back work that isn't ready and hands the rest to you with a note. Deciding, it may also approve, so a gate that needs no person's decision no longer waits for one. It never clears the gate itself. The default chain's gates all check first.
  • kraft:security-review reviews a change that touches authentication, sessions, tokens, secrets or permission checks. It reports findings the way kraft:code-review does, so they enter the same fix loop. It runs only in a chain you add it to.

Both cost money. A gate reviewer is a paid agent session on every item that reaches the gate with auto-gate on. A security pass costs an extra agent session per review round on every item.

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 set KRAFT_HOME.

Add a security review to verification

  1. Add the task to library.yaml, under tasks::
    config/library.yaml
    security_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]
    
  2. Make chains/reviewed.yaml, a chain that extendsdefault, and override verification so it runs the security review beside the code review. An override replaces a list it sets, as extends does, so write both steps out:
    config/chains/reviewed.yaml
    id: reviewed
    extends: default
    
    overrides:
      verification:
        steps:
          - id: tests
            tasks:
              - id: test_changed_scopes
                extends: kraft-default:verify_changed_scopes
          - id: review
            read_only: true
            tasks:
              - id: code_review
                extends: kraft-default:code_review
              - id: security_review
                extends: security_review
    

    The shipped tasks kraft-default:verify_changed_scopes and kraft-default:code_review come from the built-in kraft-default. The security_review task is yours, from step 1, so it keeps its bare name.
    In a chain that lists its own nodes, put the same steps on its - id: verification entry instead.
    Tasks in one step run in parallel, so both reviews read the same tests-green change. Their findings share the node's fix loop. read_only: true, as on the shipped review step, stops the item for you if either review changes the worktree.

Change or turn off the gate reviewer in the default chain

Added in 2.6

Each gate in the default chain (spec_approval, plan_approval, chain_revision_approval, local_review and final_review) has an auto_review that extends gate_reviewer, with auto_review_mode: checks_first. A chain that extends default inherits all five. Change one with an override, beside verification under the same overrides: in chains/reviewed.yaml:

config/chains/reviewed.yaml
overrides:
  # verification: as above
  spec_approval:
    auto_review_mode: decides
  plan_approval:
    auto_review:
      prompt: Check that every task in the plan traces to the spec.
  local_review:
    auto_review: null
  • auto_review_mode: decides lets the reviewer approve as well. A deciding reviewer can clear the gate with no person, so keep it to a gate you trust an agent with. At final_review, an approval starts the merge.
  • An override of the reviewer's prompt, skill or harness keeps the rest of gate_reviewer. It can't set the reviewer's id, kind or extends: Kraft refuses the chain with an override cannot set auto_review.id, auto_review.extends.
  • auto_review: null leaves the gate to you, with no reviewer.
  • To skip every reviewer on one item, file it with --no-auto-gate.
  • While a gate's reviewer runs, kraft item skip, retry and resume on the item are refused as a walk already running. Approving or rejecting the gate stops the reviewer first.

A chain written before this release that gives a default gate its own auto_review, with an id, a kind or an extends, stops resolving with that refusal. Delete those keys from the override's auto_review and keep the rest: a reviewer that extended gate_reviewer needs nothing more, and one that set its own prompt, skill or harness keeps them as overrides of the gate's reviewer. Keep auto_review_mode, if the override sets one.

Add a gate reviewer to a gate

A gate in a chain that lists its own nodes, or one you add to a chain, has no reviewer until you give it one.

  1. Pick the gate to review. This guide uses spec_approval, in a chain of your own that lists its nodes.
  2. Find the gate_reviewer task. The built-in kraft-default ships it, and from your own chains you name it kraft-default:gate_reviewer: a bare gate_reviewer is looked up in your own library.yaml. A home with a full copy of the library, seeded before Kraft shipped kraft-default, may lack it. Add it under tasks: as below, or move onto kraft-default and use the prefixed name in step 3:
    config/library.yaml
    gate_reviewer:
      kind: agent
      harness: claude
      prompt: Check this gate before the person decides.
      skill: kraft:gate-review
    
  3. Give the gate an auto_review that extends it, and auto_review_mode: checks_first, on its entry under nodes::
    config/chains/my-chain.yaml
    nodes:
      # spec: as before
      - id: spec_approval
        kind: gate
        message: Review and approve the specification.
        artifact: spec
        reject_to: spec
        auto_review_mode: checks_first
        auto_review:
          id: reviewer
          extends: kraft-default:gate_reviewer
    

    In the Templates screen, a gate's "Add a reviewer" menu does the same: a reviewer added there checks first, and the gate's "reviewer may" row switches the mode.
  4. To let the reviewer approve as well, set auto_review_mode: decides, or leave the key out. A deciding reviewer can clear the gate with no person, so it is the stronger choice, for a gate you trust an agent with. Its task can also be written out in place of extends:
    config/chains/my-chain.yaml
    nodes:
      - id: spec_approval
        # kind, message, artifact and reject_to: as above
        auto_review:
          id: reviewer
          kind: agent
          harness: claude
          prompt: Decide whether this gate needs a person.
          skill: kraft:gate-review
    
  5. 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 a fallback: 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, in either mode. 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 a verdict, and Kraft applies it. The gate's auto_review_mode says which verdicts count:

auto_review_modeThe reviewer reportsWhat Kraft does
checks_firstreject or passA reject sends the work back, with concerns as the steer. A pass leaves the gate to you, shown as ready for you with the reviewer's note. An approve counts as a pass. Added in 2.5
decides, or unsetapprove, reject, fixed or undecidedAn approve clears the gate with no person asked.

Result file says what each verdict does.

If the reviewer reports nothing or a value its mode doesn't take, or a reject with no concerns, Kraft records undecided: the gate waits for a person, shown as could not decide with the reviewer's note. auto_review_attempts in policy.yaml (default 1) bounds how many attempts one pending gate gets.

A reviewer that checks first

Added in 2.5

A checks_first reviewer's verdict never clears the gate, whatever it writes. The item page, the phone and the review page show its outcome, ready for you or could not decide, with its note, beside the gate you decide.

A pass ends automated review of that gate until it is asked for again, whatever auto_review_attempts allows. The gate's next request, after a reject and a re-run, starts afresh and so does kraft item retry on the item waiting at the gate, which asks for the gate again. Pausing doesn't: an item waiting at a gate can't be paused.

The reviewer must not change the work. Kraft reads the checkout before the review and again after, and the gate's document too, which is kept outside the checkout. If anything changed, Kraft ignores the verdict, a reject included, and records undecided with a note naming the changed files: the first 20, then how many more. In an item's own worktree the changes stay there: look at them before you approve. The gate waits for you; the item doesn't stop.

If Kraft can't read the checkout before the review, the verdict doesn't count either: for an item in its own worktree, no reviewer starts at all.

On an in-place item the reviewer never works in your checkout. It still holds the checkout, so it waits while another item uses it, but it reads a throwaway copy of what is committed on the item's branch, and Kraft removes the copy after. Your checkout isn't switched and your uncommitted edits aren't touched, nor seen: they aren't in the copy.

A change the reviewer makes in the copy voids its verdict, and the note says the copy is gone. If the copy can't be made, for example because the item's branch was deleted, no reviewer starts and the gate is could not decide.

The check counts more than the reviewer's own edits:

  • in an item's own worktree, files a test run of the reviewer's leaves behind, untracked and not gitignored, count as edits and void its verdict.
  • on an in-place item, a commit anyone makes on the item's branch during the review counts too: the branch's tip is compared as well as the copy.

The check misses:

  • an edit made across a server restart mid-review: the reading from before the review is held in memory, and is lost.
  • on another machine, commits the server refuses to publish (the branch moved, or its worktree has uncommitted changes): they are kept under refs/kraft/unsynced/ with a sandbox_branch_not_synced event, and not compared. A remote review whose commits are published is checked like a local one.
  • on another machine, a sandboxed review whose checkout holds git repositories Kraft didn't create: Kraft skips its commit sweep there, so its uncommitted edits are lost instead of flagged.
  • for an item in its own worktree, an edit to the repository's own checkout: the reviewer is told where it is and may read it, but only the item's worktree and the gate's document are compared.
  • on an in-place item, an uncommitted edit made in your checkout itself, not in the copy: only the copy, the branch's tip and the gate's document are compared.

Check it worked

  1. 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 is lint's, the second reload's. In the show output, look for security_review under verification, and auto_review on the gate.
  2. File an item on the chain:
    kraft item create "title" --chain reviewed
    
  3. 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 in findings_measured like any review finding. A gate review that ran shows one gate_auto_review_started row. A gate_auto_review_skipped row means the reviewer left the gate to a person.

Change how review-bot feedback is triaged

Added in 2.4

The shipped chain's merge_request_feedback node ends its review wait with a triage step, review_feedback.triage. A cheap agent reads what the review bots said and reports only the comments that need a change; the rest it declines, with a reason the person at final_review can read. Swap the skill it follows with one override in a chain that extends default. In chains/reviewed.yaml it goes under the same overrides: as the others:

config/chains/reviewed.yaml
overrides:
  # verification and the gates: as above
  merge_request_feedback.review_feedback.triage:
    skill: superpowers:receiving-code-review
  • The task stops if the worker can't load the skill, and waits for you.
  • superpowers:receiving-code-review needs the superpowers plugin installed for the agent that runs the task, and was written for a session with a person in it. The shipped kraft:review-feedback is written for a run with nobody to ask.
  • The triage never replies to, resolves or edits a thread on the merge request, whichever skill it follows.

Next steps

Copyright © 2026