Start an unattended run - draft a brief with the user, confirm in one question round which pending tasks the run takes, the commands the run's guard may approve and the hosts and folders its sandbox opens, then spawn a feature session that works the goal and those tasks to a verified done with nobody at the keyboard. Invoke when the user types /unattended with a goal.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Unattended?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hex-unattended)
---
name: unattended
description: Start an unattended run - draft a brief with the user, confirm in one question round which pending tasks the run takes, the commands the run's guard may approve and the hosts and folders its sandbox opens, then spawn a feature session that works the goal and those tasks to a verified done with nobody at the keyboard. Invoke when the user types /unattended with a goal.
disable-model-invocation: true
---
An unattended run is a feature session, `<base>@<task>` in its own
worktree, that works a brief to a verified done while the user is away. It
asks nobody anything: it has no AskUserQuestion, its shell runs in a sandbox
that keeps it off GitHub and every host the brief does not list, and a guard
answers Claude Code's prompts from the brief's allowlist. It ends when every
`## Done when` item holds at its `HEAD`, or when a breaker parks it; either way
cs writes `facts.md`, the run writes `report.md`, and cs mails this
session. The work stays on the feature branch until `/finish <task>`.
Ask every question the run could need here, before the user walks away, in
one AskUserQuestion call. That call is the only ask for a goal clear enough
to write `## Done when` from; a thin goal gets one question of its own first
(**Read**). Ask nothing after the spawn.
## Order
Do these steps in this order, every time, and skip none:
1. Call TaskList first, before the name check or any other command, even
when you expect no pending task.
2. Check the run's name (**Read**): free, or held only by a session a
refused start left, not open and with no work of its own.
3. Write the brief file (**Draft the brief**). Its `## Tasks` holds the task
the goal covers, or `none` when it covers no task; nothing else yet.
4. Read the file back and show it whole and unchanged in your reply. Then
ask the one round (**Ask once**): question 1 asks about the brief you
showed, and question 2 names the task the goal covers.
5. Apply the answers to the file. When an answer changes the brief, rewrite
the file, and say in the report what changed.
6. Spawn that file as it stands (**Spawn**).
7. Compare the counts `cs -spawn` prints with the brief the user confirmed
(**Check the counts**).
## Prerequisites
Only works in a cs session: check that `$CLAUDE_SESSION_NAME` and
`$CLAUDE_SESSION_DIR` have values. If either is empty, say an unattended
run needs a cs session and stop. The base checkout (see **Read**) must be
a git repository with a commit
(`git -C <base checkout> rev-parse --verify HEAD` succeeds); say so and stop
if not.
## Read
- **The goal**: the text after `/unattended`, and what this conversation
says of it. Too thin to write a `## Done when`? Ask one question for it
first (AskUserQuestion), then go on: everything else waits for the one
round below.
- **The base and the spawner**: `$CLAUDE_SESSION_NAME` is the spawner, the
session cs mails when the run ends. The spawner is also the base, unless this
session is a feature worktree (its name holds `@`): then the base is the
part before the `@`, as features fork from the base. The base checkout is
`${CS_SESSIONS_ROOT:-$HOME/.claude-sessions}/<base>`. The run's worktree
forks from that checkout's `HEAD`, not from this workspace's: from a
feature session, the run does not get the feature's commits that have not
landed on the base.
- **The run's name**: `<base>@<task>`, `<task>` a short kebab-case name for
the goal, or the one the user gave. A session of that name would take the
run into its worktree, its branch and the work in them. A run folder, a
seed staged under the name, or a `cs/<task>` branch left in the base with
no session makes the spawn refuse. Check it with one command, `<root>`
being `${CS_SESSIONS_ROOT:-$HOME/.claude-sessions}`:
`ls -d <root>/<base>@<task> <root>/.unattended/<base>@<task> 2>/dev/null; find <root>/.spawn -maxdepth 1 -name '<base>@<task>.seed' -o -name '<base>@<task>.seed.stale' -o -name '<base>@<task>+*.seed.stale' 2>/dev/null; git -C <root>/<base> branch --list cs/<task>`.
Keep the quotes around each `-name` pattern, so the shell leaves the `*`
to `find`.
- Nothing printed: the name is free.
- A seed staged under the name, `<base>@<task>.seed` with nothing after
`.seed`: `cs -spawn` refuses the name while the seed waits, and every
other name of this base too when the seed starts an unattended run
(**A start that mails nobody**, below). Tell the user what the check printed and
what that section says to do, and stop, whatever the seed starts: the
seed is a spawn waiting under the run's name, and the user decides what
becomes of it.
- The session, its branch `cs/<task>` and a seed set aside under the
name (`<base>@<task>.seed.stale` or `<base>@<task>+<n>.seed.stale`),
and nothing else: a start refused in the run's own window leaves these,
and `cs -spawn` takes that session again. An open by hand that set a
seed aside leaves them too, with the session in use since, so check that
the session is not open and holds no work of its own, with one command:
`git -C <root>/<base> rev-list --left-right --count HEAD...cs/<task>; git -C <root>/<base>@<task> status --porcelain --branch --untracked-files=normal -- ':(exclude).cs'; git -C <root>/<base>@<task> stash list; cs -live; cs <base>@<task> -conversations`.
Keep the name only when each of these holds:
- Of the two numbers, the first counts the base's commits the branch
lacks and the second the branch's commits the base lacks. The second
is 0.
- The status prints the line `## cs/<task>` and nothing else: the
session's `HEAD` is the tip of its branch, and it has no change and
no untracked file outside its `.cs/` files. `## HEAD (no branch)`
or any other branch after `##` means commits the base cannot see.
- No stash line holds `on cs/<task>:` (after `WIP` or as `On`). The
stash list is the whole repository's, so a line naming another branch
is not the session's.
- No `cs -live` row's name is exactly `<base>@<task>`: `cs -spawn`
refuses a session that is open.
- No `cs <base>@<task> -conversations` line ends `[current]`. That line is the
session's own conversation, which the spawned run would resume
instead of starting fresh; a line without it comes from the base's
records in a tracked `.cs/`.
Then say in question 1 that the run takes again the session a refused
start left, that it forks from that session's `HEAD`, as many commits
behind the base as the first number says, and that the seed set aside
stays where the check printed it. When any of them fails, the session
holds the name: pick another `<task>`, check it again, and say in
question 1 what held the name, the session open or the work the check
printed, whoever gave the name.
- Anything else holds the name. Pick another `<task>` and check again;
when the user gave the name, say in question 1 what holds it and offer
the name you picked.
- **The tasks**: call TaskList and keep the tasks whose status is pending,
each with its id, subject and description (TaskGet for a description the
list does not show).
- **The repo**: `git -C <base checkout> rev-parse --short HEAD`, the
commit the run forks from, or, for a name taken again,
`git -C <root>/<base>@<task> rev-parse --short HEAD`; the commits and
files the goal builds on, and the commands that test it.
## Draft the brief
```
# <task>
## Goal
One paragraph: what to build and why.
## Done when
- `<a command whose exit code 0 means this holds, alone on the line>`
- <a statement the verifier checks by reading the repo>
## Constraints
- Rules from this conversation the run cannot see.
## Context
- The commit the run forks from (the base checkout's HEAD, or the HEAD of
the session a name taken again reuses), and what this work builds on.
- What was tried or measured here, with the outcome.
## Review
cs runs the Done when commands and asks a verifier subagent to judge the
statements, both at the run's HEAD.
## Report back
cs mails the session that spawned this run when the run ends, with the
paths of facts.md and report.md. Do not run cs -msg: the run's hook sends
the mail.
## Tasks
- <id>: <subject>. <what the run needs of the description, on this line>
## Allowed commands
- <pattern>
## Sandbox
- <host>
- <folder>
```
Keep every heading, each on its own line: `cs -spawn` refuses a feature
brief that lacks one of the first six and names it. Under `## Tasks`,
`## Allowed commands` and `## Sandbox`, a section with nothing in it holds
the bare word `none`, with no list marker: every line that starts with
`-`, `*` or `+` is an item, so `- none` would queue a task named none or
open a host named none.
**`## Done when`.** Every line of the section is an item, so it holds no
prose and no `none`, and at least one item. A check is a line that holds
only one command in one pair of backticks, `` - `npm test` ``: cs runs it
from the worktree and its exit code decides it. A line that holds any words
is a statement the verifier subagent judges by reading the repo, a command
beside the words included: `` - Tests pass: `npm test` `` runs nothing.
Prefer checks: cs runs them itself. Never write a check or a statement that
the tree is clean or the work committed: cs checks for a clean tree itself,
outside its own `.cs/` files, before every round. A command runs for 30
minutes at most, or for the duration a `timeout` or `gtimeout` at its start
(or after `wh <host> --`) gives it. A check must leave the tree clean: the
run verifies only a tree with nothing to commit, so a check that leaves files
git does not ignore sends the run back to commit them, round after round.
**`## Tasks`.** One line per confirmed task, `- <id>: <subject>`, the
description's substance after it on the same line. The id before the colon is
how `facts.md` names the task when the run ends, and the run gets that one
line of it alone: it cannot read this session's task list.
cs queues the run's goal as its first item, then each `## Tasks` line as an
item of its own, and `facts.md` lists a task only from its `## Tasks` line.
A pending task that is the goal, or that the goal already covers, goes
under `## Tasks` once, and the `## Goal` is that task's own text,
ending with the sentence: "Task <id> under the Tasks section is this goal:
when its item comes, end it with the line cs-task-done." The run then does the work
once, in the goal, and the task still reaches `facts.md`, from which this
session can reconcile it.
**`## Allowed commands`.** Patterns the guard approves when Claude Code
would otherwise ask, and the only way a `wh` call runs. A pattern matches the
whole command; a `*` stands for any text holding no quote, `$`, backslash,
`;`, `&`, `|`, `<`, `>`, `(`, `)` or line break, and every other
character for itself. Propose the commands the goal needs that trip Claude
Code's safety checks, and the narrowest `wh <host> -- <command>` the work or
a check needs. The never list (`git push`, `gh` writes, `npm publish`,
`sudo`, `install.sh`, `cs -rm`, `cs -update`, `cs -msg`) is not read past
`wh`: `wh * -- *` lets the run send any of them to a workhorse, so name the
host and the command. `cs -spawn` refuses a pattern that could admit a `wh`
call and holds `;`, `&`, `|`, `<`, `>`, a backtick, `$(` or a line break.
**`## Sandbox`.** The hosts the run's shell may reach (`example.com`, or
`*.example.com` for each host under it): the package registries and docs the
goal needs. The folders outside the worktree it may write (`/path` or
`~/path`): the package caches the repo's tools use, such as `~/.npm` or
`~/.cargo`. GitHub stays denied whatever the list says. A registry listed
here, with a token readable on this machine, lets `npm publish` through the
sandbox: the guard refuses only its plain form. `cs -spawn` refuses a folder
that is, holds or lies inside the sessions root, the cs hooks folder or
`~/.claude`, and one with a `..` component or a wildcard.
Write the draft to a file of its own in this session's `.cs/local/`, the
machine-local folder git ignores, inside this conversation's working
folder. This command makes the file and prints its path:
`mktemp "$CLAUDE_SESSION_DIR/.cs/local/unattended-brief.XXXXXX"`. Each run
of the skill gets a name of its own, so a second `/unattended` in this
session never writes over the first one's draft. Keep that path, and write
it out in each later command where `$brief` stands below: a shell variable
does not outlast its Bash call. Claude Code refuses a Write to a file this
conversation has not read, and the new file is one, so call Read on it
first, then Write the brief into it.
## Ask once
Show the brief file's text in your reply, whole and as written, then ask
with one AskUserQuestion call, these questions in this order:
1. **The brief.** "Does the run take this brief and the name <base>@<task>?"
Options: take it as drafted; do not spawn. Edits go in Other. Say in the
question that the `## Done when` commands run outside the sandbox, with
this machine's network and credentials, on code the run may change.
2. **The tasks.** "Which pending tasks does the run take after its goal?"
A task the goal is or covers is not offered: the question names it, by
its id and subject, as taken with the goal. Of the other pending tasks, with two to four:
`multiSelect`, one option per task, its id and subject; the question
says that picking none leaves them all here. With one: not `multiSelect`,
and exactly two options, `Take <id>: <subject>` and `Leave it here`;
Claude Code refuses a question with one option. With more than four:
list every one in your reply, and offer all or none, with the ids typed in Other for any other choice.
With none, leave this question out; `## Tasks` then holds the goal's
task, or `none`.
3. **The allowed commands.** "May the guard approve these patterns?" Options:
as proposed; none. Other takes edits.
4. **The sandbox.** "May the run's shell reach these hosts and write these
folders?" Options: as proposed; none. Other takes edits.
Ask question 3 only when `## Allowed commands` proposes a pattern, and
question 4 only when `## Sandbox` proposes a host or folder. A section that
holds `none` has no second option to offer: leave its question out, and
never pad a question with an option that repeats another.
A question the user leaves without a choice is missing from the tool's
result, with no warning: the warning that some questions have no answer
shows on the user's review screen only. A `multiSelect` with nothing
picked arrives this way. Read a missing answer
as the narrowest one: to question 1, do not spawn; to question 2, the run
takes none of the tasks offered; to questions 3 and 4, `none`. Never read
a missing answer as "as proposed".
"Do not spawn" ends the skill: remove the brief file and say no run
started. Otherwise apply the answers to the brief file: the tasks chosen go
under `## Tasks`, the rest stay pending here; edits replace what they name.
The file you spawn is the brief the user saw, with only these answers
applied.
Ask again only when you cannot read an answer as an edit, or it leaves
`## Done when` empty.
## Spawn
```
cs -spawn <base>@<task> --brief "$brief" --unattended
```
Run that line exactly as written, with the path in place of `$brief` and
nothing added: a suffix such as `; rc=$?` or `&& echo` makes it a command
an allow rule for `cs -spawn` does not match.
The answer to the first question is the user's consent to the run: spawn
only after it. Claude Code shows a permission prompt on `cs -spawn` only
where no allow rule in its settings matches the command. Where it shows one,
let it stand as a second confirmation that a worktree, a branch and a window
running in `bypassPermissions` are about to exist. Never work around it.
When the user denies it, the skill ends as at "do not spawn": remove the
brief file and say no run started.
Claude Code can also ask before the name check and the work check, which
read outside this session, before `mktemp`, the Write of the brief file and
its `rm -f`, and, once the run's mail comes, before each `cs -msg` and the
read of `facts.md`; the walk-away starts at the spawn.
Keep the brief file until the spawn succeeds and its counts match (below),
then remove it (`rm -f` and its path): a refusal you fix needs it for the
next try, and so does a count that differs. When the skill stops on a
refusal, a "do not spawn" or a denied prompt on `cs -spawn`, remove it then.
`cs -spawn` checks the brief before it stages anything, so its refusals
stage nothing. One failure comes after the staging: `tmux new-window
failed`, which leaves the run's seed staged (**A start that mails nobody**,
below). Sort a refusal by its subject:
- **The brief's own text**: a section it lacks (`has no '## <section>'
section`, which a code fence left open above that heading also causes),
a `## Done when` with no item, a `## Sandbox` item, an
`## Allowed commands` pattern. Fix the brief file and spawn again. Ask one
more question first only when the fix changes something the user
confirmed: a task, a pattern, a host or folder, a `## Done when` item. A
heading or a fence needs no question.
- **Anything else**: a second run of the base, an encrypted session, a run
folder or a `cs/<task>` branch left over, a session of the name that is
open, a failed `tmux new-window`.
Print it verbatim, remove the brief file and stop. Never run the
`rm -rf` or `git branch -D` a refusal names; the user makes that call.
## Check the counts
`cs -spawn` prints one line of what it read from the brief, before the
attach hint: `<base>@<task>: an unattended run with N base task(s), N
allowed command pattern(s), N sandbox host(s) and N sandbox folder(s)`.
Compare each number with the brief the user confirmed: the items under
`## Tasks` and `## Allowed commands`, and the hosts and the folders under
`## Sandbox`, a section of `none` counting 0. When a number differs, cs
read the brief otherwise than the user saw it: keep the brief file, tell
the user which count differs, both numbers and the brief file's path, and
stop. The run is already going with what cs read; the user decides whether
to stop it in its window.
## Report
Print the spawner's output: the summary line and the attach hint (`tmux
attach -t cs`, or `tmux switch-client -t cs` from inside tmux). Then tell
the user, in two or three lines, that the run works without asking, that cs
mails this session the outcome when it ends, or the refusal if the run's
window refuses to start it (a start that fails before that window reads the
run's seed mails nothing), that the tasks it took stay
pending here until a done end marks those it finished, and that
`/finish <task>` lands its branch. When an answer changed the brief,
say what changed.
## When the run's mail arrives
cs mails this session from `<base>@<task>` when the run ends, `done` or
`parked`. The body starts `unattended run <base>@<task> is done` or
`... is parked`, then why, the path of `facts.md` or that cs could not
write it, the path of `report.md` and, when the run took tasks, what to do
with them. Reading the mail here (`cs -msg`) can raise a permission prompt,
so the reconcile waits for a person where one shows.
- **A done end** asks you to reconcile your task list. Read `facts.md`:
under `## Base tasks` it lists each task the run took by its id, with
`done`, `parked`, `left`, `not reached` or `not read`. Mark completed
(TaskUpdate) each task listed `done`, and leave every other one pending.
- **A parked end**, or an end whose `facts.md` cs could not write, asks you
to leave every task the run took pending until a person checks the run.
Mark nothing: nothing verified the work, and `facts.md` lists a task
finished at a parked end as `done, not verified`.
- **A run that took no task** asks nothing of your task list.
Then tell the user the outcome, each parked item with the one action
`report.md` says unblocks it, and that `/finish <task>` lands the branch.
Two other mails ask nothing of your task list, and one kind of failed start
sends none: leave the tasks pending.
- **A refused start.** `cs -spawn` returns once the run's window opens.
The open there checks the seed's brief again, and checks Claude Code's
settings for the first time. When it refuses, the window closes, and cs
mails this session one line that starts `unattended run <base>@<task> did
not start, and its window has closed:`, then the refusal, which names
what to fix, then what it left. A refusal once cs has recorded the run
as running, as one over Claude Code's settings is, parks the run, and
the base can spawn again: the run does not restart, its brief is
`brief.md` in the run folder the mail names, and `cs -rm <base>@<task>`
deletes that folder with the session. A window that closes there with no
refusal mails `the open stopped before claude started` and parks the
same way. When cs cannot record the park, the mail says so instead: the
run still reads running, and the base can spawn again only once
`cs -rm <base>@<task>` removes it. A refusal before that sets the run's
seed aside, and the base can spawn again: as `<base>@<task>.seed.stale`,
or under the name the mail gives when an earlier seed holds that one, its
brief after the line
`--- cs-spawn-brief ---`; a spawn of the same name takes the session
left, once someone removes any run folder the mail names, and
`/unattended` offers that name again while the session is not open
and holds no work of its own (**Read**). Tell the user the refusal and what it leaves. Never run the `rm`, `cs -rm` or other
command it names; the user makes that call.
- **A start that mails nobody.** A failure in the run's window before the
open reads the seed sends no mail: git cannot make the feature's
worktree, the session is already open or locked, or cs cannot read the
seed. A refusal cs cannot mail, as with a spawner that is no session
name or a mailbox cs cannot write, keeps the seed staged too. Each of
these leaves the seed staged at `<root>/.spawn/<base>@<task>.seed`, as a
failed `tmux new-window` does, and cs refuses the next
`cs -spawn --unattended` from this base. `cs <base>@<task>` in a terminal
shows the seed and asks:
`y` takes it and starts the run there, `n` sets it aside. Removing the
seed file clears it too. When the user asks why no mail came, tell them
this; never remove the seed yourself.
- **A run given up.** When the run's Stops keep failing, cut off at Claude
Code's time limit or unable to write a file the run keeps, cs gives the
run up where it stands and mails this session a body that starts
`unattended run <base>@<task> stopped where it stands:`, then why and the
state the run still reads. The run has not ended. A run given up can
still end later, and its end sends the mail above.