Library and chains
Chain file keys defines every key a chain or a library component takes; this page maps the files.
library.yaml: reusable components
library.yaml has four sections. Each maps a name to a definition, which any chain takes with extends: <name>.
tasks:
implementer:
kind: agent
harness: claude
profile: strong
prompt: Implement the approved plan.
code_review:
kind: agent
harness: claude
prompt: Review this work item's change for defects its passing tests do not catch.
skill: kraft:code-review
inputs: [review_package]
| Section | Holds |
|---|---|
tasks | Reusable tasks of any kind: agent, subprocess, builtin, forge. |
steps | Reusable ordered groups of tasks. A step may set read_only: true (read_only). |
nodes | Reusable nodes, with their own steps, on_failure, fix_loop and escalation. |
steering | Named guidance (a steering profile), {instructions: "..."}, that an agent task selects with steering: [name] and a repository selects with its repos.yaml steering:. |
The top-level remove: key
Added in 2.3
An add-on that builds on another may add a top-level remove: to its library.yaml, to drop entries it inherits from its parent. It isn't the chain-level remove, which drops nodes from one chain.
remove:
chains: [hotfix]
tasks: [security_scan]
- Its sections are
chains,tasks,steps,nodes,steering,skillsandprofiles, each a list of names. validate, install and update refuse a name the parent doesn't have, and an entry something still in the library uses.- A root add-on, a repo library and your own
library.yamlhave no parent: Kraft refusesremove:there with "remove:is for an add-on that builds on another".
Keys of a library task
Every kind takes scope, steering, on_failure, policy, skippable and icon. Then each kind takes its own keys. A library step or node may set an icon too (Icons).
| Kind | Its own keys |
|---|---|
agent | harness, prompt, skill, produces, profile, model, effort, fallback, inputs, outputs, reads Added in 2.6 |
subprocess | command, outputs, reads Added in 2.6 |
builtin | ref, execution |
forge | target, wait |
Chain file keys defines each key.
Extending a library step
A chain step extends a library step inside a node's steps:. The chain step names its own id. Its tasks come from the library step unless it sets tasks: of its own, which replace them. A component extends one parent of its own kind; the rest of the rule is in The library and extends.
steps:
checks:
tasks:
- id: lint
kind: subprocess
command: just lint
nodes:
- id: verify
kind: exec
steps:
- id: checks
extends: checks # runs verify.checks.lint
Inspect and edit the library
kraft admin templates librarylists every component as<section>.<name>(tasks.implementer) with the chains that use it.kraft admin templates library IDshows one component with its definition and any lint issue that names it.- Templates › Library shows the same and edits the file. Kraft refuses a save that would break any chain that loads today, and writes nothing.
Qualified names
Added in 2.1
An installed Kraft add-on adds its own components and chains beside yours. Each is named <namespace>:<name>, where the namespace is the add-on's name or the alias it was installed under.
nodes:
- id: implementation
kind: exec
tasks:
- id: implement
extends: release:implementer # the add-on's task
extends,steering,skillandprofiletake a qualified name, including theextendsof a node a chain revision or an item draft adds, as does a chain ID wherever one is named:--chain,default_chaininrepos.yaml, a schedule'schain.- A bare name is always your own. A key of
library.yamland a chain'sidnever contain:, and Kraft refuses one that does. - An add-on's components and chains are read-only. Extend one, or copy it into your own library from the Templates screens.
- A later update to the add-on doesn't change a copy.
- A copy of a child add-on's chain or component runs what the child serves, overrides included. What it takes from a parent's entries is written into it, and a skill or profile keeps the name of the add-on that ships it, such as
company:slow. - A repo library's components and chains are read-only in the Templates screens too. Edit them in that repository's
.kraft/. kraft admin templates librarylists an add-on's component with its add-on, astasks.release:implementer (release@acme 1.0.0), andkraft admin templates show release:shipheads the chain the same way.kraft admin templates lint --dir PATHloads no add-on. It prints each reference to one asnot checked (add-on)and doesn't count it as an error.
Names has the whole rule, including what a bare name means inside an add-on.
chains/*.yaml: chain templates
Each file in chains/ is one selectable chain, named by its id (or the file name), with an optional one-line description. The keys are in Chain file keys. Concepts walks through the shipped default and quick-task chains as worked examples.
kraft admin templates show ID --resolvedprints a chain with its library components expanded.- Templates › Chains edits the file itself.
Kraft never overwrites these files on upgrade.
Extending a chain
Added in 2.2
A chain can build on another chain instead of listing its own nodes. It names one parent with extends and changes it with three edits. Everything the edits leave alone is the parent's, read live: a node the parent gains later appears in your chain at the next reload, with no change to your file.
id: team-default
extends: default
description: The default chain, with a security scan and no external approval.
remove: [external_approval]
add:
- after: verification
node:
id: security_scan
kind: exec
tasks:
- id: scan
extends: kraft-default:code_review
prompt: Review the change for security problems only.
overrides:
implementation.main.implement: { profile: deep }
verification: { fix_loop: { max_attempts: 4 } }
final_review: { message: The team lead signs off. }
Kraft applies the edits in this order:
removedrops parent nodes by ID. Each must be one of the parent's nodes.overrideschanges a component by its canonical path: a node (verification), a step (verification.review), a task (implementation.main.implement), a judge (verification.fix_loop.judge). A fix loop,on_failureoron_conflictis reached through its node, asverificationdoes above. A node's override applies before its tasks' overrides.addputs a complete node, written as in any chain file, directly after the parent nodeafternames. Several added after one node keep the order you wrote them in.
An override merges as extends does: a mapping merges key by key, and a list or a single value replaces what it inherited. Setting a task's profile drops an inherited model and effort, and setting tasks on a container written with steps replaces them, or the other way round.
Kraft refuses an extending chain, naming the edit, when:
- it also writes
nodes, or a chain withoutextendswritesremove,addoroverrides; - an edit names a node or path the parent doesn't have, or an added node takes an ID the parent has;
- an override sets
id,kind,extendsorchain_finalizedon a component the parent has, at any depth (fix_loop: { judge: { extends: ... } }on a node that has a judge too): remove the node and add a new one instead. A slot the parent leaves empty, such as theauto_reviewof a gate the parent gives no reviewer, takes a whole new component, as a list the override replaces does; - it removes the parent's final gate (
chain_finalized), or adds a second one, written on the node or inherited through itsextends; - a
reject_toorrestart_fromis left naming a node it removed. Override that pointer to fix it; - its
policywidens the parent's chain policy. It may only tighten it:deny_toolsadds to the parent's list,allowed_toolsnarrows it, and a budget or time cap stays at or under the parent's. Anullcan't clear a key the parent sets. Apolicyinside an override follows the same rule against the node's or task's own policy.
There is no before:, and a parent node can't be moved. To change the order, copy the chain and own its structure.
| The extending chain lives in | Its extends may name |
|---|---|
Your config/chains/ | One of your chains (default), or an installed add-on's (release:ship). Added in 2.2 |
| An add-on | One of the add-on's own chains, never another add-on's. Added in 2.2 |
A chain that extends a chain that extends another is allowed, and each sees its parent with that parent's edits applied. kraft admin templates show ID --resolved prints the result, headed by where each node came from. An extending chain fails on its own: a bad edit, or a parent that doesn't resolve, is reported for that chain, and every other chain still loads.
Changing or ending the parent
- Copying an extending chain copies its file, which still extends the same parent.
- In Templates › Chains, Duplicate › Extend starts a chain under an ID starting
<chain>_ext. - Change base… rewrites
extendsand keeps the edits the new parent can take. The rest are dropped, and the screen lists both first. - Detach… removes
extendsand writes the chain's nodes into the file, so it follows nothing. A node you overrode is written resolved; the others keep their libraryextends. Later changes to the parent no longer reach it.kraft admin templates show ID --resolvedprints the whole chain expanded. - Ctrl/Cmd+Z undoes either.
Placing a step on a machine
Added in 2.4
runner: is a key of a chain, a node and a step: a machine or a group of machines from workers.yaml, any, or local (the default). The most specific wins: step, then node, then chain. A node written as a flat tasks: list is one step. A fix loop, a recovery plan, a judge and an escalation turn follow their node, and a gate's runner: places its automated review. Builtin and forge tasks always run on the server.
A group's name places the step on one of the group's machines that is free, the local worker included when it is a member. An item that no machine of the group could take is refused when it is filed.
An item can override it: the item's own --runner, or one node's --runner, wins over the library. A repo that needs a machine says so through its own .kraft/ library: a chain that sets runner:, made the repo's default chain.
Related
- Write your own chain: add a node with a command task, a fix loop and a judge.
- Move onto kraft-default: take what a new release ships through the built-in.
- Chain file keys: every key of a node, step and task.
- Add-ons and collections: components and chains an installed add-on adds.