tasks
CLI reference

JSON contract

Exit codes, the error envelope and its details, and every --json shape the CLI emits, with examples.

Explanatory, not normative

The authoritative definition is specification › CLI contract. This page is the same contract for @speekl/tasks, with real examples.

Three things are contract, not implementation. They change only in a major version:

  1. Exit codes
  2. --json output shapes
  3. The .tasks/ on-disk conventions

The human-readable output is not contract. Its layout, colours and wording can change at any time — never parse it.

Streams

Every command that produces output accepts --json.

StreamCarries
stdoutSuccessful output: one JSON document under --json.
stderrErrors and diagnostics: under --json, one error envelope and nothing else.

The split is absolute, so tasks ready --json | jq never chokes on a diagnostic mixed into the stream: a warning a command would print for a person (a configured scope that names nothing, a manifest it could not read, an index.md it could not refresh) is dropped under --json. Two commands answer with a document and a non-zero code: validate with an error finding and session-check with a violation print their result on stdout and exit 4.

Exit codes

0  success      the command completed; an empty result is success
1  internal     an unexpected failure
2  usage        bad invocation or configuration: unknown option, malformed reference,
                ambiguous suffix, missing message, invalid config.yml, unsupported
                version, a v1 tree (local, or a listed project addressed by alias), an
                actor or session that fails its pattern, an
                actor the roster does not list, a command group without its subcommand
3  not found    no tree discovered, no such task, a path only in .archive/,
                nothing for claim --next to take
4  conflict     the tree's state forbids the command: illegal transition, authorization,
                gate, state.md, live claim, cycle, reserved path, archive with
                dependents, failed session check, a busy lock

Branch on the code, never on message text. Messages are written for people and may be reworded in a patch release; codes may not. --help and --version exit 0.

An empty result is success

tasks ready with nothing available exits 0 with "count": 0. "There is nothing to do" is an answer, not a failure — an agent that treats it as an error loops or bails out for no reason. Only claim --next turns an empty ready set into exit 3.

The error envelope

{
  "error": {
    "code": "CONFLICT",
    "message": "auth-rework/token-schema is IN_PROGRESS and has no state.md; write it before pausing (`tasks state auth-rework/token-schema` reads it from stdin).",
    "details": { "id": "auth-rework/token-schema", "kind": "missing-state" }
  }
}
FieldNotes
codeUSAGE (2), NOT_FOUND (3), CONFLICT (4), INTERNAL (1).
messageFor people. Do not parse.
detailsStructured facts about this failure. Present on most errors. Prefer it over the message.

What details carries

Failuredetails
Illegal transitionid, from, to, and allowed: the statuses the command applies to
Authorizationid, claimed_by, claimed_session, assignee, liveness
Unsatisfied start gateid, blocked_by: [{ref, reason, status}]
Unsatisfied finish gateid, open_children, finishes_after: [{ref, reason, status}]
Cascade over a live or unknown claimid, claims: [{id, claimant, session, liveness}]
Ancestor in BACKLOG, claimed or assignedid, ancestor
Missing or present state.mdid, kind
Ambiguous suffixargument, candidates
Archive with dependentsid, dependents
A task that exists only in the archive, or a restore/purge path with nothing archivedid, archived: true
A v1 treetasksDir, version: 1, upgrade: "tasks migrate"
A listed project that cannot be addressedargument, project, reason, dir; version and upgrade for a v1 tree; the same for every command
A busy tree lockkind: "locked", lock, holder ({pid, hostname, timestamp} or null)
An actor the roster does not listfield, value, actors, file

Conflicts also carry details.kind, one word naming the refusal, so a caller can branch without reading the message. An option the parser refuses is a usage error with kind: "parser" and no other detail; an internal error may carry a kind too, such as special-file from move:

kindRefused byWith
illegal-transitiona transition from a status its row excludesfrom, to, allowed
authorizationa transition, state, a gate edit, delete or move by someone the rules excludeclaimed_by, claimed_session, assignee, liveness
already-claimedclaim of a task this session already holdsas authorization
start-gateclaim, doneblocked_by
finish-gatedoneopen_children, finishes_after
heldclaim under a claimed or assigned ancestorancestor
backlog-ancestorclaim, schedule under a BACKLOG ancestorancestor
resolved-ancestorclaim, reopen, new, restore, move under a resolved ancestorancestor, status; task too for restore
cascade-claimdefer, cancel, move over work in progressclaims
missing-statepause, handoff
present-staterelease, delete
not-assignedunassignassignee
malformedany command on a task whose task.md does not parsepath, message
malformed-ancestora command that must read an unreadable ancestorancestor, path; task, ancestor, status: null for restore
malformed-descendantsa cascade, move or restore over unreadable tasksdescendants or tasks
existsnew, restore onto a live task; move onto anything; init over a treeto for move, plus path when a group or directory sits there; path for init
reservednew, move onto a path an archived task reservesarchived (the archive entry's absolute path)
same-path, inside-subtreemove to where the source is, or inside itto
interrupted-movemove of a source that holds a .moving markerpath
path-blockeda file or a symbolic link where a directory must gopath
backlog-invariantnew --backlog, restore that would schedule work under BACKLOGdescendants, or task and ancestor
open-under-resolvedrestore that would leave open work under a resolved tasktask, ancestor, status
duplicate, collisionan archive or restore merge that would hold a file twicedestination, paths
ancestordep add, after add of the task's own ancestor, a move under onefield, ref, ancestor
cycledep add, after add, move that would close a cyclecycle
not-resolvedarchive of an open taskstatus
open-descendantsarchive with open tasks beneathopen_descendants
dependentsarchive without --force, deletedependents; delete adds alternative: "archive"
history, descendantsdelete of a task that was worked, or has tasks beneathentries or descendants, and alternative: "archive"
state-changedstate --edit when the file changed meanwhilekept
editorstate --edit when the editor exits non-zeroeditor, code, signal
lockedany write while another command holds the tree locklock, holder

The migrate refusal

migrate checks the whole tree before it writes anything, and refuses once, with exit 2, listing every problem it found:

{
  "error": {
    "code": "USAGE",
    "message": "Cannot migrate /Users/you/acme-api/.tasks to .tasks v2; nothing was written. Fix these first:\n  - phase \"release_1.2\" is not a v2 directory name …",
    "details": {
      "tasksDir": "/Users/you/acme-api/.tasks",
      "problems": [
        { "kind": "unmapped-phase", "phase": "release_1.2", "message": "phase \"release_1.2\" is not a v2 directory name (^[a-z0-9][a-z0-9-]*$); v1 allowed . and _ in a phase name, v2 does not: rename it with --map-phase release_1.2=<name>" },
        { "kind": "unmapped-status", "status": "REVIEW", "paths": ["/Users/you/acme-api/.tasks/auth/wire-refresh.md"], "message": "…" },
        { "kind": "invalid-value", "path": "/Users/you/acme-api/.tasks/auth/token-schema.md", "field": "claimed_by", "value": "build bot", "message": "…" }
      ]
    }
  }
}
Problem kindMeansWith
malformeda v1 file that does not parse, or a phase directory that is a symbolic linkpath
unmapped-phasea phase name that is not a v2 segment, with no --map-phasephase
unmapped-statusa status outside the v1 roles (or carrying two of them), with no --mapstatus, paths
unknown-mappinga --map or --map-phase naming a status or phase the tree does not haveoption, old
invalid-valuea value v2 cannot hold: an id that is not a segment, a claimed_by that is not an actor, a timestamp that is not ISO 8601, a key v2 defines that v1 did notpath, field, value
claim-fieldsa task mapped to IN_PROGRESS without claimed_by and claimed_at, or claim fields on a task mapped to anything elsepath, status, claimed_by, claimed_at
duplicate-idtwo live, or two archived, v1 tasks with one idid, paths
collisiontwo phases mapped to one name, a destination that already exists, an archived task landing on a live task's path, an existing index.mdpath, paths

Every problem carries a message.

The task object

show, resume, every transition, new, restore and the gate edits emit the task object (state, log, archive, purge, delete and move have shapes of their own): the frontmatter fields, the task's identity, and the absolute path of its directory.

FieldNotes
idThe path relative to .tasks/; alias:path for a task in a listed project.
nameThe last segment.
parentThe id of the nearest ancestor task, or null.
projectThe alias of the task's tree, null for the local tree.
titleThe first # heading of the body, else the name.
status … updatedThe ten frontmatter fields, as stored.
pathThe absolute path of the task directory.

Derived conditions

Reporting commands — show, resume, ready, list, tree, mine — and every command that changes a task add the conditions computed for the calling actor. They are never stored.

FieldNotes
situationOne of done, cancelled, working, parked, backlog, held, waiting, assigned, blocked, closable, open, ready. Its object is in the fields below.
blocked_byUnsatisfied depends_on references: [{ref, reason, status}]; empty for a resolved task.
readyReady for the calling actor.
effective_priorityThe highest of the task's own priority and its ancestors'.
held_byThe nearest claimed or assigned ancestor — or a malformed one, which holds for all anyone can tell — or null; null for a resolved task.
startedA state.md exists on the task or beneath it.
children{open, resolved}: live children by state.
activeA task beneath is IN_PROGRESS.
waiting_forThe assignee of a PAUSED task, else null.
closableAn open task with children or finishes_after whose finish gate is satisfied.
livenessFor IN_PROGRESS: live, orphaned or unknown; else null. last_seen is null too for a claim without a session.
last_seenThe claimant session's last heartbeat, or null.
last_entryThe most recent log entry — {time, actor, via, session, text} — or null.
{
  "id": "auth-rework/wire-refresh",
  "name": "wire-refresh",
  "parent": "auth-rework",
  "project": null,
  "title": "Wire the refresh endpoint",
  "status": "TODO",
  "priority": "normal",
  "depends_on": ["auth-rework/token-schema"],
  "finishes_after": [],
  "assignee": null,
  "claimed_by": null,
  "claimed_at": null,
  "claimed_session": null,
  "created": "2026-10-26T02:55:55Z",
  "updated": "2026-10-26T02:55:55Z",
  "path": "/Users/you/acme-api/.tasks/auth-rework/wire-refresh",
  "situation": "blocked",
  "blocked_by": [
    { "ref": "auth-rework/token-schema", "reason": "not-done", "status": "IN_PROGRESS" }
  ],
  "ready": false,
  "effective_priority": "normal",
  "held_by": null,
  "started": false,
  "children": { "open": 0, "resolved": 0 },
  "active": false,
  "waiting_for": null,
  "closable": false,
  "liveness": null,
  "last_seen": null,
  "last_entry": {
    "time": "2026-10-26T02:55:55Z",
    "actor": "alice",
    "via": null,
    "session": null,
    "text": "dep add: auth-rework/token-schema"
  }
}

A task being worked carries its claim and its liveness:

{
  "id": "auth-rework/token-schema",
  "status": "IN_PROGRESS",
  "claimed_by": "agent",
  "claimed_at": "2026-10-26T02:55:55Z",
  "claimed_session": "7f3a",
  "situation": "working",
  "liveness": "live",
  "last_seen": "2026-10-26T02:55:55Z",
  "…": "…"
}

show and resume

show adds:

FieldNotes
bodyThe markdown body of task.md.
workspaceThe vocabulary files present, in reading order: ["state.md", "log.md"].
referenced_byLive tasks, here and in listed projects, whose depends_on or finishes_after name this task.

resume adds body, workspace and referenced_by too, and:

FieldNotes
ancestorsOutermost first: [{id, title, status, workspace}]; a malformed ancestor is left out.
child_tasksThe children, as task objects with derived conditions; a malformed child is left out (children still counts it).
statestate.md in full, or null.
docsThe documentation locations config.yml lists, in order: [{name, path, present}]; present says whether the path exists here.
{
  "id": "auth-rework/token-schema",
  "status": "PAUSED",
  "situation": "ready",
  "started": true,
  "…": "…",
  "ancestors": [
    { "id": "auth-rework", "title": "Rework authentication", "status": "TODO", "workspace": ["log.md"] }
  ],
  "child_tasks": [],
  "workspace": ["state.md", "log.md"],
  "state": "## Done\n\n- Drafted the claims table in design.md.\n\n## Next\n\n- Decide the refresh-token lifetime.\n",
  "referenced_by": ["auth-rework/wire-refresh"],
  "docs": [{ "name": "engineering", "path": "docs/engineering", "present": true }],
  "body": "# Design the token schema\n\n## Description\n\n## Acceptance criteria\n\n- [ ]\n\n## Notes"
}

Collection object

ready, list, tree and mine share one shape:

{
  "scope": null,
  "projects": ["backend"],
  "count": 2,
  "tasks": [ { "id": "auth-rework/token-schema", "…": "…" }, { "id": "backend:kernel/claims-api", "…": "…" } ],
  "malformed": [
    { "path": "/Users/you/acme-api/.tasks/billing/task.md", "message": "the frontmatter has no closing `---` line" }
  ],
  "unavailable": [
    { "alias": "web", "reason": "not-checked-out" }
  ]
}
FieldNotes
scopeThe resolved local scope, or null.
projectsThe aliases of the listed projects spanned.
countEquals tasks.length.
tasksTask objects with derived conditions, in the command's order.
malformedEvery task directory in the query whose task.md could not be parsed: {path, message}. Such a task is never in tasks, and it blocks whatever references it.
unavailableListed projects the query could not read: {alias, reason}, with not-checked-out, unresolved-project or unsupported-version. The human output prints a line for each; --local spans none.

tree emits the same flat list: every task carries parent, and nesting is only how the human output presents it. --depth and --top choose the rows and nothing else: the shape is the same, and count follows.

Log entries

log --since emits entries across the trees in time order, oldest first:

{
  "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."
    }
  ]
}

task is qualified with its alias for a foreign tree; via and session are null when the heading has none; text is the entry's body below the heading. log <task> "<text>" prints the one entry it appended, in the same shape; log <task> without text prints the task's entries as the entries object; note <task> "<text>" prints the task object with its derived conditions, and show --archived the task object with archived: true. last_entry on a task object is this shape without task.

Transition results

The twelve transitions print the task object with its derived conditions, as the tree reads after the write, plus:

FieldPresent onNotes
cascadeddefer, schedule, cancel, alwaysThe tasks the cascade reached, in tree order; may be [].
dependentscancel, alwaysOpen tasks whose depends_on names a task it cancelled — now stranded.
holdsclaim, assign, handoff, when the count is above 0How many open descendants the task now holds.
{
  "id": "billing/invoices",
  "status": "CANCELLED",
  "situation": "cancelled",
  "…": "…",
  "last_entry": {
    "time": "2026-10-26T02:36:01Z",
    "actor": "agent",
    "via": null,
    "session": "s1",
    "text": "cancel: TODO → CANCELLED\nBilling moves to the payment provider."
  },
  "cascaded": [],
  "dependents": ["billing/reminders"]
}
{
  "id": "search",
  "status": "PAUSED",
  "assignee": "alice",
  "situation": "waiting",
  "waiting_for": "alice",
  "…": "…",
  "holds": 3
}

new, restore, dep add/rm and after add/rm print the task object with derived conditions too.

Other commands

dep list and after list

{
  "id": "billing/reminders",
  "field": "depends_on",
  "refs": [
    {
      "ref": "billing/invoices",
      "project": null,
      "id": "billing/invoices",
      "satisfied": false,
      "reason": "cancelled",
      "status": "CANCELLED"
    }
  ]
}

Every reference, satisfied or not. project is the target's alias, null for the local tree, or its project path for a tree reached without an alias; id is the target inside its own tree; reason is null when satisfied; status is null when the target is not a live, readable task.

actors

{ "actor": "agent", "via": null, "projects": ["backend"], "actors": [ { "actor": "alice", "type": "person", "description": "maintainer; approves plans and does releases", "listed": true, "claimed": 1, "assigned": 2 }, { "actor": "agent", "type": "agent", "description": "the coding agent", "listed": true, "claimed": 0, "assigned": 0 }, { "actor": "zed", "type": "person", "description": null, "listed": false, "claimed": 0, "assigned": 1 } ], "unavailable": [] }

actor and via are the caller, as init reports them. actors lists the roster in its configured order, then by name every other actor an open task names and the caller; type is person or agent (the roster's, or by the name convention for an unlisted one), description is the roster's line or null, listed whether config.yml names the actor, claimed and assigned count the open tasks across the spanned trees. projects and unavailable are as in the collection object.

state

{ "id": "auth-rework/token-schema", "path": "/Users/you/acme-api/.tasks/auth-rework/token-schema/state.md", "bytes": 164 }

move

{
  "from": "kernel/claims-api",
  "to": "api/claims",
  "kind": "task",
  "tasks": [{ "from": "kernel/claims-api", "to": "api/claims" }],
  "deferred": [],
  "rewritten": [
    { "project": null, "task": "kernel/ui-check", "field": "depends_on", "from": "kernel/claims-api", "to": "api/claims" },
    { "project": "web", "task": "session-ui", "field": "depends_on", "from": "../backend:kernel/claims-api", "to": "../backend:api/claims" }
  ],
  "unrewritten": [
    { "project": "../upstream", "task": "publish", "field": "depends_on", "ref": "../backend:kernel/claims-api" }
  ],
  "skipped": []
}
FieldNotes
from, toThe source and the destination, qualified with the alias for a listed project.
kindtask or group.
tasksEvery task that moved, {from, to}, in tree order of the old ids; empty for an empty group.
deferredThe new ids of the tasks a BACKLOG destination deferred.
rewrittenEach reference changed: project is the tree holding it — null for the local tree, else its alias — and from, to the stored forms. The source's tree comes first.
unrewrittenReferences to a moved task found in trees the command could read but not write: project is that tree's alias, or its project path when it is reached without one.
skippedTrees the command could write but did not — their lock stayed busy, or a write failed — as {project, reason}: null for the local tree, else the alias. Their references are in unrewritten.

archive, restore, purge, delete

{ "id": "billing/invoices", "path": "/Users/you/acme-api/.tasks/.archive/billing/invoices", "tasks": ["billing/invoices"], "left_blocked": ["billing/reminders"] }
{ "id": "billing/invoices", "path": "/Users/you/acme-api/.tasks/.archive/billing/invoices", "removed": ["billing/invoices"], "referenced_by": ["billing/reminders"] }
{ "id": "scratch/try-it", "deleted": true }
{ "before": "2026-10-02T10:00:00Z", "archived": [ { "id": "billing/invoices", "path": "/Users/you/acme-api/.tasks/.archive/billing/invoices", "tasks": ["billing/invoices"], "left_blocked": [] } ], "skipped": [ { "id": "auth/old", "reason": "dependents", "dependents": ["auth/new"] } ] }

archive lists every task it archived and, with --force, the live tasks it left blocked. archive --resolved-before and --all-resolved print the last shape: before is the threshold (null for all), archived the single form's results root by root in tree order, and skipped the roots a refusal kept — its kind as reason, its other details beside it. restore prints the restored task object with derived conditions. purge lists the archived tasks it removed and the live tasks whose references now reach a task recreated at that path. delete confirms the removal.

migrate

{
  "tree": "/Users/you/acme-api/.tasks",
  "tasks": 3,
  "archived": 0,
  "phases": { "auth": "auth", "release_1.2": "release-1-2" },
  "statuses": { "PENDING": "TODO", "IN_PROGRESS": "IN_PROGRESS", "REVIEW": "PAUSED", "DONE": "DONE" },
  "rewritten": [
    { "project": null, "task": "auth/wire-refresh", "field": "depends_on", "from": "token-schema", "to": "auth/token-schema" },
    { "project": null, "task": "release-1-2/notes", "field": "depends_on", "from": "wire-refresh", "to": "auth/wire-refresh" }
  ],
  "unrewritten": [
    { "project": null, "task": "release-1-2/notes", "field": "depends_on", "ref": "../upstream:publish" }
  ],
  "readme": "absent",
  "scope": "auth",
  "consequences": [
    "IN_PROGRESS with claimed_session: null, so the liveness of each claim is unknown and a claimant that runs with a session token recovers it only with --force: auth/token-schema",
    "PAUSED without a state.md, which validation reports until one is written (`tasks state <task>`): auth/wire-refresh",
    "kept as written, so blocking until edited (1 reference): release-1-2/notes depends_on ../upstream:publish"
  ]
}
FieldNotes
treeThe migrated .tasks/ directory.
tasks, archivedHow many live and archived tasks were migrated.
phasesEvery v1 phase and its v2 directory name.
statusesEvery v1 status the migration mapped, through a role or --map, and its v2 status.
rewrittenReferences rewritten: the migrated tree's own, then those other trees held into it.
unrewrittenReferences kept as written — they block until someone edits them; project is null for the local tree.
readmereplaced (it was v1's scaffold), kept (it was edited, and still describes v1), or absent.
scopeThe scope written to config.yml, from v1's active_phase; null when there was none or it named no phase.
consequencesWhat a person must know or do, in words — the lines the human output prints with !.

Setup and sessions

{ "actor": "alice", "via": null, "actors": null, "tasksDir": "/Users/you/acme-api/.tasks", "created": ["/Users/you/acme-api/.tasks/config.yml", "…"], "skill": { "installed": true, "dir": "/Users/you/acme-api/.claude/skills/tasks", "files": ["…"] } }
{ "installed": false, "dir": "/Users/you/acme-api/.claude/skills/tasks", "files": [], "skipped": "exists" }
{ "installed": true, "file": "/Users/you/acme-api/.claude/settings.json", "actor": "agent", "written": ["SessionStart", "PostToolUse", "SessionEnd"], "kept": ["Stop"] }
{ "path": "/Users/you/acme-api/.tasks/index.md", "written": true }
{ "session": "7f3a", "touched": ["/Users/you/acme-api/.tasks", "/Users/you/backend/.tasks"] }

In order: init (actors lists the roster --actors wrote, else null; skill is null under --no-skill), skill install, hooks install, reindex, heartbeat. hooks install names in written the events whose tasks hook it added or replaced and in kept those whose tasks hook it left as it was; when it wrote nothing, installed is false and skipped is "exists", as for skill install.

Validation, session-check and session-end

{ "ok": false, "checked": 4, "fixed": [], "findings": [ { "severity": "error", "kind": "cycle", "task": "a", "message": "is in a gate cycle, a → b → a: each task waits for the next, so none of them can ever be done" } ] }
{ "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"] }
  • validate: ok is false if and only if a finding has error severity; checked counts the manifests examined, archived ones included; fixed lists what --fix regenerated — only ever index.md; task is null for a finding about the tree. Exit 4 on errors, 0 on warnings alone. Every kind is on the validation page.
  • session-check: ok is false if and only if there is a violation, and the command then exits 4. session is null when none is known. warnings entries are {id, kind, message} with kind state-older-than-claim or state-older-than-log.
  • session-end: claims lists the tasks whose claims it orphaned; exit 0 even when there are none.

Chaining

Ids are stable, so they are safe to carry between commands:

id=$(tasks ready --json | jq -r '.tasks[0].id // empty')
[ -n "$id" ] && tasks claim "$id" --json

The // empty matters: without it, jq yields the string "null" on an empty queue. Better still, let the CLI pick under the lock, so two agents cannot race for the head of the list:

tasks claim --next --json

Branching on the exit code:

tasks claim "$id" --json >task.json 2>err.json
case $? in
  0) jq -r .id task.json ;;
  3) echo "no such task" ;;
  4) jq -r .error.details.kind err.json ;;   # start-gate, held, authorization, …
  *) cat err.json ;;
esac

Stability

Fields are added, never repurposed. A new key can appear in a minor release, so parse defensively — do not assume an exhaustive set. Removing a field, renaming one, changing an exit code, or changing the on-disk conventions is a major version bump.

On this page