Skip to content

Workflow Builder and hooks

The Workflow Builder draws the Companion pipeline as a board: one lane per step, each lane a list of nodes, the blocks of instruction your assistant reads. Open it from the circuit icon at the top of the Specs view, or run SpecKit Companion: Open Workflow Builder.

The Workflow Builder, showing four steps as columns with their phases, nodes and attached hooks.
The run reads left to right. Outside the run, at the far right, holds what takes no turn, such as auto.

Every edit on the board is a change to .specify/companion.yml or a file beside it, and none of it reaches your assistant until you build.

A lane groups its nodes into phases. Anything your project changed carries the same color, so a lane with no color runs as shipped.

Two lanes of the board, specify and plan, with a changed step, a rewritten node, a gate and an attached hook.
The specify and plan lanes, with one rewritten node and one attached hook.
Mark Meaning
changed The step differs from the shipped workflow
yours You rewrote this node, or this routing
gate The node can stop the run
held The node can’t be reordered, because a later node reads what it writes
via <extension> A hook an installed extension attached
+ on a dashed rule Attach a hook there, or open the phase menu

The header counts the same marks for the whole workflow. Its changes chip scrolls to the first lane that differs, and its Living specs chip holds the on/off switch and layout for living specs.

The header with the workflow switcher, the changes chip, the hooks tally and Add step.
The header: the workflow you're on, what differs from shipped, and the hook count.

Docked beside the editor, the lanes stack one under the next and every control still works.

The Workflow Builder docked narrow: the specify step's gather and author phases at the panel's full width, a dashed rule with a plus between steps, and the plan step stacked underneath.
Docked narrow: the phases of specify at the panel's full width, with plan stacked underneath.

Click a node to open its panel. Edit and Save write your version to .specify/companion/nodes/<step>/<node>.md and leave the shipped file alone. More > Use the shipped node deletes your copy.

The side panel showing one node's instructions and facts.
A node's panel: the instructions, then what it writes and what it needs.

To reorder, drag the node or use the Order row. Move to phase… drops it at the nearest edge of the phase you pick.

The panel for the Create the feature branch node, its Order row offering Move up, Move down and Move to phase, with the phase list open on gather, author and classify, each marked Joins the end of it.
The Order row on a node, with the phase list open.

A node with alternatives has a Replace menu, and its hooks move with the replacement. Add node, in a phase’s + menu, offers the add-ons that ship switched off.

The Replace menu offering two alternatives.
Replace swaps a node for one of its alternatives.

The same + menu renames, splits and merges phases. A row that can’t run is greyed out with the reason.

The phase menu open, offering Add hook, Add node, Rename phase, Split phase and Merge.
The phase menu.

A hook is your own work, run before or after a node, a phase or a whole step. There are four kinds.

In the builder In companion.yml What it does
Skill { type: skill, ref: <name> } Asks the assistant to load a skill you already have. Try this first.
Instruction { type: prompt, text: "<instruction>" } One instruction, read at that point
Command { type: command, run: "<shell line>" } A shell line. The assistant needs a terminal.
Node { type: node, ref: <id> } A file at .specify/companion/nodes/<id>.md, reusable in several places

Add hook is in a phase’s + menu, in a node’s panel, and on the dotted slot between nodes. Pick where it runs, then the kind.

The Add hook form: where it runs, then the kind.
Add hook: where it runs, then what kind of work it is.

Drag a hook onto the top or bottom half of a node to run it before or after, or between two hooks to change their order. Hooks at one place run top to bottom. A hook stays inside its own step, and an extension’s hooks don’t move.

A hook being dragged above another, with the drop line showing where it lands.
A hook being dragged above another, with the drop line showing where it lands.

By hand, the same hooks look like this:

commands:
implement:
hooks:
before:
handoff:
- { type: command, run: "npm test" }
- { type: prompt, text: "Confirm the CHANGELOG is updated." }
after:
implement-exec:
- { type: node, ref: review }
- { type: command, run: "npm run e2e", background: true }

handoff and implement-exec are the anchors. An anchor is a node id, a phase name or the step’s own name. background: true starts a hook without waiting for it, which suits tests and notifications and nothing that writes the run record.

The extension ships four nodes you can attach with ref:, covered in Plan blocks.

Nothing executes companion.yml. Your assistant reads it at run time, so a check that must never be skipped belongs in CI.

Situation What happens
No companion.yml Shipped defaults, no warning
The file can’t be parsed Shipped defaults and one warning. Nothing partial is applied.
A hook anchored to a missing node A warning, and that anchor is skipped
A type: node hook with a missing file An error
An extension’s hook marked asks first It doesn’t run unless you ask
An unattended run under Auto A hook that would stop for a person records the checkpoint and carries on

Spec Kit’s own lifecycle hooks (before_plan, after_specify) live in .specify/extensions.yml, and a Companion run fires those too.

specify ends with classify-size, the one branch in the pipeline. As shipped, simple skips plan and tasks, and oversized prints a notice before running everything. Change the routing, at the foot of the lane, opens one row per answer and writes only what you changed:

commands:
specify:
decisions:
classify-size:
simple:
folds: [plan]
warns: ""
Key What it does
folds The steps that answer skips. [] runs everything.
warns A line printed before the run continues. "" prints nothing.

The node declares which answers exist, and a build refuses a folds entry naming a step that doesn’t exist.

The Document shape chip on a step lists each ## section of the template it writes. Pick an alternative for a section, or As shipped. Your own alternatives are files in .specify/companion/fragments/.

The template panel with one row per section.
One row per section of the document the step writes.

Add step, in the header or on the + between two lanes, asks for a name, the step it runs behind and the file it writes. After the next build your assistant runs it as /speckit.companion.<name>.

The New step form.
A new step: its name, where it runs and what it writes.

A workflow is a whole named configuration. Switching swaps node order, hooks, templates and routing together, so a one-line fix and a client deliverable can run differently in one repository.

The New workflow form, offering three whole configurations to start from as cards.
A new workflow starts from what you run today, or from a preset.

Classic spec-kit changes document shapes only, back to P1/P2/P3 stories and the full Technical Context block. Brownfield is for changing an existing system: the spec is written as a delta, the task list is challenged before it runs, and a person opens the result before it counts as done. As shipped, in the Workflow dropdown, parks your configuration without deleting it.

Build writes the command files your assistant loads. Preview build lists which commands would change and writes nothing. A failed build names the step and leaves the working commands as they were.

Path Holds Builder writes
.specify/companion.yml Your changes to the shipped pipeline Yes
.specify/companion/workflows/<name>.yml A named workflow. While one is selected, edits go here. Yes
.specify/companion/nodes/<step>/<node>.md A node you rewrote, or a step you added. _frame.md replaces the step’s preamble. Yes
.specify/companion/fragments/<name>.md A document section you wrote No
.specify/extensions/companion/commands/ What a build produces. Don’t edit it by hand. On build

companion.yml has eight keys:

Key What it does
workflow Names a file under workflows/ that replaces this configuration whole. shipped selects none.
commands.<step>.nodes Replaces the step’s node order. Dropping a node that a kept node reads is an error.
commands.<step>.phases Renames and regroups phases. Every node must sit in exactly one.
commands.<step>.hooks Hooks, by side and anchor
commands.<step>.decisions Routing, by node and answer
commands.<step>.template.sections Maps a template heading to the fragment that replaces it
risk.high, risk.low Paths that make a change high or low risk, on top of the defaults. The tier sets how deep implement reviews the work.
mutation.enabled true runs a mutation check at the end of implement and marks requirements whose tests catch no planted bug as weak. Off by default; it adds minutes.

Without the Companion extension for Spec Kit, the board draws the project’s own workflow: .specify/workflows/ when one is installed, otherwise the /speckit.* commands your assistant has. Build is disabled and nothing is written under .specify/companion/. A hook’s checkbox sets enabled for it in .specify/extensions.yml, and a document shape row opens that template from .specify/templates/.

Nodes, phases and your own hooks arrive with the extension. See Install.