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 itself, whichever skill it follows. Kraft posts any reply, as Let Kraft answer the review bots says.

Let Kraft answer the review bots

Unreleased

By default the triage declines a bot's comment silently: the person at final_review reads why in the brief, but the bot and the merge request's other readers see nothing. Turn replies on and Kraft answers in each thread it judged, reads the bot's answer and judges that too. Off by default: a repository that sets neither key below changes in no way.

Turn it on

Unreleased

Set replies: true on a bot reviewer, and resolve_fixed: true as well to have Kraft resolve the threads whose fix it confirmed. resolve_fixed needs replies: true on the same entry, and a check: reviewer takes neither key. Name them in any of the three places that name reviewers:

repos.yaml
repos:
  - path: /work/app
    automated_review:
      - {bot: coderabbitai, replies: true, resolve_fixed: true}
  • In a chain's config.reviewers on the review task, as {bot: LOGIN, replies: true}.
  • In the repo's automated_review, as above.
  • On one item: kraft item set-node-override ID --node merge_request_feedback --reviewer bot:coderabbitai:replies:resolve_fixed.

The nearest layer's list wins whole. An item override stored before this release has no replies key, so it leaves replies off for that item until you set it again.

Replies need a triage skill that writes them

Unreleased

The shipped kraft:review-feedback skill writes a reply for each thread it judges. The skill swapped in above, superpowers:receiving-code-review, writes none, so Kraft would post nothing and nothing would say why. Keep the shipped skill on a node whose bots have replies: true.

What Kraft posts

Unreleased

  • A reply per judged thread. It reads Fixed in <commit>: once the triage on the fixing commit confirmed the fix, Declined: for a comment the triage found wrong or not for this change, or Answer: for a question.
  • A summary comment. The bot's top-level comments that the triage declined go in one comment on the merge request, edited in place.
  • A signature on every note. Each ends with a footer naming Kraft and the work item, and a hidden marker that finds the note again.

Kraft refuses text that holds a link, an image, raw HTML or a secret it knows. It breaks every mention, reference and / command line so none fires, accepts a quote only when it is verbatim, and cuts a long note.

Where it works

Unreleased

Kraft posts only where a fix loop can act on what the bot answers.

Node shapeReplies
The shipped one: review wait that watches CI, an early fix loop, then the triageYes
A review wait, the triage and a fix loop, without CI watchingYes
A CI step before the review waitYes
No fix loopNo
No triage task that reads the botsNo
An item that covers several repositoriesNo

On a "no" shape nothing is posted, and the node records one replies_inert event with the reason. The same event covers a repo with no forge and a Kraft that writes as the bot itself.

The reply round and its limits

Unreleased

Before a node completes, Kraft checks whether a bot has answered one of its replies or still may. If so it runs a reply round: one more measurement of the node on the same head, where the triage reads only what is new, answers or raises a finding, and the fix loop acts on it. Three limits bound it:

KeyDefaultWhat it limits
reply_cap_per_thread2Kraft's triage replies in one thread, over the item's life.
reply_rounds_per_head2Reply rounds on one head in one node run.
reply_timeout_minutes5How long a round waits for the bot to answer each reply.

They are policy keys, so a repo, chain or item can set them within the administrator's maxima. The rounds count toward the fix loop's wall clock. A CI look that is still pending when a round's time ends doesn't hold the node: it completes on the earlier green measurement, and the brief says so. A bot that answers after the timeout writes in a thread Kraft may already have resolved, and nobody reads it.

Resolving threads

Unreleased

With resolve_fixed: true, Kraft resolves a thread only at node completion, after the last reply round, from a fresh read of the thread. It resolves only a thread whose latest Kraft note is a confirmed Fixed in reply, and only once the last triage saw every note in it.

Kraft never resolves:

  • a decline or an answer: a person decides those;
  • a thread whose reply the cap, the gate or a failure held back;
  • a thread with a finding still outstanding, or a bot answer no triage read;
  • a person's thread, or one the forge says the viewer can't resolve;
  • a thread it resolved once and someone reopened.

Every thread it leaves open is listed in the brief with its reason.

What to expect. A resolved fix can satisfy a "conversations must be resolved" rule (GitHub branch protection, GitLab's "all threads must be resolved"). A decline or an answer never does, so on such a repository a person resolves each of them before the merge. The brief lists them as open threads that need a person (not_fixed).

Before the merge. With a bot configured, replies on or off, the final_review brief says how many bot threads are still open and whether the base branch requires resolved conversations: yes, no, or unknown when Kraft can't read the rule.

Kraft reads GitHub's rulesets and classic branch protection, and GitLab's "All threads must be resolved" setting. Classic protection needs admin access, so a token without it can read unknown. A failed read never holds the item. A repository with no bot gets no extra forge call and an unchanged brief.

If the merge stops on it. When the forge refuses a merge on unresolved threads, or holds it until the wait times out, the stop lists each open bot thread by file and line. It says the forge named them when it did.

GitHub's refusal covers every branch rule, so there the stop calls them the likely blocker, or a possible one when Kraft couldn't read the rule. Kraft doesn't change what the merge does: resolve the threads, then retry. A workspace item's brief covers its root merge request only and names the members it didn't read.

The restart consequence

Unreleased

A resolved thread isn't collected by a later triage. After a base change, a merge rejection or a final_review rejection, a change that undoes a fix, or the code a decline cited, isn't judged against that thread.

Edits

Unreleased

Kraft compares only creation times. A bot that edits an earlier note after Kraft's triage read it isn't seen, and a thread can resolve over the edit.

What it doesn't close

Unreleased

An agent that reads untrusted notes writes the text Kraft posts. The body gate narrows what that text may carry but can't judge it. On a repository that outsiders can comment on, run the triage and the repair sandboxed. On a remote worker, the worker's own environment applies.

Things to know

Unreleased

  • With client: cli, replies post under your own login.
  • CodeRabbit may turn a reply into a standing learning.
  • A workflow on pull_request_review_comment or pull_request_review runs on every reply, and Kraft waits for its checks, up to the round's time.
  • Plain-word ChatOps commands aren't neutralised. Kraft only defeats a parser that reads the first word of a line.
  • Copilot's login differs between REST and GraphQL.
  • An App token that can't read its own login defers every post.
  • A bot that never answers costs the reply timeout.

What is verified

Unreleased

GitHub and GitLab are both covered by the real-forge contract tests and one real walk each. Real bot behaviour and timing aren't verified, and neither is GitLab's "auto-resolve outdated threads" setting.

A bot that reviews late, or only on green CI

Unreleased

The default chain waits for the bots for 10 minutes after each push, watching CI meanwhile. A bot that posts later, or only once CI passes, isn't read on that push.

To raise the limit, replace the review step's task. An override of the task's own policy: can only lower a cap, and Kraft refuses one that raises it. A chain written before this release that set a cap above 10 there is refused for that reason.

config/chains/reviewed.yaml
overrides:
  merge_request_feedback.automated_review:
    tasks:
      - id: await_review
        extends: kraft-default:await_automated_review
        config:
          watch_ci: true

This gives the library's 30 minutes. Add policy: {total_time_cap_minutes: N} on the task for another limit.

For a bot that reviews only on green CI, put CI first with the node's own steps:. Leave config.watch_ci off there: Kraft refuses it unless an mr.ci task comes after the wait. The paths don't change.

config/chains/reviewed.yaml
overrides:
  merge_request_feedback:
    steps:
      - id: ci
        tasks:
          - id: await_ci
            extends: kraft-default:await_mr_ci
      - id: automated_review
        tasks:
          - id: await_review
            extends: kraft-default:await_automated_review
      - id: review_feedback
        read_only: true
        tasks:
          - id: triage
            extends: kraft-default:triage_review_feedback

A bot that is always slower than the limit is recorded as never having posted. After three items, kraft admin doctor's review bots row names it as possibly misconfigured. Either change above clears the row once the bot is heard.

Next steps

Copyright © 2026