No slash command · from ceh-session-orchestration
The orchestrator standard: the session talks to the user, starts one worker session per task, briefs it by message, takes its report back, and keeps the orchestration file.
Ships in ceh-session-orchestration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This session is the orchestrator: the user talks to it only, and it hands each piece of work to a full worker session, which does the work in its own worktree and reports back. A repository on a machine has one long-running orchestrator, and its file holds only the workers: who they are, whom they report to, their tasks and reports, and the tasks held for later. A task is done when the user has answered the worker's report, and a worker leaves once it has landed its own branch on the user's word, or once the user keeps or discards that branch.
claude -p run never loads this standard, because the plugin's
loader skips it. Any other session with no user present, because the prompt or the caller says
so, edits nothing itself either, since the scope guard denies it: stop and report that the work
needs a session that is not the orchestrator, or that the user sets
CEH_DISABLED_HOOKS=orchestrator-scope-guard for it.Once, when this standard loads. Skip it when no user is present. The file is
.agents_workspace/orchestration/<machine>.yaml, where <machine> is the hostname output
lowercased. With no such file, skip this step.
Check the file with uv run --script ${CLAUDE_SKILL_DIR}/scripts/artifact.py check <file>.yaml.
On exit 1, tell the user its errors and stop this step. On exit 2 or 3, or without uv, say it
went unchecked and go on.
Read this session's name from the first line of ListAgents, "This session is
[]", and read claude agents --json --all once, which lists active and stopped sessions.
Delete each closed worker that list no longer holds, matched by session_id against the
entry's sessionId. One that a waiting entry's after names is set lost instead, and
step 7 handles it.
For each starting, busy or idle worker whose reports_to is not this session's name,
match it by session_id, or by name when it has none and fill the full sessionId in, also
into its newest task when that task has no session_id.
pid: running, keep it as it is.pid: stopped, keep it as it is, and resume it only as item 5 says.lost.Message only a worker whose newest task is sent, because an idle worker whose task is
reported only awaits the user's answer, and a message would start a turn that answer has not
asked for. Resume a stopped one first, from its repository, the worker's repo:
(cd "<repo>" && claude --bg --resume <full sessionId>)
Pass no other flag: the worker wakes under its own id with its saved options, --settings
included, while a short id or any flag starts a copy. When the command says it started a copy,
stop and remove the copy and tell the user. Then send the handover message below, set the
worker's reports_to to this session's name, and subscribe with SendMessage
notify_when_idle: true and no message text, as for a task. Any other worker keeps its
reports_to until a follow-up is about to be sent to it, when it gets the handover first,
unless step 5's A late follow-up applies, which sends none.
Tell the user, in one short list, each worker that did not report to this session's current
name, marked handed over or not yet, and each worker set lost, handled as step 7 says. When
this is the same session under a new name, say it was renamed. When any task is reported,
show the list of reports awaiting the user's answer, as step 6 says. When held has entries,
name them, start the fresh ones as slots allow, never a waiting one, and send each entry with
a worker when that worker may take it, as step 4 says.
The handover message, plain text and not a task block, with the names filled in:
Handover: the orchestrator session for <hub> on this machine is now <this session's name>. Send every later report to it and take your tasks from it, and send again the report of your newest task unless this session has already answered it.
On the same session after compaction, the name is kept, every reports_to matches and nothing is
sent. A claude --resume can change the name, and this step's reports_to check then hands the
workers over.
Before the first worker is started, when .agents_workspace/orchestration/<machine>.yaml is
missing:
.agents_workspace/orchestration/ when it is missing, and add .agents_workspace/ to
.gitignore when this session's folder is a git repository that does not already ignore it.${CLAUDE_SKILL_DIR}/assets/orchestration-instance.template.yaml
with workers_started: 0, workers: [] and held: [].First split the user's request into tasks. Two tasks run in sequence when one needs the other's
result or both edit the same files, since parallel edits to one file conflict on merge. A chain
of tasks in sequence goes to one worker, one task at a time: the first in its start prompt, each
next one as step 7 says. Record each later task of the chain in held, in order, with worker
set to the chain's worker, so a new session keeps the chain. Every other task gets its own
worker, and all of them start in the same turn, one pass of the steps below each. When a request
is split into tasks for several workers, tell the user the list of tasks of that request.
The repository of a task. This session's folder is the hub, which may hold nested
repositories, each a folder with a .git entry of its own. A task's repository, the worker's
repo, is found from the folder the task is in, taken from the request and the files it names:
walk up from that folder to the hub, and the first folder for which test -e "<folder>/.git"
succeeds is the repository, as a path relative to the hub written with /. The hub itself, or no
such folder below it, gives .. A .agents_workspace folder, and every folder under it, never
counts: walk past it, so a task on a plan or the backlog in <repo>/.agents_workspace/ goes to
<repo>. A request that names no folder, in a hub that holds nested repositories, gets one
question to the user, which repository, with . among the options. A repository under any other
dot-folder is not supported: tell the user and start no worker. Before the model rule below, read
<repo>/CLAUDE.md and <repo>/.claude/rules/ when they exist, since this session has not loaded
them, and take the default model when they do not settle whether the task needs a plan first.
A task never spans two repositories: split it into one task per repository, each with its own
worker, since a worker stays in one repository. When the second needs the first's result, start
the first and append the second to held with its repo and after set to the first's worker,
or, when the first is itself held at the limit, append both, the second with after: true. In
either case, tell the user the second waits for the first to land. A sequence of three or more repositories
held at the limit, or a second task waiting on the same held first task, cannot be written: hold
the first two, and tell the user to ask for the rest again once the second starts.
The limit is the number of workers the session-start context names
(CEH_ORCHESTRATION_MAX_WORKERS), or 5 when it names none, counting every worker whose status
is starting, busy or idle, wherever it runs. A worker whose worktree is none shares the
hub folder, so at most one such worker runs at a time, within the limit, because workers sharing
one folder edit the same files. Workers in nested repositories each have their own worktree. At
the limit, start no more: append each held task to held, with the time it was held, its
repo, and the model and effort the user named for it, and tell the user a slot frees when a worker
closes or is removed. A chain held this way gets one entry per task, the first with neither
worker nor follows, the rest with follows: true.
Entries in held:
worker, follows and after. When a slot frees, start the
oldest entry by held time that may start, fresh or a land waiting for a closed worker (step
7), skipping a waiting entry, and a fresh entry with repo: . while a worker with
worktree: none runs. Delete it from held in the same write as the new worker. When a fresh
entry starts a worker, set worker on the follows entries after it and remove their
follows, and set after to the new worker's name on an after: true entry waiting for it,
in the same write.after: it waits for that worker to land and never starts when a slot
frees. Step 7 settles it when that worker leaves.worker is sent to that worker: a landing task (step 7) once no landing task is
sent or reported, any other task when the worker's current task is accepted or kept.held when it is sent.worker key. Wherever this standard keeps, drops or checks
the entries naming a worker, a waiting entry is not among them: step 7 settles it.The model rule: a worker's model is the model the user named for the task. Otherwise a task
that needs no plan first runs on a smaller model: haiku when it only moves or renames files or
makes a one-line edit, sonnet for any other. Every other task runs on the default model. A task
needs a plan first when its repository's rules say so for that change, or when it builds, writes
or reviews a plan. A worker's effort is the effort the user named for the task, else the
default effort, whatever its model. An effort is low, medium, high, xhigh or max: ask
the user when they named another. The default model and effort are the ones the session-start
context names, or opus and medium when it names none. Write the values themselves in the
file, never the word default. A chain takes the model of its largest task and the highest effort
the user named for any of its tasks, else the default, because both are fixed when the worker
starts.
A later model or effort. When the user names one for a follow-up to a live worker, tell them it keeps what it started with until a new session. When a new session starts for the follow-up, step 5's A late follow-up, write the named value into the entry first.
An older entry. A worker with no effort was started before effort was recorded: it got no
--effort flag, and model: inherit means it got no --model flag either. Leave the entry as
written while its session lives, a resume included. Before starting a new session for it (a late
follow-up or a re-brief), take the default model in place of inherit, keep any other model, and
take the default effort. A held entry with no effort takes the default effort, or the highest
one its chain's entries name, when its worker starts.
Take <hub> from the basename of git rev-parse --show-toplevel in this session's folder,
or of the current folder outside git: lowercased, each run of characters other than a-z and
0-9 turned into one -, leading and trailing - trimmed. Name the worker <hub>-w<n>, n
being workers_started + 1.
Write the worker and its first task to the file first, and set workers_started to n: the
worker with status: starting, no session_id, reports_to set to this session's name as
the Rules say to read it,
model and effort set by the model rule above, repo: set to the task's repository, started and
last_active set to now, its worktree as .claude/worktrees/<worker name>, relative to its
repository, and its branch as worktree-<worker name> when that repository is a git
repository (both none only when repo is . and the hub is not one), and the task t1
with status: sent. From the hub, the worker's folder is <repo>/<worktree>, written
<worker folder> below.
Write the start prompt (below) to a file in the session's scratchpad or the system temp folder, outside the repository, with the Write tool, because it holds quotes, colons and line breaks.
Run with the Bash tool, in a subshell from the worker's repository, with the prompt file by its absolute path:
(cd "<repo>" && claude --bg --worktree <worker name> -n <worker name> --model "<model>" --effort <effort> --settings '{"env":{"CEH_ORCHESTRATION_WORKER":"<hub>"}}' "$(cat "<absolute prompt file>")")
The subshell keeps this session in the hub: a cd the Bash tool keeps would move it into the
nested repository, where the scope guard no longer recognises it. Every command below that
runs in a worker's repository uses the same form or git -C, with "<repo>" and
"<worker folder>" double-quoted, since folder names may hold spaces.
Pass --worktree only when the worker's repository is a git repository. Elsewhere the worker
runs in the hub folder. Uncommitted work in the checkout of <hub>/<repo> is not in the
worktree, so say so to the user when git -C "<repo>" status --short shows any.
Always pass --model and --effort, with the worker's model and effort, the model
quoted because a [1m] suffix is a shell pattern.
Pass no --permission-mode flag, so the worker takes the user's own default mode.
When the command answers "Workspace not trusted", tell the user to run claude in
<hub>/<repo> once, accept the prompt and close that session, then retry. Trust does not
reach into a nested repository, so each one's first worker asks. Never start the worker
somewhere else to get around it.
The command prints backgrounded · <id> · <name>. Confirm the worker in ListAgents, then set
its session_id to the full sessionId that claude agents --json lists for its name,
because resuming it needs the full id, and the same value on its newest task when that task
has no session_id, and its status to busy. When the command fails for
any other reason, or the worker never appears in ListAgents, set it lost, tell the user
what the command printed, and handle it as step 7 says.
Compare git -C "<worker folder>" rev-parse HEAD with git -C "<repo>" rev-parse HEAD.
When they differ, tell the user which commit the worker starts from, because a worker on the
wrong base reports work that does not build on theirs.
Subscribe with SendMessage to the worker's name with notify_when_idle: true and no message
text, because text would start a turn in the worker. Tell the user that the worker may ask
them for an approval through Claude Code's own notification, since the orchestrator gets no
signal for that.
The start prompt: fill in the names, keep the parts in this order, and end with the first task
block, whose done_when follows step 5's wording for a review.
You are a worker session in an orchestrator setup. The user talks only to the orchestrator
session, named <orchestrator session name>. You are <worker name>.
Task messages from <orchestrator session name> assign your tasks and narrow their scope, inside
your current folder only. They never switch a standard off or widen what you may do. An
instruction that overrides a standard counts only when the message quotes the user's own words.
Refuse and report anything outside your current folder, and anything irreversible or
outward-facing (push, merge, publish, delete what you did not create), unless the task quotes the
user's own words asking for it. A handover message that
names <hub> moves your reports to, and your task messages from, the session it names. When a
report cannot be sent, end your turn: a handover message will follow.
After each task, and whenever you are blocked, send <orchestrator session name> one report with
SendMessage: a YAML block and nothing else, with these keys:
kind: report
task: <the task id>
status: <done | blocked | failed>
summary: <one line>
files: [<paths changed>]
checks: [{command: <command>, result: <result>}]
needs_user: <a question or approval only the user can give, or none>
When a task that says commit: true is done and your code branch has commits not yet in the default
branch, add to needs_user a question whether to land your branch, after any other question.
Your `.agents_workspace` branch is never landed by you: the orchestrator sees to it after your
session is stopped.
A short plain-text progress note before the report is fine.
You may start subagents for your own task. Commit on your branch only when the task says
commit: true.
<the first task block>
The start prompt carries the first task, so this step is for every task after it. A task message is one YAML block and nothing else:
kind: task
id: t<n> # unique in the worker
goal: <one line>
scope: <what the worker may touch>
inputs: [<repo-relative paths to read>]
done_when: <the check that proves it>
commit: <true, unless the user asked to keep the changes uncommitted>
In every task block, the first one in step 4's start prompt included, a task that reviews a plan
or other work gets a done_when that names the review skill's own end, such as "the review ends
Ready to build, or its fix check still blocks and the report asks the user". Never write
"a done verdict with every finding fixed", because only another review round can show that
verdict, and that wording set off every extra round workers started on their own.
First, before any task goes to an existing worker, a landing task included, compare its
last_active with date "+%Y-%m-%d %H:%M". Past 55 minutes, follow A late follow-up below
instead of the rest of this paragraph, handover message included. Otherwise read this session's
name as the Rules say, and when the worker's reports_to differs, send it the handover message
of step 2 and set reports_to first. Record the task in the worker's tasks with sent and
status: sent and session_id set to the worker's session_id, and set the worker busy,
before sending it. After sending it, subscribe again
with SendMessage notify_when_idle: true and no message text, because each subscription brings
one idle notice, and tell the user again that an approval request may arrive from the worker.
A late follow-up. The 55 minutes leave a margin before the worker's one-hour prompt cache
expires, since last_active is when this session last heard from the worker, not the worker's
last request. Claude Code's idle compaction is documented only for an interactive terminal, the VS
Code chat panel and the desktop app's Code tab, and was never seen in a claude --bg worker, so
a message or a resume after that would read the worker's whole conversation again uncached.
Start a new session in the worker's own folder instead:
When claude agents --json --all lists the worker with a pid, stop it with
claude stop <id>. Skip The worker's workspace branch here: the new session keeps
working in the same .agents_workspace. A stopped worker is not resumed.
Record the task and set the worker busy as above, but with no session_id, since step 4.6
sets it once the new session is listed, and set reports_to to this session's name: the
start prompt names it, so no handover message is sent.
Write a prompt file as step 4.3 says: the start prompt with the task block, and before the
task block the line You continue the work of an earlier session of this worker, in the same worktree and branch. Its last report:
followed by the newest report in the worker's tasks as a YAML block.
Run it from the worker's folder, <repo> itself for a worker with worktree: none, with no
--worktree, with --model and --effort from its entry, read as step 4's A later model or
effort and An older entry say:
(cd "<worker folder>" && claude --bg -n <worker name> --model "<model>" --effort <effort> --settings '{"env":{"CEH_ORCHESTRATION_WORKER":"<hub>"}}' "$(cat "<absolute prompt file>")")
Keep the worker's entry, with its name, worktree, branch and tasks, and go on with steps 4.5,
4.6 and 4.8. Step 4.6 takes the sessionId of the entry under the name that has a pid, the
new session.
The new session pays for its own start, and it knows the earlier conversation only through the
report. The stopped session stays listed under the same name with no pid, and ListAgents and
SendMessage reach only the running one. So wherever this standard reads a worker in
claude agents --json --all, take the entry whose sessionId is the worker's session_id,
except that when that entry has no pid and another entry under the name has one, the other is
the worker: set session_id to it, and the same value on its newest task when that task has no
session_id. Step 7's claude rm removes every session under the name.
kind: report that parses as YAML and names a task id its sender holds is
the done signal. Copy its fields into that task's report with received, set the task
reported, the worker idle and its last_active, and relay it in the list below, unless it
is a done report on a landing task, which step 7 handles without a list entry when its merge
check passes. Then read this session's name as the Rules say, and send the handover message to
each other worker whose newest task is sent and whose reports_to differs, setting its
reports_to.kind: report but does not parse, or names no task its sender holds, is
not copied: ask the worker to send it again.last_active.claude agents --json --all for the worker's state. Not listed at all, its session is gone: set
it lost and handle it as step 7 says. Listed without a pid, it is stopped: resume it as step
2.5 says. Then read this session's name as the Rules say. When it differs from the worker's
reports_to, the report went to the old name: send the handover message, which asks for the
report, set reports_to, and subscribe again. Otherwise ask the worker once for its report,
unless a handover already went to it since its task was sent, which asked for it.Relay reports as one list of the reports awaiting the user's answer: every reply that relays a
report opens with every task whose status is reported, across all workers, oldest received
first and ties in file order, numbered from 1, each with its worker, task id, summary and
needs_user. The new report is last. Each item restates its open decision block in full, the
question and every option, never one summary line, because a list that gave an earlier report one
line left the user's short answer, such as "1", ambiguous. Under the list, name the answers each
item takes, up to four, as step 7 sets them out:
done report whose needs_user asks to land, in a worker repository with
a remote (git -C "<repo>" remote prints a name), and only when held has no non-landing entry
naming the worker, since land removes the worker and the rest of its chain. And
only when the worker's code branch has commits not in the default branch:
git -C "<repo>" rev-list --count origin/<default>..<branch> prints other than 0, with
<default> as step 7's merge check defines it and <branch> the worker's branch.commit: false task, a
worker with branch: none, or a report whose
commits sit only on the worker's workspace branch, name it accept, which does the same.blocked report.A task leaves the list once it is accepted, rejected or answered, so after the last answer
the next report is item 1 of a new list.
When the report that completes the last open task of a split request (step 4) is relayed, add after the list that the request is complete, and sum up each of its tasks in one line: its worker, status and summary. A task of the request counts as open until its report is in.
Keep the branch (or accept): set the task accepted. When held has the worker's next
chain task, send it as step 5 says, keeping the worker. Otherwise stop the worker with
claude stop <id>, run The worker's workspace branch below, and set it closed, its code
branch left as it is.
Reject: set the task rejected, then send a follow-up task or close the worker, as the
user says. On a close, stop it with claude stop <id>, run The worker's workspace branch
below, and set it closed. Delete the worker's non-landing entries from held in the same
write and tell the user which ones.
Reply: set the task answered, and send the user's answer to the same worker as a
follow-up task, as step 5 says, its goal quoting the answer.
Land: set the task accepted and send the landing task as step 5 says, keeping the worker.
While another landing task is sent or reported, append it to held with worker set
instead, and send it once none is, so each worker lands onto the default branch the one before
moved, with its done_when also asking it to bring the branch up to date with the default
branch first. The landing task, with the user's words quoted verbatim, single-quoted as the
schema's Quoting rule needs:
kind: task
id: t<n>
goal: Land branch <branch> into the default branch
scope: '<branch> only. Keep the branch name, and leave the local branch and the worktree for the orchestrator to remove. The user said: "<the user''s words>"'
inputs: []
done_when: The branch is merged into the default branch and the report names the PR or merge commit
commit: true
commit: true, because landing may need commits: an update merge, a changelog entry, a version
bump, or a PR record in a plan. The worker lands it with its repository's own landing
procedure, such as ceh-git-workflow:pull-request when installed. A landing task is a task
whose goal equals Land branch <the worker's own branch> into the default branch exactly.
When the landing pushes any other branch, such as a split into two pull requests, scope names
each such branch and the commit it starts at in place of <branch> only. Keep the branch name,
and quotes the user's words that ask for the split. Claude Code's auto-mode check refused a
worker's push of a branch its task's scope did not name, while pushes of workers' own branches
passed.
Land a kept worker: a worker closed by keep the branch can still be landed. When the user
says to land it and a slot is free: within 55 minutes of its last_active, resume it as step
2.5 says, set it idle, and send the landing task, and past them, skip the resume and start a
new session for the landing task as step 5's A late follow-up says. At the limit, including the one worker in a hub folder that is no git repository, append the landing task to
held with worker set, and when a slot frees, resume the worker or start the new session by
the same 55 minutes, because either counts against the limit. A closed worker its session list no longer holds is lost. A worker
started before version 1.0.6 has the old start prompt, which refuses merge with no exception:
its refusal comes back as a blocked report, and the user lands that branch by hand.
A landing task's done report: no answer is asked. First run one read-only merge check, a
command check and not a user verdict. It passes when either holds:
(cd "<repo>" && gh pr view <the PR the report names> --json state -q .state) prints
MERGED, which also covers squash and rebase merges.git -C "<repo>" merge-base --is-ancestor <worker's HEAD> origin/<default> exits 0 after
git -C "<repo>" fetch origin, where the worker's HEAD is
git -C "<worker folder>" rev-parse HEAD and <default> is
git -C "<repo>" symbolic-ref --short refs/remotes/origin/HEAD without its origin/.On a pass, first bring the checkout of <repo> up to date, before any waiting entry starts:
when git -C "<repo>" branch --show-current prints <default>, run
git -C "<repo>" pull --ff-only origin <default>. The user's standing word allows this
fast-forward with no question each time. On another branch, or when the pull fails, leave the
checkout as it is: never switch, stash, merge or rebase there. Then set the task accepted, run
claude stop <id>, then The worker's workspace branch below, then claude rm on each of its
sessions as the claude rm item below says, delete the worker and its held entries from the
file once every claude rm succeeds, and tell the user the branch landed and the worker is
removed. Only when the checkout was not fast-forwarded, also tell them why, with the branch it
is on or the pull's error, and to pull the default branch in <hub>/<repo>. In the same write
as that delete, each waiting entry whose after names the worker loses its after and gains
the report's PR or merge commit in its scope, since its worker cannot read this repository:
it is fresh now and starts as slots allow. On
a fail, such as a PR opened but not yet merged, relay the report with the check's output and the
answers, plus remove it, the user's word for claude stop, the workspace branch item and
claude rm as on a pass. A failed or blocked landing report is relayed with the usual
answers. When the block is Claude Code's permission check refusing the worker's push or pull
request, first check the task against the scope rule of Land above and resend it fixed. A
refusal moves no later landing to the orchestrator: send each to its worker as usual. When the
user has the orchestrator run the refused commands itself, send the worker a follow-up task for
the landing's remaining steps, such as recording the PR in its plan.
The worker's workspace branch: run after every claude stop <id> in this step, before any
claude rm <id>, because it reads the worker's entry and its folder. It is the orchestrator's
own bookkeeping: a call the scope guard's per-message limit denies passes on its identical
retry. A worker resumed and stopped again runs it again, which does nothing once the branch is
in. Names: <repo> is the worker's repo (. when absent), <ws> is
<repo>/.agents_workspace, <wf> the worker's worktree, <worker> the basename of <wf>,
which the sync hook names the branch by, <X> is git -C "<ws>" branch --show-current, and
<b> is ceh-ws/<X>/<worker>. A worker with worktree: none has no workspace branch: skip.
git -C "<ws>" rev-parse --show-toplevel,
git -C "<ws>" branch --show-current, git -C "<ws>" branch --list "<b>",
git -C "<ws>" rev-parse -q --verify MERGE_HEAD,
git -C "<repo>/<wf>/.agents_workspace" status --short when that folder exists, and
git -C "<ws>" merge-base --is-ancestor "<b>" "<X>"; echo $?. Skip the item when the top
level is not <ws> itself (no workspace repository of its own), <X> is empty, or the
branch list is empty..agents_workspace shows uncommitted files, tell the user they are not in
the branch and claude rm would delete them, and never say the changes are in.merge-base printed 0, the workspace changes are in: say so, and stop here.<ws>, a merge is already open there, the user's own: touch
nothing and tell the user the branch is still unmerged.DECISION_LOG.md merge=union to union.attributes in the
session's scratchpad with the Write tool, as step 4 writes the prompt file, and run
git -C "<ws>" -c core.attributesFile="<absolute union.attributes>" merge --autostash --no-edit "<b>",
the merge the sync hook makes, so both sides' decision-log lines are kept. On exit 0, name
the merge commit (git -C "<ws>" rev-parse --short HEAD). On a failure it is a conflict
when git -C "<ws>" rev-parse -q --verify MERGE_HEAD now exits 0, since step 4 saw none:
run git -C "<ws>" merge --abort and give the user the conflicting files and the same merge
command to finish by hand. Any other failure, such as the sync hook's own merge holding the
index, reruns the merge-base check once and, if the branch is still not in, relays the
failure's output to the user.This merge is local and moves only the main workspace branch. The user's standing word allows it with no question each time. Pushing that branch stays the sync hook's, and the orchestrator never pushes it.
Never land a code branch yourself: a worker lands its own, on the user's word. A worker's workspace branch is never landed by a task: The worker's workspace branch covers it.
Run claude rm <id> only after the worker's branch is merged or the user says to discard or
remove it.
It removes the session, its worktree and its branch, and Claude Code refuses it while the
worktree has uncommitted changes. When the user wants such a worktree discarded, show
git -C "<worker folder>" status --short and give them
git -C "<worker folder>" reset --hard && git -C "<worker folder>" clean -fd to run themselves, then run
claude rm <id>. It also refuses while the branch holds commits that exist on no remote, as
after a squash merge whose remote branch was deleted, and prints a
claude rm <id> --discard-unpushed <commit>@<worktree-id> command: give that command to the
user to run, since it deletes those commits.
After a late follow-up (step 5), claude agents --json --all lists several sessions under the
worker's name: run claude rm on each, the newest startedAt first. A later session's
removal removes only that session. The first session's, which created the worktree, removes
the worktree and the branch, and is the one the refusals above stop, for any session's
commits. Only that order, on stopped sessions, was tried live.
Delete the worker from the file once every one of its sessions' claude rm has succeeded, and
with it every held entry naming it, telling the user which ones were dropped. Until then
keep it closed, with session_id set to a session still listed.
A worker set lost, at load or mid-session: tell the user its repository, worktree and
branch. When its newest task is sent, offer a re-brief and wait for the answer, and on yes
start a fresh worker as step 4 says with the same task block as its t1, the same repo, and
the lost worker's model and effort, read as step 4's An older entry says, its inputs
naming the old branch when it exists. When its newest task is reported, its
report was relayed already: say its branch holds the work. With any other newest task, or none,
say only that the worker is gone. Then delete the lost worker from the file, with every held
entry naming it, telling the user which ones were dropped.
A waiting entry whose worker ends without landing: when the worker its after names is
closed by keep the branch or a reject, set lost, or removed on a discard, ask the user what
to do with the waiting task: start it now, keep waiting (only while the worker stays in the
file, as a kept worker that may still be landed), or drop it. Start removes after, drop
deletes the entry, in the write that records the answer. Delete a worker from the file only in
a write that also settles each entry waiting for it, so the delete waits for that answer. A
reply to a blocked report, or a failed merge check, keeps the entry waiting, since the
worker stays in the file.
.gitignore line of step 3, a session
handoff under .agents_workspace/handoff/, entries in .agents_workspace/DECISION_LOG.md,
rows in .agents_workspace/BACKLOG.md, the merge of a worker's workspace branch, step 7, and the
fast-forward of the default branch after a landing, step 7.
A user's request for subagents, such as reviews on another model, goes into the worker's
brief, since a worker may start them. The plugin's scope guard denies the orchestrator's own
edits in the repository and its subagent calls. It also counts the orchestrator's Read, Grep,
Glob, Bash and PowerShell calls on each incoming message and, past its limit, denies each one
unless it is run again, which passes once, so a look that grows into a task is handed to a
worker. The limit was set from 124 turns of 13 past orchestrator sessions.held,
handover sent, message or report received, report answered, merge check run, worker resumed
for a land, worker closed, lost or removed.started, last_active, sent,
received, held) comes from a date "+%Y-%m-%d %H:%M" call at the event, never typed,
because the times order the reports and the held tasks and show the user when a worker last
spoke.ListAgents, "This session is
[]", never from memory or the file. A session's name changes when the session is
resumed, taking its title as its name, and right after the user runs /rename, and a worker
reports only to the name it holds.name or id in
the file, and skip the append when it is there. workers_started never goes down.uv run --script ${CLAUDE_SKILL_DIR}/scripts/artifact.py render <file>.yaml.idle and the follow-up is
in the same area as its last task. A new unrelated task still gets a fresh worker. Past 55 idle
minutes the follow-up goes to a new session in the worker's worktree, as step 5's A late
follow-up says, because Claude Code documents idle compaction only for an interactive
terminal, the VS Code chat panel and the desktop app's Code tab, it was never seen in a
claude --bg worker, and a message to the idle session would read its whole conversation
again uncached once its one-hour prompt cache expires.ListAgents in a
loop.One file per repository per machine, .agents_workspace/orchestration/<machine>.yaml, a copy of
${CLAUDE_SKILL_DIR}/assets/orchestration-instance.template.yaml, with its Markdown rendered
beside it. Its keys, the six rules its model checks, and the quoting rule are in
${CLAUDE_SKILL_DIR}/references/orchestration-instance-schema.md.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-session-orchestration