headless-chief
Skill2 starsChanged 24 days agoMITView on GitHub
Launch a headless `chief` (`claude -p --agent chief`) and follow its status lines and final report from the calling session. Use when handing a task worktree, such as a PR to babysit, to a headless chief.
In this repository23 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- arduinoSkill
- ci-rerunSkill
- code-sizeSkill
- coworkSkill
- debug-probeSkill
- download-docSkill
- followup-issueSkill
- hil-farm-setupSkill
- hilSkill
- pr-babysitSkill
- pr-replySkill
- pr-reviewSkill
- read-docSkill
- read-pcbSkill
- repo-auditSkill
- rttSkill
- simplify-gateSkill
- target-debugSkill
- usb-kernel-debugSkill
- usb-kernel-recoverSkill
- usb-snifferSkill
- worktree-removeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 83
Leave the worktree to chief until it exits.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Headless chief
scripts/chief_run.py runs chief with streaming output and keeps what the
caller needs in one new directory per run. Chief begins a message that reports a change
with a status line (the rule in agents/chief.md); the script copies those
first lines to progress.log, so the caller tails a file.
R="${AGENTRC_DIR:-$HOME/.claude}/skills/headless-chief/scripts/chief_run.py"
python3 "$R" --out <new dir> --worktree <task worktree> --task-file <task.md> \
--task <key> --permission-mode bypassPermissions- Before launching: take the target from the assignment, formed as the
Report rule in
agents/chief.mdforms it (owner/repo#Nand the task), asking only when it is ambiguous, and name--outafter it.--taskis that target as a key (hathach/agentrc#490:accounting,owner/repo#N:babysit), matched exactly and the same on every relaunch of the task, so its launches add up; a launch without one is a task of its own. A task that publishes to a PR carries its grant verbatim and itsMerge grant:line, per the README's headless recipe. - Launch in the foreground: it checks the arguments, starts the
launcher in its own session, prints its pid and returns. A chief
runs as long as it needs; a background command would end it at the tool's
time limit. A refused argument exits 2 at once. So does a worktree whose
.claude/workflowsor.claude/agentsentries differ from the same-named agentrc copies installed in the user scope ($CLAUDE_CONFIG_DIR, else~/.claude), which they would shadow (aninstall.py --projectlink to this checkout is no copy); the message names the fix. The skill's hook deniesWorkflowandAgentcalls in such a worktree for interactive sessions too. Thelauncher: exitline inprogress.logis the end of the run;kill <launcher pid>stops it early. On Windows,taskkill /T /F /PID <pid>on thelauncher: started pidline's pid does (exit lineclaude exited 1), never on the launcher pid, which loses the exit line; there only a chief chief_run started in a git repository counts as running, and a launcher that loses its run lock to another reports its exit 2 only on theprogress.logexit line, after the launch returned 0. - Watch with Monitor on
tail -n +1 -F <dir>/progress.log, its description, on every arm, the target, such aschief hathach/tinyusb#3988 babysit. Each line is<seq> <HH:MM:SS> <text>:launcher:lines (started, session, a parse warning,credit-guard waitingandwait overwhen a 30 s look finds the README's credit guard holding the run's hooks for a plan limit to reset and later finds none, exit), chief'schief: <event> · ...lines, andnote:lines, a progress note, joined onto one line, that the model returned as athinkingblock instead of text; a note can carry an event whose status line never came. Anattentionline is chief asking for something; relay it. Every line you relay, delivered by Monitor or read later, names the target, so parallel chiefs stay apart. Monitor expires after 30 minutes: re-arm withtail -n +<last seq received + 1> -F, a few lines earlier when unsure. On exit, stop the Monitor and read the lines it had not delivered; then read
report.md, chief's final report, or, when there is none, the exit line andstderr.log. When it can table the session's cost, the launcher writesscripts/run_cost.py's full output, the spend by Workflow run, stage and model in claude's own dollars, its breakouts and a time table, tocost.md, and puts its brief form, the Launches and Usage tables, into the report before chief's first##section. The exit line ends with the total, or withcost noneand why. Open the message that reports the exit, with or withoutreport.md, with the target, and, unasked, relay verbatim the Launches table with its State line and chief'sWorth a look:line, the Usage table, each launch'sFindingstable from chief's report and chief's decisions for the user; a row that dwarfs the work it did is worth a word. The exit code, the number on thelauncher: exitline, says how the run ended, not whether the task passed:Exit Meaning 0 chief ended with a report 1 no final result, an error result, one without text, or one after which the session's end cut off chief's own work (a unit's background command still running, or killed after chief's last message; the exit line and the top of report.mdname each task)2 bad arguments, --outalready exists, a chief already runs in the worktree, its run lock cannot be taken (Windows), or its.claudeshadows agentrc's installed copies or cannot be read127 claudecould not startother claude's own status; 128 + N when killed by signal N (not on Windows); 1 for a Windows NTSTATUS, named in hex on the exit line
Leave the worktree to chief until it exits; remaining in-scope work goes into
its task. A signal to the launcher is passed
on to chief (not on Windows, step 2); the launcher still writes the exit
line. A relaunch needs a new --out and the same --task; its grant follows the README's
headless recipe.
Each launch is accounted for in run.json in --out and in the run ledger, which outlives it
(scripts/run_ledger.py names its path). Both are best-effort and measure only: a lost write can leave a launch
missing or unfinished and a warning is attempted, so nothing here can enforce a budget yet (#490). What a task has
spent, from the ledger alone (launches before it, and their cost.md, are not in it):
python3 "${AGENTRC_DIR:-$HOME/.claude}/skills/headless-chief/scripts/task_cost.py" [--task <key>] [--json]A total is a plain sum only when every launch finished with a known cost and the ledger read whole; otherwise it says what is known and what is missing: an unfinished launch has no end recorded, which does not mean it still runs; a partial cost is a lower bound and an unknown one is not zero. The script's docstring has the rest.
The rest of the directory is for autopsy: stream.jsonl (every event,
raw), stderr.log, and session, whose id names the transcript:
ls "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/projects/*/<id>.jsonl.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

