CLI contract
Streams, exit codes, the error envelope, JSON shapes, and commands, for implementations that expose a command line.
This section applies to an implementation that exposes a command line. A library, an editor plugin or an MCP server MUST satisfy every other section and MAY ignore this one; an implementation that exposes a command line and claims conformance MUST satisfy it in full.
Streams, structured output, exit codes
Unchanged from v1: stdout carries successful output only, stderr errors and diagnostics only;
every command that produces output MUST accept --json, under which success is one JSON document
on stdout and an error is one JSON document on stderr in the envelope below and nothing else (a
diagnostic the command would print for a person is dropped); without --json, output is
unspecified and MUST NOT be parsed. validate and session-check report a failing verdict as
their result document on stdout with exit 4, not as an error (see
their output).
| Code | Name | Meaning |
|---|---|---|
0 | success | The command completed. An empty result set is success. |
1 | internal | An unexpected failure in the implementation. |
2 | usage | Invalid invocation or configuration: unknown flag, malformed reference, ambiguous suffix, missing required message, invalid config.yml, unsupported version, a v1 tree for any command that opens it (every command but migrate, skill install and hooks install), an actor or session that does not match its pattern, an actor the tree's roster does not list. |
3 | not found | No tree discovered, no task at the given path, a path that exists only under .archive/, nothing to take for claim --next. |
4 | conflict | The tree's state forbids the command: an illegal transition, an authorization failure, an unsatisfied gate, a missing or present state.md, a claim that is live or unknown, an archive with dependents, a cycle, a reserved path, a session check that fails. |
Errors
{
"error": {
"code": "CONFLICT",
"message": "auth-rework/token-schema is IN_PROGRESS and has no state.md; write it before pausing.",
"details": { "id": "auth-rework/token-schema", "kind": "missing-state" }
}
}error.code is USAGE, NOT_FOUND, CONFLICT or INTERNAL. error.message MUST NOT be
parsed. error.details is OPTIONAL and SHOULD carry the structured facts:
| Failure | SHOULD include |
|---|---|
| Illegal transition | from, to, allowed |
| Authorization | claimed_by, claimed_session, assignee, liveness |
| Unsatisfied start gate | blocked_by with reasons |
| Unsatisfied finish gate | open_children, finishes_after with reasons |
| Cascade over a live or unknown claim | claims (id, claimant, session, liveness) |
Ancestor in BACKLOG, or claimed or assigned | ancestor |
Missing or present state.md | kind |
| Ambiguous suffix | candidates |
| Archive with dependents | dependents |
| An actor the roster does not list | field, value, actors, file |
details.kind names the refusal in one word, so an agent branches on it rather than on the
message. A conflict SHOULD carry one of illegal-transition, authorization, already-claimed,
start-gate, finish-gate, held, backlog-ancestor, backlog-invariant, resolved-ancestor,
open-under-resolved, malformed, malformed-ancestor, malformed-descendants, cascade-claim,
missing-state, present-state, state-changed, not-assigned, not-resolved,
open-descendants, dependents, descendants, history, cycle, ancestor, exists,
reserved, path-blocked, duplicate, collision, same-path, inside-subtree,
interrupted-move, locked, editor; a usage error the option parser raises carries parser. A
later revision MAY add kinds; a kind MUST NOT change meaning. A listed project that cannot be
addressed fails the same way for every command, with argument, project, reason
(not-checked-out, unresolved-project or unsupported-version) and dir, plus version and
upgrade for a v1 tree: not found when the project is absent or holds no tree, usage when its
tree is of another version, and the configuration's own error when that is what fails.
Task object
A command returning a single task MUST emit at least:
{
"id": "auth-rework/token-schema",
"name": "token-schema",
"parent": "auth-rework",
"project": null,
"title": "Design the token schema",
"status": "PAUSED",
"priority": "normal",
"depends_on": ["auth-rework/audit-claims"],
"finishes_after": [],
"assignee": "alice",
"claimed_by": null,
"claimed_at": null,
"claimed_session": null,
"created": "2026-09-21T09:14:00Z",
"updated": "2026-09-21T16:40:12Z",
"path": "/abs/path/.tasks/auth-rework/token-schema"
}path MUST be the absolute path of the task directory. project is the alias of the tree the
task belongs to, or null for the local tree; ids of foreign tasks in aggregated output MUST be
qualified as alias:path.
Commands that report state (show, resume, ready, list, tree, mine) MUST add the
derived conditions: situation (the word of the Situation table), blocked_by (a
list of {ref, reason, status}; empty for a resolved task), ready (for the calling actor), effective_priority, held_by (the nearest claimed or assigned ancestor — or a malformed one, which holds for all anyone can tell — or null; null for a resolved task), started, children
({open, resolved}), active (an IN_PROGRESS descendant exists), waiting_for, closable,
liveness and last_seen (null unless the task is IN_PROGRESS; last_seen is null too for a
claim without a session), and last_entry: the task's most recent log entry
in the shape of log entries without task, or null: the task's last
activity, not a message channel (see log.md). mine MUST render
last_entry. cancel adds dependents: the open tasks,
qualified by alias where foreign, whose depends_on names a task it cancelled (see
Cancellation and deletion interaction). show and resume SHOULD add referenced_by: the live tasks, in
the local tree and in the trees reachable through projects:, whose depends_on or
finishes_after name this task — how a task learns which epic holds it. resume MUST add docs:
the documentation locations the holding tree's config.yml lists
(Configuration), in configured order, each as
{ "name", "path", "present" } — the path as configured and whether it exists on this machine —
and an empty list when none is listed. show and resume MUST add body (the markdown body) and
workspace (the workspace files present, in reading order); resume MUST add ancestors
({ "id", "title", "status", "workspace" }, outermost first), child_tasks (the children as task
objects) and state (state.md in full, or null), leaving a malformed ancestor or child out of
these lists. A transition adds cascaded (the ids a cascade reached) and holds (the open
descendants the task now holds) where they apply.
Collection object
{ "scope": "auth-rework", "projects": ["backend", "cli"], "count": 2, "tasks": [ … ], "malformed": [], "unavailable": [] }scope is the resolved local scope or null; projects lists the aliases spanned (none while a scope is in force); count
equals tasks.length; malformed lists { "path", "message" } for every task directory whose
manifest could not be parsed (see Structure); unavailable lists
{ "alias", "reason" } for every listed project the query could not read — not-checked-out,
unresolved-project or unsupported-version — so an empty project is told from an unread one.
tree emits this same object: a flat
list in which every task carries parent; nesting is how the human-readable rendering presents
it, not a property of the JSON.
Log entries
{ "count": 1, "entries": [ { "task": "auth-rework/token-schema", "time": "2026-09-22T08:02:41Z", "actor": "alice", "via": "agent", "session": null, "text": "done: PAUSED → DONE\nAPPLY. Committed as abc123." } ] }log --since emits entries across the tree(s) in time order, oldest first; task is qualified
with its alias for a foreign tree, via and session are null when the heading has none, and
text is the entry's body below the heading.
Actors object
{ "actor": "agent", "via": null, "projects": ["backend"], "actors": [ { "actor": "alice", "type": "person", "description": "maintainer; approves plans and does releases", "listed": true, "claimed": 1, "assigned": 2 } ], "unavailable": [] }actor and via are the caller's identity as init reports it. actors lists the roster in its
configured order, then by name every other actor an open task of the spanned trees names, and the
caller; each row carries type (person or agent, see Actors),
description (the roster's line, or null), listed, and the open tasks the actor is claimed
on and assigned to. projects and unavailable are as in the
collection object.
Commands
Command names are not contract — only the JSON shapes and exit codes are — but an implementation
SHOULD use these names, and MUST provide each behaviour unless marked OPTIONAL. Every command MUST
accept --as <actor> and --session <token> as the overrides defined under
Sessions and liveness, and SHOULD accept -C <dir> as the starting
directory for discovery.
| Command | Behaviour |
|---|---|
init | Scaffold a tree: config.yml with version: 2, README.md, .gitignore. The caller asks before creating; the command never prompts. Print the resolved actor; MAY write the roster on request (--actors). |
new <path> <title…> [--backlog] [--assign <actor>] [--priority <level>] | Create a task; groups on demand; an existing group at the path becomes the task; refuse an existing task, a resolved parent, a reserved path; --assign names a listed actor when the tree lists actors. |
show <task> [--archived] | The task object with derived conditions and the body; --archived reads a task under .archive/ by its former path in full, the object carrying archived: true. |
resume <task> | The task object; one line per ancestor (id, title, status, workspace files); children with statuses and conditions; the workspace file list; the documentation locations config.yml lists, each with whether it exists here; state.md in full; the last log entry. |
ready [--scope <path>] [--all] [--local] | The ready set for the calling actor in ready order: effective priority, PAUSED first, oldest first. |
mine [--as <actor>] [--local] | Open tasks whose assignee or claimant is the actor, each with its situation, liveness and last log entry. |
actors [--local] | OPTIONAL, RECOMMENDED: the actors config.yml lists, each with its description and its open tasks, then every other actor an open task names, and the caller: the actors object. |
list [--<situation>] [--active] [--depth <n> | --top], tree [--depth <n> | --top] | Overviews by situation; list filters by situation (--parked, --blocked, --waiting, …) and by the active label (--active: an IN_PROGRESS task beneath); tree nests by containment in its human output and renders finishes_after entries under their task, tagged with their project; its JSON is the flat collection object. --depth <n> keeps the tasks whose containment depth is at most n, a task's depth being one more than the number of task ancestors it has within the scope (a listed tree counts from its root); --top is --depth 1: the tasks with no task ancestor there. |
schedule, defer, claim [--next [--scope <path>]], pause -m, release, done -m, cancel -m, reopen -m, handoff <actor> -m, assign <actor>, unassign, priority <level> | The transitions; --force as defined under Force. |
dep add|rm|list <task> [<ref>…] and after add|rm|list <task> [<ref>…] | Edit and inspect depends_on and finishes_after with the mutation constraints; <ref> resolves like <task> (addressing) and is stored in full. |
move <task|group> <destination> | Relocate with reference rewriting in this tree and in listed trees; list the trees it could not write and the references it could not rewrite. |
archive <task> [--force], archive --resolved-before [<when>] | --all-resolved, restore <path>, purge <path> | Archive a resolved subtree, or every resolved subtree of this tree whose root was resolved before a time (a timestamp, a date or a duration back from now), skipping and naming the roots open tasks reference; restore one to a free path, never under a resolved parent; purge an archive entry (see .archive/). |
delete <task> | OPTIONAL: remove a never-worked task without archiving it, under the conditions in .archive/. |
log <task> "<text>", log <task> [--archived], log --since <duration|timestamp> [--local] [--archived] | Append a narrative entry; print one task's entries; list entries across the tree(s) by time as log entries, the archive's included on request. |
note <task> "<text>" | Append a dated, attributed note under ## Notes of the task's body — an input for whoever works on it next — and log it as note; no transition, no authorization (see Body). |
state <task> [--edit] | OPTIONAL, RECOMMENDED: replace state.md with standard input, or open it in the caller's editor with --edit; no transition, no log entry (see state.md). |
heartbeat | Touch the current session's registry file; usage error without a session. |
session-end | Mark the current session ended, orphaning its claims at once, and report them; usage error without a session (see Heartbeats). |
session-check [--as <actor>] | The exit invariant; exit 4 on violations. |
validate [--fix] | The validation findings; --fix regenerates index.md only. |
reindex | Regenerate index.md. |
migrate [<alias>] [--map OLD=NEW …] [--map-phase OLD=NEW …] | The one-time upgrade from v1 of this tree, or of a listed project. |
Validation, session-check and session-end output
{ "ok": false, "checked": 41, "fixed": [], "findings": [ { "severity": "error", "kind": "cycle", "task": "a/b", "message": "…" } ] }
{ "ok": false, "session": "7f3a", "violations": [ { "id": "auth-rework/token-schema", "kind": "missing-state" } ], "warnings": [] }
{ "session": "7f3a", "ended": "2026-09-22T08:02:41Z", "claims": ["auth-rework/token-schema"] }ok MUST be false if and only if at least one finding has error severity or at least one violation exists;
validate exits 4 on errors and 0 on warnings alone; session-check exits 4 on any
violation. session-end lists the tasks whose claims it orphaned and exits 0 even when there
are none.