Skip to main content
A template is the declarative shape of one operation — the milestones that have to be witnessed for it to count as complete. build and sample assemble receipts against one. Four ship with the CLI: Anything else needs one you write.

Options

template list

Everything build --template will accept — the shipped templates and your project’s own — each labelled with the file build would actually load.
A local template is shown by path rather than by a label, because the path is also the answer to “which one is being used?” when it shadows a shipped template of the same name.

template new

Scaffold a template into .trace/templates/ — the directory build searches first, so the two halves of the loop meet with no flags to configure.
The file it writes is commented and already valid, but deliberately inert: its placeholder event types match nothing, so building against an unedited scaffold returns PARTIAL rather than a clean verdict on an operation nobody has described yet.
A witness may also name the payload fields the event has to carry:
where is a mapping of top-level payload fields to scalars, all of which have to hold. Comparison is strict equality: 1 does not match "1", true does not match 1, and a field the event does not carry never matches. That is the whole grammar — no dotted paths, no comparison operators, no patterns, and an empty where is rejected rather than quietly matching everything. Reach for it where one event type carries the outcome in its payload. Without a condition the stage above closes on a rejected decision as readily as an approved one; listing the type in exceptions instead faults every decision the operation ever took. An exceptions entry is either a bare event type — how the shipped templates write them — or the same { event, where } mapping, for a type that is a fault only under some outcomes. One key is special: role reads the role that observed the event — the one the adapter stamped on it — rather than a payload field of that name.
Without it, any role closes the stage. Reach for it wherever two roles record the same event type for the same operation, as a resource server and a facilitator do: the shipped x402-seller and x402-facilitator templates constrain every witness for exactly that reason. new refuses to overwrite an existing file unless you pass --force, so an edited template is never lost to a repeated command:
Writing over a shipped name is allowed — it is how you adapt a template to a flow that differs from the standard one — but it is said out loud:
The build line new prints carries whichever of --dir and --templates-dir you used, so the follow-up command resolves the file that was just written rather than reading a default root.
Templates are data, not code: a new scenario is a new file plus, if the events are new, a capture adapter — never a change to the assembler. See Operation Receipt for how stages and match-sets shape a verdict.
.trace/templates/ is source you author, unlike .trace/events/ and .trace/receipts/, which are recorded and derived. Ignore those two subdirectories in git rather than .trace/ as a whole, or your templates will not be committed.