The agent protocol
What an agent does on entry, during work, and on exit — the Agent role in practice, and the skill that teaches it.
The normative version
This is the Agent role of the specification in practice. The bundled skill teaches it to agents; the harness hooks make it automatic.
The CLI is usable by a person, but it exists because agents need somewhere to put state
that outlives a context window. The protocol is short: one session token on every
command, enter through mine and resume, claim before working, keep state.md
current, and leave through pause, handoff or done.
The skill
tasks init installs an agent skill into
.claude/skills/tasks/. It is what makes an agent reach for this CLI on its own rather
than inventing a TODO.md: it carries the protocol on this page, the command table, the
JSON contract, and what to do when something looks wrong.
tasks skill install [--force]Add it to a project that predates it, or refresh it after upgrading the CLI, with the
command above. An existing install is left alone unless --force, so local edits
survive. Commit .claude/skills/tasks/ so every agent working in the repository gets it;
tasks init --no-skill scaffolds a tree without it.
The session token
An agent acts as the actor agent — the conventional name, unless the tree's
roster names it otherwise — with a session
token on every command. A claim taken without one has unknown liveness: nobody takes it
over without a force, and the agent's own next session can only pause it, as the same
actor, and claim it again.
Subagents act under the same name and token as the agent that spawned them.
- With the harness hooks,
TASKS_SESSIONandTASKS_ACTORare exported for every shell command of the session, and the agent passes nothing. - Without them, the agent generates one token at the start of the session — a UUID
or
date +%s, matching^[A-Za-z0-9][A-Za-z0-9._@+-]*$(an ISO timestamp's colons fail it) — and runs every command asTASKS_ACTOR=agent tasks … --session <token>. Shell state often does not survive between an agent's tool calls, so the prefix and the flag are safer than anexport. WithoutTASKS_ACTORthe agent acts under the repository's git identity, which is the person's: it works, but the log cannot tell the two apart, and a task assigned toagentnever reaches it.
The actor names who acted; the session names which run. Two sessions of the same agent
are the same actor, and the log, the liveness rules and mine tell them apart by token.
Your name comes from the environment, not from the roster: TASKS_ACTOR when the harness
set it, else agent. tasks actors is for choosing a person to hand a task to; a team
that named its agent otherwise (an actor of type: agent) tells you so. Without the hooks,
a long stretch with no tasks command — reading code, running tests — lets your claim go
orphaned for everyone else after session_timeout_minutes (30 by default), and another
agent may take it: run tasks heartbeat --session <token> in such a stretch, or any
command; a state write counts.
Entry
Run tasks mine
tasks mine --jsonIt lists your claims first — this session's, then older ones — and then the tasks merely
assigned to you — your inbox — each with its last log entry, its last activity. What was left
for you is in the task's files: ## Notes of task.md, design.md, state.md; resume
shows them.
- Continue a task claimed by this session.
- Then the highest effective priority among your orphaned claims (
liveness: "orphaned", from an older session of yours) and your inbox; at equal priority finish your orphan before starting inbox work, and a person's instruction — in the conversation or under## Notes— names what comes first. Take over an orphan with an ordinarytasks claim <task>, which records the takeover: one at a time, only what you will work on now; the others stay orphaned, which is no breakage. - A task held by another live session is not yours.
- A claim of unknown liveness is reported to the person, never forced.
- Another actor's orphaned claim is taken over only on the person's instruction.
- New work comes last:
tasks claim --next.
Run tasks resume and read in order
tasks resume <task>Read, in this order: task.md, state.md, design.md, plan.md — then, for each
ancestor as far as needed, its task.md, design.md and plan.md. An epic's design and
plan live on the epic. resume lists the ancestors outermost first, with the workspace
files each one has.
Do not read log.md on entry. The present is fully described by the other files;
the last entry — the last activity — is already in the resume output. If a person's text
reached you only there, put it under ## Notes with tasks note before you claim.
Claim before working
tasks claim --next # the first task of your ready set, claimed in one step
tasks claim <task> # a specific taskThe claim is what stops a second agent starting the same task, and it is only useful if
it happens first. Claim before working, read before changing: your own orphan is claimed
first — the takeover restores your hold — and resumed after; new work is claim --next
then resume, or resume the candidates and claim <task> by id when you choose. A
conflict (exit 4) means another agent was first: move on to the next ready task. Never
reach for --force to win a claim.
Leave unavailable projects to the person
A listed project the commands cannot read — not shown on stderr, unavailable in the
JSON: a v1 tree, a repository not checked out here — is a person's to migrate or check
out. Say so once in your report and go on.
During work
-
Never hand-edit frontmatter. Every field has a command. The body below it is yours; edit it with ordinary file tools.
-
Never move a task directory by hand. Its id is its path; use
tasks move, which rewrites the references. -
Write
state.mdthroughtasks state, so the write is fenced like a transition: a session whose claim was taken over learns of it before it overwrites the new claimant's file.tasks state <task> < state.md -
Put each input where it belongs. A clarification of the statement changes
DescriptionorAcceptance criteriain place; an input received after the start goes to## Notes; a decision goes todesign.md; a change of plan goes toplan.md. -
A follow-up that is not part of the deliverable becomes a separate
BACKLOGtask outside the parent (tasks new <path> "<title>" --backlog), linking to the context in its body. -
A step a person must take — a review, an approval, a deploy — is a
handoffto that person when it concerns this task, and a separate task assigned to them (--assign) only when other tasks must depend on it.tasks actorssays who they are and how they are named; a refused name is corrected, never added toconfig.ymlon your own. -
Children are parts of the deliverable, never phases. No child for planning, review or verification: the plan is
plan.md, the review is ahandoff. -
A task with open children is never cancelled, deferred or archived on the agent's own initiative. Such a decision comes as a person's instruction, quoted in the message.
-
--asonly on an explicit instruction from that actor, given in the current session, and the message quotes it. Never use--asto satisfy an assignee rule on your own initiative. -
The freshness rule: every turn in which the work progressed ends with
state.mdupdated. The status staysIN_PROGRESSbetween turns.
Exit
-
An input for whoever works next — a decision taken, a fact learned, a link — goes under
## Notesoftask.md:tasks note <task> "<text>"appends it dated and attributed, and logs it. A message alone is history: the next entry displaces it. -
A turn is not a session. A turn ends with the claim kept and
state.mdfresh whenever you expect to continue in this conversation — waiting for the person's answer included. The session ends withpause,handoffordone: the conversation closes, the harness stops you, or the task passes to someone. A task that cannot move without a person's decision is ahandoffto them, the question in the message and under## Notes. Not sure you will be back?pause: your pause frees the task; an orphan is what to avoid. -
A deliberate end of work is
pause,handoffordone, each with a message. The message is the history line; the resume point isstate.md. Never end a session deliberately with a taskIN_PROGRESS.tasks pause <task> -m "Parser done and tested, commit 4f1c2e on parser; the CLI flag is next (see state.md)." tasks handoff <task> alice -m "Ready for review: design.md has the two options." tasks done <task> -m "Merged: commit abc123 on main; docs: engineering/auth.md updated." -
pauseandhandoffare refused without astate.md;releaseis only for a claim that produced nothing. -
state.mdnames, under Open, every uncommitted file and branch the work leaves behind. -
Name your commits in the log. Every commit made for the task goes into its log before the work ends: in the
pause,handoffordonemessage, or earlier withtasks log <task> "commit <hash> on <branch>: <what>"when a turn produced one; add the repository when it is not this one. Where the project's commit convention allows it, the commit message names the task's id too (aTask: <id>trailer, or in the subject), so a commit leads back to its task as the task leads to its commits. -
Promote knowledge before
done. What must outlive the task goes into the project's documentation; the task directory is working memory, not documentation. Whenconfig.ymllistsdocs,tasks resumeshows where that documentation lives, and beforedonethe agent brings the listed documents that describe what the task changed up to date — within the task's scope, never a general revision — and says in the message what changed, or that nothing needed to. A location absent on this machine is named in the message instead; a change in another repository that has not landed is named too, and stays under Open instate.mdwith its branch while the task is open. -
Project state lives only in the tree. An agent's private memory keeps preferences and reference facts, never the state of a task.
Approval of a plan
The hold gives an epic its approval gate without a procedural child:
tasks claim auth-rework # the planner takes the epic
# write design.md and plan.md, then create the parts — held by the claimed epic
tasks new auth-rework/token-schema "Design the token schema"
tasks new auth-rework/wire-refresh "Wire the refresh endpoint"
tasks state auth-rework < state.md
tasks handoff auth-rework alice -m "Plan ready for review."While the epic is claimed or assigned, nothing beneath it is ready. The approver either
releases the children with tasks unassign auth-rework -m "APPLY", or sends the plan back
with tasks note auth-rework "Split the refresh work in two." and
tasks assign auth-rework agent, which keeps them held until the planner reworks it and hands
it off again: the instruction sits under ## Notes, where the planner reads it, and the
assignment is the history line.
A task that is not being worked
Every case maps to a stored status plus what overviews show:
| Case | Stored | Shown |
|---|---|---|
| not started, free | TODO | ready |
| not started, waits for a task | TODO + depends_on | blocked by X |
| not started, not scheduled | BACKLOG | backlog |
| a specific person's own step (deploy, release) | TODO + assignee | assigned alice |
| being worked | IN_PROGRESS | working by agent · live |
| session ended deliberately, work unfinished | pause → PAUSED | ready · started, first in ready |
| a person stops, meaning to come back | pause → PAUSED + assignee | waiting for alice; her unassign or handoff releases it |
session ended without pause, or crashed | IN_PROGRESS | working by agent · orphaned since T; the next session takes over |
| started, waits for a task | pause + dep add → PAUSED | blocked by X · started |
| started, needs a decision or review | handoff alice → PAUSED | waiting for alice |
| started, set aside | pause, then defer → BACKLOG | parked; schedule brings it back to PAUSED |
| started, decided not to do | cancel | cancelled |
| finished, awaits confirmation | handoff alice → PAUSED | waiting for alice; her done confirms it |
| an epic whose child is being worked | TODO or PAUSED | open 2/5 · active |
| an epic whose plan awaits approval | handoff alice → PAUSED | waiting for alice; children held by it |
When something looks wrong
- Run
tasks validate --jsonbefore hand-repairing anything. See validation. - A conflict means someone else was first — another agent's claim, a cascade, a
takeover of your own stale session. Re-read with
tasks resumeand move on. - Never
--forceon your own initiative. It is for a person's explicit decision, and the log records every forced transition (a forcedstatewrite is not logged). - Never hand-edit frontmatter, never
mva task directory. Both bypass the checks that keep the tree trustworthy. - If
tasksis not onPATH, usenpx @speekl/tasksin its place. Exit3with no.tasks/found means the project is not set up: ask before runningtasks init— creating a tree is a project-level decision — and ask whom to list as actors:tasks init --actors <person>,agentwrites the roster at once.