agentleFS
hathachhathach/agentrc/skills/headless-chief/SKILL.md

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.

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
  1. Very specific:

    Leave the worktree to chief until it exits.

    line 83

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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
  1. Before launching: take the target from the assignment, formed as the Report rule in agents/chief.md forms it (owner/repo#N and the task), asking only when it is ambiguous, and name --out after it. --task is 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 its Merge grant: line, per the README's headless recipe.
  2. 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/workflows or .claude/agents entries differ from the same-named agentrc copies installed in the user scope ($CLAUDE_CONFIG_DIR, else ~/.claude), which they would shadow (an install.py --project link to this checkout is no copy); the message names the fix. The skill's hook denies Workflow and Agent calls in such a worktree for interactive sessions too. The launcher: exit line in progress.log is the end of the run; kill <launcher pid> stops it early. On Windows, taskkill /T /F /PID <pid> on the launcher: started pid line's pid does (exit line claude 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 the progress.log exit line, after the launch returned 0.
  3. Watch with Monitor on tail -n +1 -F <dir>/progress.log, its description, on every arm, the target, such as chief hathach/tinyusb#3988 babysit. Each line is <seq> <HH:MM:SS> <text>: launcher: lines (started, session, a parse warning, credit-guard waiting and wait over when 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's chief: <event> · ... lines, and note: lines, a progress note, joined onto one line, that the model returned as a thinking block instead of text; a note can carry an event whose status line never came. An attention line 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 with tail -n +<last seq received + 1> -F, a few lines earlier when unsure.
  4. 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 and stderr.log. When it can table the session's cost, the launcher writes scripts/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, to cost.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 with cost none and why. Open the message that reports the exit, with or without report.md, with the target, and, unasked, relay verbatim the Launches table with its State line and chief's Worth a look: line, the Usage table, each launch's Findings table 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 the launcher: exit line, says how the run ended, not whether the task passed:

    ExitMeaning
    0chief ended with a report
    1no 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.md name each task)
    2bad arguments, --out already exists, a chief already runs in the worktree, its run lock cannot be taken (Windows), or its .claude shadows agentrc's installed copies or cannot be read
    127claude could not start
    otherclaude'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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.