Agent Harness Reference

This page holds the facts of the agent harness. Read it to look one fact up. It covers which hook blocks what, which command-line scripts help the main loop, and what the installers change. The story of a call, the lookup for a denial text and the routes by kind of work are on Agent Harness. The rules for model, effort and cost are on Dispatch Economy.

The harness never changes WHICH reviews run. The rosters, the mandatory core and the gates stay in verification-routing.md and in the pipelines. Economy prices a reviewer and never removes one.
evidence §N on this page cites section N of the evidence file named in Evidence.

Routes

The main loop is the Claude Code session in which you talk to the orchestrators. It decides and approves but does not do the work. A lane is one running top-level orchestrator. The table of routes by kind of work is on Agent Harness, Which route a kind of work takes.

Below the orchestrators, the leaves write code (*-coding-agent, and ft-ui-ux-design for presentation). The reviewers refute the code (verifier lenses and ft-test-adversary). The doc writer documents it. ft-ui-ux-design routes each design property to its skill and never reviews its own diff (evidence §71).

Other pieces of the harness:

Piece What it does

rules/agents/tiering.md

The canon for model and effort per dispatch, escalation, unit size, slices, who decides and the report lines.

rules/agents/context.md

The orchestrator’s own context: one sanctioned reset, and where knowledge is written by what it costs to load.

hooks/decide.py and skill ft-decide

Jev, a small external decision model that is asked first on enumerable choices. See Decision model (Jev).

hooks/unit-check.py

The orchestrator calls it after each unit. It compares the delivered size and the new files with the pick and journals the result in one command.

agents/ft-fix-host.md

Hosts ONE /ft-fix run for the main loop, on a 1-hour cache (evidence §65).

agents/ft-ops.md

Runs ONE operational batch on sonnet and a 1-hour cache, and brings every design choice back (evidence §68).

deploy/scripts/economy.py

The install step that wires the hooks into ~/.claude. Both installers call it.

Preview push of the git safety hook

The hook has one exception to the push block. The exception exists only for the release ring preview in Release rings. It runs for Claude Code only. Codex installs no ring hook, so no preview ring runs there. Codex runs two hooks, the readonly-role-guard and the spawn price gate, and neither is a ring. See Codex.

Flag. Only ft-ops starts the hook with --allow-preview-push. Any other agent keeps the normal block on every push. The flag has an effect only when the command starts with git -C ` and contains ` push --force-with-lease=refs/heads/preview/. Every other command takes the normal path unchanged.

Command form. The command must match this form exactly. The <repo> value is an absolute path of the characters A-Z a-z 0-9 _ . / -. The <last sha sent> value is empty for the first push of a run, so the lease ends with the colon.

git -C <repo> push --force-with-lease=refs/heads/preview/<slug>:<last sha sent> origin <sha>:refs/heads/preview/<slug>

Allowed repositories. The hook pushes to an origin that is one of these two repositories, with the base branch in the second column.

Repository Base branch

Friendly-Technologies/ft-acs-qa-console

main

Friendly-Technologies/oneiot_backend

feature/generic-hazel-bridge

Checks. The hook runs seven checks in order. The first failing check refuses the push with exit code 2 and names the step.

Step Name What the hook checks

1

form

The command matches the canonical form.

2

slug

The lease slug and the push slug are equal. The slug has 1 to 100 characters of A-Z a-z 0-9 . _ -, starts with a letter or digit, and is a valid ref name.

3

target

The directory is a work tree. origin has one push URL on github.com, equal to the fetch URL, and the repository is in the table above.

4

config

The repository sets no local core.sshCommand, credential.helper, remote.origin.uploadpack, remote.origin.receivepack, remote.origin.vcs, remote.origin.proxy, http.proxy, http.curloptresolve, http.sslcainfo, http.sslcapath, core.hooksPath or core.askPass. It holds no local include or includeIf entry, no config-based hook (hook.<name>.*), no URL-scoped http.<url>.proxy, http.<url>.curloptResolve, http.<url>.sslCAInfo or http.<url>.sslCAPath, and no URL-scoped credential.<url>.helper. push.followTags, remote.origin.mirror and submodule.recurse are not true. push.recurseSubmodules is unset or no. http.sslVerify and every URL-scoped http.<url>.sslVerify are not off. refs/replace is empty, and the hook reads objects with GIT_NO_REPLACE_OBJECTS=1. No pre-push or reference-transaction hook file is present. Git runs both on the push.

5

base tip

ls-remote of the validated push URL returns exactly one commit for the base branch, and that commit exists locally. If it does not, fetch first.

6

held

The pushed commit changes no held path between the base tip and the pushed commit.

7

content

No added line of any commit between the base tip and the pushed commit, and none in the cumulative diff from the base tip to the pushed commit, holds a token signature. In yml, yaml, properties, xml and json files, no added line holds a build-time reference of the form @env., ${env., @settings. or ${settings.. The scan reads at most 16 MiB of diff text in total. A larger diff is refused at this step.

Held paths. The held list lives only in the script. To see the step that refuses a push, run git-safety-check.sh --preview-check '<the push command>'. The command pushes nothing. It prints ok and exits with code 0, or prints the refusing step and exits with code 2. The held list covers workflow files, the Maven build files, Dockerfiles and the repository profile. These are the inputs that run in a step that holds a registry credential. It is not a list of files that a preview may never carry for any other reason. The command --preview-check also scans the workflows of the base tip: every file under .github/workflows that ends in .yml or .yaml, in any letter case, listed from the top of the repository. Every event must be on a fixed list of events that creating a branch cannot start (for example pull_request, workflow_dispatch or schedule); create, workflow_run and any other name refuse. A push trigger needs a branches, branches-ignore, tags or tags-ignore filter. A branches entry passes only in two cases, where a plain name holds only letters, digits, ., _ and -: the entry is a plain name with no /, such as main (a bare preview or refs passes too, because it cannot equal preview/<slug>), or its first path segment is a plain name other than preview or refs and the first / is followed by nothing, a plain-name character or , such as release/. Every other entry refuses, for example , , v*, //, pre/?view/, pre/{0}view/**, previ{1}ew/**, !main, null, ~ and every preview/…​ or refs/…​ entry in any letter case. A branches-ignore list passes only when one entry surely covers preview/<slug> and no entry starts with !. An entry that starts with **/ refuses. The two delivered preview workflows, build-preview.yml in oneiot_backend and preview.yml in ft-acs-qa-console, are not judged while their content is exactly the delivered one. A file the reader cannot read refuses. The real push does not run this scan.

Failure mode. The preview branch is fail-closed. An unexpected error (ERR trap) or a deadline of 20 seconds for all git calls and the scans exits with code 2, never 0. The refusal names the step in progress. The allow branch runs as its own process, and the hook reads its exit status: anything but 0 is a refusal. The normal path is fail-open: it allows a command that it cannot read. One case is excluded: a helper process of the hook that did not do its job. That is a grep with a status above 1, any non-zero status of awk, sed or tr (a SIGKILL under heavy load, status 137, is the usual cause, but a plain failure counts too), and a jq or cat killed by a signal (status 128 or above; a jq that rejects a malformed payload stays fail-open). The command was then judged on an empty or partial copy, so the hook blocks it with the text the helper process '<name>' failed (status N), so the command could not be judged and is refused. Retry the command. (fail-closed, exit code 2). The ft-ops hook entry sets a timeout of 30 seconds, which is longer than the internal deadline.

Hardening of the normal path. The hook also matches each command after it removes ', " and \, so git 'push' origin main blocks. It first joins a line that ends in \ with the next line, as the shell does. It also blocks git send-pack, git http-push and git subtree push. It blocks a gh api call that writes: a REST call with a method other than GET, or with a field or input flag, on a path with git/refs, git/tags, /contents/, /merges, /merge, update-branch, /branches/<name>/rename, /dispatches, /pulls or default_branch, and a gh api graphql call when the command names a ref, merge, pull request creation or revert mutation on any of its lines, or reads the query from a file. A gh api read passes. It blocks the gh commands that reach the same writes: gh pr create (and its alias gh pr new), gh pr revert, gh pr update-branch, gh workflow run, gh repo sync and gh repo edit --default-branch. A gh option before the command group, between the group and its command, or before api does not hide the command or the write. This holds for a value glued to its flag (-R<owner>/<repo>) and for a quoted value with spaces. The hook also reads a quoted argument as the one word the shell passes, so a ;, & or | inside quotes does not split a command. These readings can block a gh api read whose text names a write path or a mutation. That is the fail-safe direction.

Declared residual. The hook checks typed commands only. It does not stop a git or gh alias that is defined and then invoked, a script file that pushes, another language that calls git, or a background job that changes configuration or refs between the check and the push. Its reading of shell quoting is partial. A $'..' (ANSI-C) string is decoded the way bash decodes it before the command is judged again: git $'push', git $'\x70ush', gh $'pr' create and gh api -X $'DELETE' .. block, and $'a b' is one word. The decoder handles \a \b \e \E \f \n \r \t \v \\ \' \" \? \nnn \xHH \uHHHH \UHHHHHHHH \cX; a result that is syntax outside quotes (a space, ;, &, |, a quote, a backslash, a control character) becomes _, and a code point above 127 becomes ?. It is run in two quote-state readings (one per line with the comment rule, one across lines without it), like the quote copies below. The decoder also reads a $'..' inside "$(..)" and inside backticks in double quotes, and drops the $ of a locale string $".." (bash reads it as ".."). A $' left open on a line (for example in a heredoc body) ends with that line in the per-line reading. Declared residuals of this decoder (fail-open): a decoded space or newline that the shell reads again as syntax (eval $'git\x20push origin main', bash -c $'git\x20push'), because the decoder makes it word text; a $'..' in a run without jq, where the raw JSON quote state hides it; a heredoc body and a $' that share a command in a way the decoder’s own quote reading does not follow. A space or ;, &, | escaped with \ outside quotes counts as part of its word. The hook judges six readings of the quotes: one whose quote state ends at each line, three that carry over lines (one copies the body of a heredoc as it is, so an odd quote in a plain heredoc body does not corrupt the quote state; one is the narrower round-4 form of the same, kept unchanged; one skips nothing), and two that do not treat as a comment start, one per line and one carrying over lines (a after $(..), inside backticks or inside ${..} is word text). It blocks if any reading blocks. So an unbalanced quote in a comment or a heredoc body no longer corrupts the reading of the command below it, and a word quoted across lines stays one word. The body of a quoted heredoc is not read as a command in one narrow shape only: the whole command is cat > F <<'W', cat <<'W' > F or tee [-a] F <<'W', optionally after cd <word> &&. F is one plain word ending in .md, .adoc or .txt, with no $, no .git/, no /dev/ and no /proc/. Line 1 holds exactly one <<. The body ends at the first line equal to W, and only blank lines follow it. Anything else is read in full, which is a fail-safe false block: a second statement, a second <<, <←, an unquoted delimiter, a pipe, a variable in the file name, or a follow-up such as git add F in the same command. The carry-over readings take the command before its backslash-newline pairs are joined and join them themselves outside heredoc bodies, so a \ at the end of a quoted heredoc body line neither merges the line with the terminator nor swallows the command below. The reading that skips heredoc bodies reads the delimiter as the shell does (quotes and backslashes removed): <<\EOF, <←EOF, << -EOF (the delimiter is -EOF), <<END-X, <<a.b and <<E"O"F each have their own delimiter, one line may open several heredocs (their bodies follow in order), and a heredoc inside "$(..)" counts. A << inside $.. or $[..] is a shift, not a heredoc (a bare .. is not tracked by this reading; the earlier reading of round 4, which copies a plain-name heredoc body as it is and does not know .. or backslash-continued delimiters, is kept and judged as an extra pass on the joined command, together with the carry-over readings on both the joined and the unjoined text, so every form blocked before round 5 is still blocked and the newer readings only add blocks). In an unquoted-delimiter heredoc a backslash-newline joins body lines before the terminator is compared. So an odd quote in the body of these heredocs no longer lets a write whose quoted word spans lines through. Declared residuals (fail-open), found by the Gate B review and not closed in round 5: an empty delimiter (<<""), a delimiter with $(..), and a heredoc inside "$(..)" whose substitution holds an inner " or a bare ) before it (the substitution depth is a counter, not a parser). Also open and older than round 5: git itself is judged only on the plain and quote-stripped copies, so a git -c value with a newline in quotes before the subcommand hides it; git pu$()sh, git${IFS}push and {git,push} are allowed.

Also open, fail-open, and the same on c0a6790: a gh write that sits inside a quoted string and has a quoted word with a space in it, such as "$(gh pr --title 'a b' create)", eval "gh pr --title 'a b' create" and bash -c 'gh pr --title "a b" create'. The hook turns the spaces inside quotes into word text, so it no longer sees gh as a command word there. Reading quoted text as a command again would also block ordinary messages that only mention such a command, so it is left open on purpose. The same text without a space inside the inner quotes (eval "gh pr create") is blocked. A heredoc delimiter continued over a line (<<E\<newline>OF) is refused outright, because the readings cannot follow it (a rare false block). The vault exemption covers only a push whose arguments are plain words: an argument that starts with a quote, a backslash, $ or a backtick, or that holds a + (a forced refspec), is not exempt, so git -C "$FT_VAULT_PATH" push '--force' and push origin +main block. Indirect execution (cat f | bash), a file that a later tool call runs, and a process started by an earlier call that reads the file are not seen, because the hook checks typed commands only. This fails open. A .md file that Claude Code itself runs (command or skill files with ! lines) is not seen either. A multi-line commit message that quotes a PR-creation phrase on a later line is now blocked (a fail-safe false block), because the per-line reading sees that phrase outside a quote. A gh api read that carries -X GET -H X:\ -X\ DELETE is also blocked, because the copy without backslashes is judged first. gh api /graphql, a graphql URL, and either with a query string, a fragment or a trailing slash are read as GraphQL, because on github.com gh sends them to the same endpoint. On a GitHub Enterprise host that path is not the GraphQL endpoint, and the reading there is the fail-safe one. A command long enough to outlast the hook timeout is allowed, because the normal path is fail-open. The gh api segment checks no longer fork a process per segment and run the whole-command GraphQL search once, so a command with many gh api segments is faster than before (60 GraphQL segments: 367 grep calls, now 9). Residual: a killed helper under load. Under a load of about 10 to 14 on this host, short child processes were killed from outside with SIGKILL (the shell reports Killed: 9; status 137). The hook’s own watchdog was not the sender: it kills only at the 20 second deadline or past the output cap, and each of those refusals says timeout or git output above, which no failing run showed. Before this fix a killed awk, sed, tr or grep on the normal path read as no match, and a real push passed (fail-open); a test that kills each helper in turn reproduced it. Now the normal path refuses with the text above. The preview branch was already fail-closed: a killed child gives a refusal such as cannot size the git output, and the caller turns any status but 0 into exit code 2. A self-test row that expects another refusal text can therefore fail under heavy load without a product defect; it is not a budget problem, because FT_PREVIEW_ROOM (read only under --selftest) already gives those rows 120 seconds. Rows pin that: one runs the script as its own process with the payload on standard input, FT_PREVIEW_ROOM=1 and a git that answers 3 seconds late, and it must reach the repo allowlist (the production process ignores the room and keeps its 20 seconds); the same child under --selftest must refuse with timeout; and a push on standard input must exit 2 with and without --allow-preview-push. The self-test’s check rows tell a dead helper from a verdict: a block that came from a dead helper is retried twice and then fails with helper failure (no verdict, not a pattern result), instead of passing a row that wants a block. The kill-the-n-th-call loop also covers the preview branch: for each tool the branch calls, killing the n-th call (every n) of the happy-path push must give exit code 2, never 0. The production budget of 20 seconds and the 600 second limit of the regression test are unchanged. A killed jq or cat refuses the same way (the raw payload is not the command text). The helpers read their input from a here-string, which bash may route through a temporary file; if that file cannot be created the status reads as no match, and the earlier sed on the same input fails first and blocks. Declared residual: if the hook process itself is killed, no script can refuse; Claude Code reads a status other than 2 as non-blocking. bash 3.2. The hook runs through #!/usr/bin/env bash, which is bash 3.2 on a stock macOS. The hook itself needs nothing newer: /bin/bash git-safety-check.sh --selftest passes. Before round 5 it printed 108 FAIL lines there, all from one idiom of the self-test code (a case pattern without its leading ( inside $( ), which bash 3.2 cannot parse), none from the hook. A self-test row now fails if that idiom comes back. The commands gh release and gh pr merge stay allowed for the hook agents, because ft-ops performs releases and merges.

Work push of the git safety hook

The hook has a second exception to the push block. The owner ruling of 2026-11-10 allows an agent to push a work branch, open its pull request and rerun its CI. The exception runs for Claude Code only.

Flag. Only ft-ops starts the hook with --allow-work-push. The frontmatter of agents/ft-ops.md sets it next to --allow-preview-push. Any other agent keeps the normal block on every push. The hook checks the flag only for a command that the normal path blocks, and for a command that starts with gh run rerun. It never turns an allowed command into a refusal.

Admitted commands. The hook admits exactly three commands. Each must be the whole command, with no chaining, quote tricks or redirection.

Form Command

Push

[cd <abs dir> && ]git [-C <abs dir> ]-c credential.helper= -c 'credential.helper=!gh auth git-credential' push origin <40-hex sha>:refs/heads/<branch>

Pull request

gh pr create -R Friendly-Technologies/<repo> --head <branch>, with the other gh pr create options that the hook lists

CI rerun

gh run rerun <id> [--failed] -R Friendly-Technologies/<repo>

Conditions of the push. The push sends one 40-character hex commit to a refs/heads branch that is not protected. The origin of the directory must be a Friendly-Technologies repository on github.com, and the repository must pass steps 3 and 4 of the preview push. Give the directory with cd or with -C, not both. Without either, the hook uses the working directory of the call. The protected branches are master, main, release/, feature/generic-hazel-bridge, preview/, HEAD and refs/*, in any letter case.

Owner exception. The owner can name repositories outside Friendly-Technologies in ~/.local/state/ft-ai-toolkit/push-exception.json: {"repos": ["owner/repo", "owner/"], "until": "YYYY-MM-DDTHH:MM"}, in local time; owner/ covers every repository of that owner. Until that time a push to a listed repository passes the same canonical form to any branch, the protected ones included, except HEAD and refs/*. Every other condition and refusal stays. A missing file, no jq, a broken file or a past until means no exception. Deleting the file closes it.

Conditions of the gh commands. Exactly one -R Friendly-Technologies/<repo> is required. gh pr create also needs exactly one --head <branch>, so gh does not push the current branch itself. The options --admin and --auto refuse. gh run rerun takes a numeric run id first, then only --failed and -R.

Refused. The hook refuses a protected branch, a force (a + refspec, --force, --force-with-lease), a delete (:<branch> or --delete), any option after push, and any chaining or shell syntax (;, &, |, a redirection, $, a backtick).

Refusal text. The hook exits with code 2 and writes this format to stderr. The <rule> names the failed rule, for example chain, form, flag, remote, refspec, branch, target, repo or head.

git-safety hook: work command refused: <rule>: <detail>

Failure mode. The work branch is fail-closed in the same way as the preview branch. It runs as its own process, and any status but 0 is a refusal.

Declared residual. The strictness for gh run rerun is no boundary: a command with a leading space, such as ` gh run rerun x`, takes the normal path, which allows it. The hook does not see the shell environment of the agent (GIT_CONFIG_*, GH_REPO, a shell function named git or gh).

Auto mode. The classifier of Claude Code auto mode is a separate layer. You configure it in the settings of the user, not in this hook. A command can pass this hook and still need a permission there.

Hooks at a glance

Eleven hooks have install code a in the Hook catalogue. The installer registers ten of them in settings.json. The eleventh, git-safety-check.sh, runs from the frontmatter of four agents. The table shows the event that each hook fires on and what it blocks or does. Three of the eleven never block: main-compact.py, main-rules.py and artifact-registry.py. lane-nudge.py blocks one stop, and at most once an hour for each session. The health notice of lane-nudge.py is a block of its own, at most once every 300 seconds. The Hook catalogue states the same facts with the reason and the step for each hook.

Fires on Hook Timeout Blocks or does

PreToolUse, Agent|Task|SendMessage

price-gate.py

15 s

Unpriced dispatch, route rules, lane cap, leaf past 200K

PreToolUse, Bash, every agent

checkout-guard.py

5 s

Maven or git write in a guarded checkout (sub-agent); pgrep -f wait loop with no deadline; a wait on a bare timer such as sleep 240; ending processes by name pattern (pkill, killall, kill $(pgrep …​), `pgrep …​

xargs kill`); git stash (all but list, show)

PreToolUse, Bash, every agent

heredoc-guard.py

5 s

Unquoted heredoc with backticks

PreToolUse, Bash, every agent

encoded-exec-guard.py

5 s

A decoded payload (base64 -d, openssl base64 -d, xxd -r) piped or substituted into an interpreter

PreToolUse, Bash, agent frontmatter

git-safety-check.sh

None stated. The ft-ops entry declares 30 seconds.

push, PR, --no-verify, add -A, reset --hard, clean -f, push --force

PreToolUse, SubagentHandback

ownership-check.py

10 s

A hand-back of a sub-agent that leaves live things of its own unnamed, once for each set of things

SubagentStop

ownership-check.py

10 s

Never blocks. It ends the unnamed wait commands of a finished agent and writes a record.

PreToolUse and PostToolUse, Agent|Task

refresh-gate.py

5 s

A refresh brief that declares no inputs (once), and a refresh whose inputs did not change

SubagentStop

turn-guard.py

10 s

Turn end with nothing running

Stop, main loop only

main-compact.py

10 s

Never blocks. It types /compact into the main loop’s terminal at 300K of context.

Stop, main loop only

lane-nudge.py

15 s

A stop while fewer lanes run than the status line says, at most once an hour

SessionStart, startup|resume|clear|compact

main-rules.py

5 s

Never blocks. It gives the main loop its own rules.

PostToolUse, Artifact

artifact-registry.py

5 s

Never blocks. It records the link of a published artifact.

PostToolUse, CronCreate|CronDelete

main-rules.py

5 s

Hook catalogue

deploy/templates/hooks/ ships 29 scripts and 3 JSON policy files. The Installed line of each hook uses three codes. They are checked against deploy/scripts/economy.py, install.sh and install.ps1:

Code Meaning

a

Copied to ~/.claude/hooks/ and registered in ~/.claude/settings.json (or, for git-safety-check.sh, in an agent’s frontmatter).

b

Copied to ~/.claude/hooks/, not registered. The pipelines call the script through Bash.

c

Shipped in the repository only. No installer copies or registers it. To use one, copy it to ~/.claude/hooks/ and add the settings.json entry yourself.

Every hook fails open: an internal error exits without a decision and denies nothing. Seven hooks of code c ignore a call from a sub-agent (a payload with an agent_id): phase-gate.py, reuse-gate.py, verify-gate.py, durability-gate.py, rules-loader.py, design-gate.py and context-guard.py. Most of them deny each item at most once per session. verify-gate.py blocks at most twice per session. phase-gate.py denies until you record a route. A blocked call passes on retry after you satisfy the denial text.

Hook, install code, event What it denies or does Why If it blocks you

price-gate.py
Installed: a
PreToolUse Agent|Task|SendMessage, 15 s

Refuses a dispatch that is not priced. It checks model, effort, lane cap, unit size, the route rules (major_route, host_route, ops_route, ops_opus, integ_batch) and the context-reset lines. The pricing checks apply when ft-developer or bugfix-agent sends the dispatch. The lane cap and major_route apply to the main loop. A SendMessage to a leaf that holds more than 200K tokens of context is denied with the recipe for a fresh dispatch. Every denial ends with the ready-to-paste lines for the missing items. This includes a judgment lens or the test adversary on a cheaper model (model: opus, effort: high). For the checkpoint F trivial fix and delta fix, it also reads the run’s saved lens reports (<run>-cpF-r<n>-<lens slug>.md, and under a port-lane profile <run>-cpF-r1-postfix-<lens slug>.md) and fails closed to FIX_LANE on any error. A context or Touch: note prints once per 60 s per session, so a parallel batch of dispatches carries it once. The main loop over 300K of context gets a note at each 50K of growth that asks the owner for /compact. A SendMessage of the main loop that carries Run-cost raise: <new total> · by <who> (the new TOTAL, never the increment) is recorded on the lineage root. The hook refuses the message, with the corrected line, when the raise is a no-op, is unparsable, has a list marker or emphasis before it, or targets an agent that is not a top-level ft-developer id. A mid-line or >-quoted mention is only noted, at the next allowed Agent or SendMessage call. See Dispatch Economy Reference, Raise refusals and notes.

An unpriced dispatch is paid for before anyone can object.

Read the deny text: it names the rule. Add the missing line to the brief or use the named route. The rules are on Dispatch Economy.

checkout-guard.py
Installed: a
PreToolUse Bash, 5 s

For a sub-agent: Maven and git writes in a checkout listed in ~/.config/ft-ai-toolkit/guarded-checkouts. For every agent and the main loop: a pgrep -f wait loop with no deadline (the denial prints the deadline-bounded idiom), a run_in_background wait loop with no deadline (see Background waits with no deadline), a command whose only purpose is to wait on a timer (see Timer waits), a command that ends processes by name pattern (pkill, killall, kill of a pgrep/ps/lsof result, xargs kill fed by them; the denial says to end only a pid you recorded with p=$!, or to use mvn-slot.sh --cancel <checkout>), and git stash in any form but list and show. All linked worktrees share the stash stack. The denial prints the replacements: a worktree on the base commit, a commit or git rebase --autostash, a WIP commit. For a sub-agent on a 1-hour prompt cache, it also denies a repeated foreground wait loop or sleep-check chain, including waits that add up to 60 seconds (see Foreground waits of 1-hour-cache agents). For every agent and the main loop, it denies a command that only prints a waiting word (see No-op waits and sleep-check chains). It also adds a once-only context note to a bugfix-agent that started with Resets: handled and passes 250K tokens of context. For a coding leaf, it denies a test runner with unbounded output, adds a once-only context note past 200K, and denies every new runner past 400K (see The leaf bound).

The Bash working directory resets to your main checkout after every call. Two shells that wait on one pattern never end. A wait on a timer ends whether or not the awaited event happened, and each wake re-reads the whole context.

Work in a worktree under .claude/worktrees/. Give the wait loop a deadline. Wait on the job, not on a timer. FT_PGREP_WAIT=0 turns off the loop denial. FT_TIMER_WAIT=0 turns off the timer denial. FT_FG_WAIT_GUARD=0 turns off the foreground-wait denial. FT_NOOP_WAIT=0 turns off the waiting-word denial and the sleep-check chain rule.

heredoc-guard.py
Installed: a
PreToolUse Bash, 5 s

An unquoted heredoc whose text holds backticks.

Bash runs the backticks, and a backticked command can destroy files.

Quote the delimiter: <<'EOF'.

encoded-exec-guard.py
Installed: a
PreToolUse Bash, 5 s

A decoder (base64 -d, --decode, -D, openssl base64 -d, xxd -r) whose output reaches an interpreter (bash, sh, python, perl, node, eval, source) by a pipe or a substitution, also inside an ssh or bash -c command string.

The permission reviewer cannot read what an encoded payload runs (2026-11-13: an encoded script piped into bash inside an ssh command).

Send the plain script: scp or rsync the file, or use a quoted heredoc. Decoding to a file or to stdout is allowed.

turn-guard.py
Installed: a
SubagentStop, 10 s

Blocks once a turn end with nothing running, for ft-developer, bugfix-agent, refactor-agent and ft-fix-host. When a top-level lane ends for good, it also stamps the session. price-gate.py then tells the main loop at its next dispatch to refill its lanes. A SubagentStop hook cannot reach the parent. It also saves the final report of a coding leaf under the run’s units directory.

The harness turns that turn end into a forced hand-back.

Follow the instruction in the block. See The turn guard.

main-compact.py
Installed: a
Stop, 10 s

Never blocks. When the last turn of the main loop holds 300K tokens or more (FT_MAIN_COMPACT_AT), it types /compact keep: <what to keep> into the session’s Terminal.app tab. It acts only when TERM_PROGRAM is Apple_Terminal, at most once per 600 s (FT_MAIN_COMPACT_GAP_S), and only after 30 s without keyboard or mouse input (FT_MAIN_COMPACT_IDLE_S). Stop does not fire for sub-agents. A hook cannot run /compact, so it types the command as a person does, then sends two more Enter keys. It types nothing into a turn that continues: a Stop with stop_hook_active, or a Stop that lane-nudge.py blocked less than 60 seconds ago, gets no /compact. The detached sender checks the block marker a second time, 2 seconds after the start and before it types. It fails open. See Dispatch Economy, Context rules.

No setting reaches the main loop alone. autoCompactWindow stays at 600K for the sub-agents. Every main-loop turn re-reads the whole context. One main loop reached 966K in a live session, and 94% of its spend re-read that context.

Nothing to satisfy. In any other terminal, type /compact yourself when the price gate note asks for it. FT_MAIN_COMPACT=0, or the file ~/.local/state/ft-ai-toolkit/main-compact-off, turns it off.

main-rules.py
Installed: a
SessionStart, matcher startup|resume|clear|compact, 5 s, and PostToolUse CronCreate|CronDelete, 5 s

Never blocks. Gives the main loop the text of ~/.claude/main-rules.md and, when present, ~/.claude/main-rules.local.md as session context, in two commands (main-rules.py and main-rules.py --part 2) that each stay under the harness’s 10000-character cap for one hook’s output. See The global CLAUDE.md block.

The PostToolUse entry (matcher CronCreate|CronDelete) is a separate entry with one command. It runs on the main thread only and never prints. It appends each recurring session-only cron job to ~/.local/state/ft-ai-toolkit/session-crons/<session_id>.jsonl. The directory is mode 0700 and the file is mode 0600. At the next resume or startup of the same session ID, the bare main-rules.py command (part 1 only) prints a re-arm block before the rules. The block says re-arm: check CronList; re-create what is missing. It lists one row per live job, newest first. Each row starts with the job ID, then the cron, then the cut prompt. The block holds at most 1500 UTF-16 units. When every row fits, the last line is the file: <path>. Otherwise the last line is and N more in the file followed by the path. Nothing prints on compact or clear. A new session ID starts with an empty file, and jobs created before the install are unknown to the hook. A session that is already running does not load a hook entry added to the user settings after it started: neither /hooks nor a compaction reloads it, and a restart (claude --resume) does. The payload shape was captured from CLI 2.1.333 and 2.1.334. A deleted or expired prompt stays in the file until the file is untouched for 30 days. After 30 days, the hook deletes the file at the next resume or startup. To drop a stale job, delete every line of that cron and prompt from the file.

CLAUDE.md reaches every agent on every turn. Session-start context reaches the main thread only, and it arrives again after a compact. Sub-agents therefore do not pay for these rules.

Nothing to satisfy. It fails open: a missing file gives no context and the session starts. Put machine-specific main-loop rules in main-rules.local.md. The installer never writes that file.

lane-nudge.py
Installed: a
Stop, 15 s

Blocks the stop of the main loop once, with a short reason, when its own status line says lanes <running>/<target> and the transcript counts fewer running background agents. See The lane nudge.

The audit of 31 October to 2 November found 28 owner messages about lanes. A lane count that follows the target needs a check in code.

Start the next backlog items. If you cannot, say in one line backlog empty or backlog waits on <event or owner decision>. FT_LANE_NUDGE=0 turns it off.

ownership-check.py
Installed: a
PreToolUse SubagentHandback, 10 s, and SubagentStop, 10 s

On the hand-back of a sub-agent, it denies once when the agent still owns live things that its report does not name. It also refuses the hand-back of an ft-fix-host that dispatched no reviewer and declares none, at most 3 times (see The reviewer floor), and an ft-developer hand-back that claims delivery with no review of its own (see The ft-developer floor). On the stop of a finished agent, it ends the agent’s unnamed wait commands and writes a record. See Process ownership.

A finished agent left worktrees, browser sessions, detached processes and wait shells behind, and nobody owned them.

End each thing, or name it in the report as live: <kind> <id> · <what> · <next step for whoever takes over>. Then hand back again. FT_OWNERSHIP=0 turns the hook off. FT_OWNERSHIP_KILL=0 turns off only the kill.

refresh-gate.py
Installed: a
PreToolUse and PostToolUse, Agent|Task, 5 s each

Skips a refresh dispatch whose declared inputs did not change since the last refresh. It also denies once a refresh brief that declares no inputs. See Refresh gate.

A status page that is refreshed on a timer costs a full agent run, also when nothing changed (26 unconditional hourly refreshes, $28).

Add Refresh-inputs: to the brief, or add Refresh: force.

artifact-registry.py
Installed: a
PostToolUse, matcher Artifact, 5 s

Appends one JSON line for each published artifact to ~/.local/state/ft-ai-toolkit/artifacts.jsonl. It never blocks, prints nothing and fails open. The same script has command modes: see artifact-registry.py.

After an account switch an old link returns 404. The same audit found 7 owner requests to republish.

Nothing to satisfy. To stop recording, remove its settings.json entry.

decide.py
Installed: b
None. The orchestrators and price-gate.py call it.

Asks the decision model (Jev). Prints DECIDED <option> or UNSURE <why>. Always exits 0.

An enumerable choice costs less to ask than to deliberate.

It never blocks. Without the key at ~/.config/ft-ai-toolkit/openrouter.key it answers UNSURE and the caller decides. See Decision model (Jev).

unit-check.py
Installed: b
None. The orchestrator calls it after each unit.

Prints the zone status, diff size, new files, new-surface paths and a within or over-bound verdict. Optionally appends a journal line. Read-only on the repository.

One command replaces three to five bookkeeping turns per unit.

It never blocks. Read the verdict line and decide on PLAN_INVALIDATED.

lane-status.py
Installed: b
None. You or the main loop run it.

Prints a table of the running sub-agents and how long each has been silent. See lane-status.py.

One command replaces the "where are the lanes" questions.

It never blocks. Exit 2 when it finds no session.

vault-note.py
Installed: b
None. You or an agent run it.

Writes a note into the team vault with its hub entry, commit and push. See vault-note.py.

The same audit priced vault work at about $336 at list price. The steps are fixed, so one command can do them.

It refuses a note, with a line that names the fix. Exit 1, 2, 3, 4, 5 or 130: see the script section.

session-audit.py
Installed: b
None. You run it.

Prints cost, mechanical errors, waits and vault work over the last transcripts. See session-audit.py.

The audit numbers came from one-off scans. The script repeats them on any machine.

It never blocks. Exit 2 on a bad date.

diff-router.py + route-schema.json
Installed: b
None. The pipelines call diff-router.py plan. settings.json allows that command without a prompt.

Chooses the verifier lenses for a change. See Brief gates.

Routing is a computation over paths and diff lines.

Exit 1 means a conservative default applied. Exit 2 means a refused override.

evidence-store.py + evidence-schema.json
Installed: b
None. No agent or skill calls it today, only delegation-gate.py where you registered it, and you by hand.

Stores evidence packs and recorded verdicts. See Brief gates.

A repeat review over identical input need not be paid for twice.

It never blocks. FT_EVIDENCE_CACHE=off turns off verdict replay only.

git-safety-check.sh
Installed: a (frontmatter)
PreToolUse Bash, declared in the frontmatter of bugfix-agent, refactor-agent, ft-fix-host and ft-ops. Both installers copy it.

Exit 2 on git push, gh pr create, --no-verify, git add -A, --all or . with no path after it (git add -A src/x passes), git reset --hard, git clean -f and push --force. This also holds with -C <dir> or -c <k=v> before the subcommand. A flag such as docker buildx build --push -f x.Dockerfile is not a push. A plain git -C "$FT_VAULT_PATH" push passes, because the vault canon requires it. So does the first plain git push after cd "$FT_VAULT_PATH" && (or ;, or the literal vault path). A forced push, a second push, or a cd to anywhere else still blocks. The agent skips the hook when the file is absent. The hook allows a command that it cannot read. bash git-safety-check.sh --selftest runs its cases. The agent ft-ops starts the hook with --allow-preview-push and --allow-work-push. See Preview push of the git safety hook and Work push of the git safety hook.

The Iron Laws (no push, no PR, no history rewrite) need a check in code, not only in a prompt.

An agent cannot satisfy it. Do the operation yourself, with your consent, outside the agent’s Bash call.

delegation-gate.py + brief-schema.json
Installed: c
PreToolUse Agent|Task (per deploy/evals/delegation-gate.md). The toolkit states no timeout for this entry. The value is yours to choose and is unverified.

Not installed, by the owner’s ruling of 2026-11-03. Registered by hand: eight brief rules, R1 to R8, plus the route citation rules R9 and R10. See Brief gates.

A brief is checked before the dispatch is paid for.

Fix every violation that the deny text lists in one pass, or record --override "<reason>" for one dispatch.

phase-gate.py
Installed: c
PreToolUse: code writes (Edit tools and shell writes), Agent|Task, Skill

Denies an implementation write in the main loop until you record a route with python3 ~/.claude/hooks/phase-gate.py --route <route>. The routes are ft-dev, ft-fix, ft-refactor, trivial and other. trivial allows three code edits once per session. other allows none. An ft-* route allows none until the pipeline is dispatched. Tests, docs and the scratchpad are not gated.

Phases that CLAUDE.md only declares mandatory do not run by themselves (measurement).

Run the --route command, then dispatch the pipeline (/ft-dev, /ft-fix, /ft-refactor or its agent).

reuse-gate.py
Installed: c
PreToolUse: ExitPlanMode, Write of a new code file, shell creation of one

Denies once per moment until you answer the reuse check in ~/.claude/rules/code-quality/convergent-change.md section 0. It skips tests, migrations, scratch and build trees.

Searching costs minutes. Removing a written duplicate costs a refactor.

Search the graph and the repository. State one line: Reuse: searched <terms> - found <what> - verdict reuse, extend or new - <why>. Retry.

verify-gate.py
Installed: c
PreToolUse (design artifact, ExitPlanMode, writes, Agent|Task) and Stop

Blocks the end of a session that changed code with fewer than two different verifier lenses, or with a code change after the last lens. Denies a code write while a design artifact is unverified. At most two blocks per session.

A change reviewed only by its author is not reviewed.

Dispatch two different verifier lenses in parallel, one lens per invocation. Report Verified (diff): <lens> <verdict>. After a REFUTED verdict, fix it or record why it does not hold.

durability-gate.py
Installed: c
PreToolUse: Edit tools and shell writes

Denies once per path a note written under the scratchpad or /tmp that looks durable: a prose file, or a name with plan, handoff, spec, findings, notes and similar.

The scratchpad does not survive a reboot.

Write it where it lives: the repository docs directory, the vault, the memory directory or the run journal. For a real throwaway, say so in one line and retry.

graph-search-augment.py
Installed: c
PreToolUse Bash|Read

Never blocks. Adds the code graph’s context to a shell code search, or the file map to a whole-file read of a code file. Needs ~/.local/bin/codebase-memory-mcp.

A whole-file read costs about 13.6 KB. The graph’s map costs under 1 KB.

Nothing to satisfy. Read a line range after the map.

context-guard.py
Installed: c
PreToolUse: Read, Bash reads, and any call that requests a full-page screenshot

Denies once: a full-page capture, a transcript read (~/.claude/projects/*/.jsonl), and a re-read of the same bytes (at most 10 per session). A new range or a changed file is not a re-read.

Images and transcript reads fill the context (measurement).

Capture the viewport or an element, ask for a new range, or say in one line why you need the same bytes again.

rules-loader.py
Installed: c
PreToolUse: Edit tools, shell writes, Skill, Agent|Task

Denies a write once per item until the session has seen the rule modules whose paths: match the file, and the stack’s standard skill. It names them with their sizes and does not paste them.

Claude Code loads paths: rules natively. This hook adds a check that the session has seen the matching modules and the stack’s standard skill before a write.

Read the rule modules you touch and dispatch the named standard skill. Retry. See Rules.

user-visible-gate.py
Installed: c
PostToolUse: Edit tools and Bash writes

Never blocks. Adds a pointer to ~/.claude/rules/ux/user-visible-dod.md after an edit that a person can read, up to three files per session. See UI/UX.

A file-type trigger misses a controller that writes a sentence.

Apply the user-visible Definition of Done.

design-gate.py
Installed: c
UserPromptSubmit (hint) and PreToolUse (deny once)

Denies the first edit to a user-facing file until the session names the design owner skill, or says in one line that no design property applies. A prompt that names a design property gets the owner as a hint. See UI/UX.

Nothing executed the routing table in rules/ux/design-skill-routing.md.

Dispatch the owner skill from the routing table, or state which properties are in play and why none applies.

The turn guard

A background sub-agent can end a turn with plain text while no child agent and no own background command runs. The harness then tells it to deliver its report ([handback-send-enforce]), and that ends its run. For an orchestrator in the middle of a unit this is a lost lane. It hands back half-done and is relaunched from its journal. This happens to orchestrators that wait on an idle child, on an armed Monitor, or on a report that has already arrived.

turn-guard.py runs on SubagentStop, before the harness’s enforcement. It runs only for ft-developer, bugfix-agent, refactor-agent and ft-fix-host. A probe in an interactive session verified it (evidence §11). Since Claude Code 2.1.309 the harness text may arrive just before the block. The agent still keeps its run. The guard blocks that one turn end, once, with the instruction to follow instead:

Situation at the turn end What the guard says

A child agent went idle on its own work and has not delivered

Wait in the background for the child’s next SubagentHandback line: until { tail -c +<size+1> <child transcript>; } | grep -q …​, with the size taken at the block. Then act on the report. The command quotes each child transcript path. Only a child whose id is made of [A-Za-z0-9_-] characters counts as a child. The reason ends with a cue for the wake turn, followed by the canon pointer: if a notice says a child "is waiting on its own background work", arm the wait in that turn. The <output-file> of the notice is the child’s transcript.

No child is running and a Monitor is armed

A Monitor does not keep an agent alive. Wait for what it watches with ONE background command that has its own deadline (run_in_background: true), then end the turn.

No child is open, and the turn ended on "waiting" words ("waiting", "watching", "monitoring", "once it arrives", …​)

A report that was already delivered is in your context: act on it. A job, CI run or demo step is waited for by ONE background command that ends with it (run_in_background: true), then end the turn. If the work is done, deliver the report.

The guard lets the turn end in these cases:

  • A child is running as the harness counts it. A child counts from its dispatch, or from a message of its parent that resumed it, until its first end of turn. A child that woke on its own background job no longer counts.

  • One of the agent’s own background commands has not reported back.

  • The guard already blocked once (stop_hook_active).

  • The agent has delivered its report.

  • The guard itself errors.

The guard never blocks on a file. It opens every file non-blocking, and the file must be a regular file. The size cap is 1 MiB for a meta file and for lane-ended.json, and 8 MiB for a journal or unit report. A meta file or transcript that is refused or over the cap is an error on the verdict path, and the guard allows the turn end (fail-open). Other paths have their own outcome, and none of them changes the turn-end decision:

  • A refused journal is skipped as a candidate.

  • A refused or oversized (over 8 MiB) unit report is not saved.

  • A refused or oversized leaf meta, parent meta or own transcript on the save path also means the unit report is not saved.

  • A refused own meta on the lane-end path is treated as missing, so the lane is stamped as top-level.

  • An unreadable lane-ended.json is replaced by a fresh file. If the path is a directory, the replace fails and nothing is written. If it is over 1 MiB, it is reset to the stamp of the current session only.

Three effects are visible to an operator:

  • A symlinked turn-guard.log loses its log lines.

  • A symlinked lane-ended.json is replaced by a regular file.

  • A unit report whose final path component is a symlink is not saved. The write opens the path with O_NOFOLLOW and fails with ELOOP.

The guard logs its decisions to ~/.local/state/ft-ai-toolkit/turn-guard.log. python3 ~/.claude/hooks/turn-guard.py --selftest runs its cases. The replay that measured the guard is in Evidence.

Timer waits

checkout-guard.py denies a Bash command that only waits on a timer. The denial applies to the main loop and to every agent, in the foreground and with run_in_background. A timer wait ends whether or not the awaited event happened, and each wake re-reads the whole context. The audit of 31 October to 2 November counted 482 turns that the harness refused for a bare sleep.

The hook denies a command when every simple command in it is a timer or noise, and at least one timer exists.

Part of the command Counts as

Timer

sleep …​ (also behind nohup), or python3 -c with only import time, time.sleep(..), sleep(..), pass or a print of a literal.

Timer loop

A for loop whose body is only timers and noise, over a word list, {1..N}, $(seq …​) or …​, or a while or until loop whose condition is true, :, false, [ 1 ], a sleep or only a comparison on $SECONDS.

Noise

echo, printf, date, true, : or a bare assignment. A word with $( or a backtick, or a redirection to a file, makes the command real work.

These commands pass:

  • A loop that checks a job: until <check>; do sleep 30; done, or for i in $(seq 1 46); do grep -q <done> f && break; sleep 5; done.

  • The four-minute chunk: e=$SECONDS+240; until <check> || [ $SECONDS -ge $e ]; do sleep 20; done.

  • A sleep before real work: sleep 2; osascript …​.

  • Any command the hook cannot parse as timer-only, for example bash -c 'sleep 5' or sleep 5 | cat.

The denial text names the replacement. If a child agent or a background command of yours runs, end the turn: its completion wakes you. Otherwise wait on the job’s process id, done marker or log line, with a deadline. FT_TIMER_WAIT=0 turns the denial off.

The wait card

Every denial of checkout-guard.py for a wait ends with the same card. The card is also in rules/agents/common.md, and a test pins that the two texts are identical. A brief for a receiver that waits on CI, a gate or a host carries the filled-in form as a Wait: line.

Wait forms (pick the first that fits; checkout-guard allows each):
- a job you start: start THE JOB with run_in_background: true; its completion wakes you; no wait command at all.
- CI of a PR: `gh pr checks <n> --watch --interval 60` with run_in_background: true.
- a log line or done marker of a job whose pid you hold: `e=$((SECONDS+3600)); until grep -qE '<done>|<fail>' "$log" || [ -f "$done" ] || ! kill -0 "$pid" 2>/dev/null || [ $SECONDS -ge $e ]; do sleep 30; done`
- a pid you hold: `e=$((SECONDS+3600)); while kill -0 "$pid" 2>/dev/null && [ $SECONDS -lt $e ]; do sleep 30; done`
Over ~4 min: run_in_background: true and end the turn. Then say which condition ended it.

The three command forms also count as waits for ownership-check.py and janitor.py. See What counts as a wait.

Foreground waits of 1-hour-cache agents

checkout-guard.py also denies a repeated foreground wait loop to a sub-agent on the 1-hour prompt cache. Each chunk of a foreground poll is a wake turn that re-reads the whole context. One background wait costs one wake.

Agents. The roster is FG_WAIT_AGENTS: ft-java-coding-agent, ft-angular-coding-agent, ft-python-coding-agent, ft-coding-agent, ft-ops, bugfix-agent, ft-fix-host, ft-developer, refactor-agent, ft-sdd and ft-ui-ux-design. The main loop and the agents on the 5-minute cache (general-purpose and the reviewers) are never affected. They keep their 4-minute foreground chunks.

What counts. A foreground bounded wait loop is an until or while loop with a sleep command in the body (the do may be on its own line) and a condition that only looks (grep -q, [ -f x ], kill -0, true, a $SECONDS test), or a for loop with a sleep command in its own body whose other commands check nothing, or are all checks and one of them leaves with && break. The hook reads loops from the parsed command, so a loop inside a heredoc, a quoted string or a comment never counts, and while read h; do ssh $h uptime; sleep 1; done is real work. A loop that does real work, with or without a throttling sleep or a break that does not guard a check, never counts. A sleep that is only an argument is not a sleep command. The hook reads the deadline from SECONDS+<n> or a literal product such as SECONDS+2*60, or from a literal word list, $(seq A [S] B) or {A..B[..S]} times the sleeps of the body. Anything else has no readable deadline, and so has a command that also holds an until or while loop without a $SECONDS bound. A call with run_in_background: true never counts for this foreground rule. The background rule in Background waits with no deadline applies to it.

The sleep-check chain. A foreground sleep N; <checks> also counts as a wait of N seconds. It counts only when all of these hold:

  • N is a literal number of 30 or more. A sleep with several arguments or an unreadable argument does not count.

  • The chain has no loop, no command substitution and no heredoc.

  • Every other command is a read-only check (grep, tail, cat, ls, wc and similar) or a variable assignment. A leading cd <dir> is allowed. A git command counts as a check only for status, log, diff, show, rev-parse and ls-remote. A gh command counts only for pr checks, pr view, pr list, run view and run list.

  • No command can write or act elsewhere. These never count: ssh, docker, kubectl, oc, systemctl, wget and awk, sed -i, curl with a method, body or output flag, find -delete or -exec, sort -o, kill with anything but -0, and any redirect other than to /dev/null.

For this chain, the 15-minute window and the duplicate rule in the next table apply from 30 seconds, not from 60. The chain applies to the agents of the roster only. Sleeps alone are a timer wait (see Timer waits).

When the hook denies. The hook keeps the time and the command of the last allowed wait of each agent_id, and the list of its allowed waits in the window, at most 32. It denies the call in any of the three cases.

Case Condition

(a)

The loop has a deadline of 60 seconds or more (or the hook cannot read the deadline), and the same agent ran an allowed foreground wait within FT_FG_WAIT_WINDOW_S seconds. The default is 900.

(b)

The agent sent the identical wait command within FT_FG_WAIT_DUP_S seconds. The default is 5.

(c)

The agent’s foreground waits in the last FT_FG_WAIT_WINDOW_S seconds, the earlier ones plus this one, add up to 60 seconds or more. An earlier wait whose deadline is unreadable counts as 60 seconds.

The first wait of an agent passes. A loop with a deadline under 60 seconds passes only while the agent’s waits in the window stay under 60 seconds in total, and it is not a duplicate of the previous command. A sleep-check chain of 30 seconds or more falls under case (a).

Denial text. The text starts with checkout-guard: and gives one reason: the identical foreground wait was sent twice within seconds., a second foreground wait of 60 s or more within <n> s of your last one. (30 s for a sleep-check chain), or a second foreground wait within <n> s of your last one: your foreground waits in the last <window> s add up to <total> s, 60 s or more. The text then tells the agent to start the wait with run_in_background: true and to end the turn, because the completion wakes it. It ends with the wait card.

State. The hook writes fg-wait.json in FT_LANE_STATE_DIR (default ~/.local/state/ft-ai-toolkit), mode 0600. The file holds the time and the command of the last allowed wait of each agent, and a list of its allowed waits as a time and a number of seconds, at most 32. A state entry written by an older version counts as one wait of 0 seconds. The hook drops entries older than one day.

Failure mode. The guard is fail-open. A payload without agent_id or agent_type, an unreadable state file or a failed write allows the call. A corrupt state file is replaced.

Background waits with no deadline

checkout-guard.py denies a command with run_in_background: true that holds a wait loop with no deadline. The rule applies to the main loop and to every agent. Its harm does not depend on the prompt cache: a loop that never ends keeps running after its lane ends, and the sandbox cannot kill it. On 2026-11-13, an until loop polled every 20 seconds for a line that never came. It ran for hours after its lane ended.

A loop is bounded when its own condition or body compares $SECONDS or date +%s with a value, quoted or not, such as [ $SECONDS -ge $e ], SECONDS < e or [ "$(date +%s)" -lt "$end" ]. A test in the body counts only when it leaves the loop (&& break, exit). An echo $SECONDS, an ls -lt, a date +%s > file, a file count compared with -ge, or an e= assignment that no test in the loop reads is not a deadline. A for loop is also bounded when it has a readable round count. $EPOCHSECONDS is no clock: the harness’s zsh has no zsh/datetime loaded, so it is empty and a test on it never comes true. Any other background wait loop is denied.

The denial text starts with checkout-guard: a run_in_background wait loop with no deadline. It gives this form and ends with the wait card:

e=$((SECONDS+N)); until <done> || [ $SECONDS -ge $e ]; do sleep 30; done

N is the longest the job may take. FT_BG_WAIT_GUARD=0 turns this denial off. An error in the check allows the command.

The same until or while loop sent in the foreground is denied too, to the main loop and to every agent. A for loop is not denied in the foreground, because its rounds end it, except a C-style for ;; with no condition, which never ends. At its Bash timeout the harness moves a foreground command to the background instead of ending it, so a loop whose condition never comes true runs on there. On 2026-11-29, a verifier’s foreground until grep waited for a line that its finished job never printed. The harness moved it to the background, and it ran for 3 days. In the 13 hours from 2026-12-01 19:00 UTC, 25 such loops ran and 10 of them were moved. The denial text starts with checkout-guard: a foreground wait loop with no deadline. An agent on the 1-hour prompt cache gets its own loop bounded for the background. Any other caller gets its own loop bounded inside its own call timeout and kept in the foreground: e=$SECONDS+T, where T is the call’s timeout minus 10 seconds (110 for the default 120 s), so a 4-minute chunk stays a 4-minute chunk. A loop that sits inside a for, an if or a { }, or whose work after it carries a # comment, is never rewritten, and every offered form must parse in bash and zsh; otherwise the denial offers the wait card’s form. A loop whose body counts rounds (n=$n+1) reads as work, not as a wait, and passes. A test that only ends the loop when its producer is gone (! kill -0 $p) is no deadline. FT_FG_DEADLINE_GUARD=0 turns the foreground half off.

Every denial that tells you to send a form with run_in_background: true says on its second line what the turn after the launch is: no call at all, no echo, no sleep and no read of the output, until the completion notice wakes you. On 2026-12-01 and 2026-12-02, 22 of 53 such launches were followed at once by one of those calls, and another rule denied it.

FT_FG_WAIT_GUARD=0 turns the guard off. It also turns off the sleep-check chain rule.

Background commands that read stdin with no input

checkout-guard.py denies a command with run_in_background: true that runs a stdin reader with no input. The rule applies to the main loop and to every agent. The harness leaves the stdin of a background command open and never writes to it. The reader waits for data that never comes, and the call never ends. On 2026-12-01, a stray cat >/dev/null in a background command held a lane for 1 h 57 min.

The readers are cat, head, tail, wc, sort, uniq, tee, read, mapfile, readarray and python that reads - or has no script. cat, head, tail, wc, sort and uniq are readers only when they have no file operand, or when the operand is -. read, mapfile and readarray are readers only without -u, which reads another file descriptor, and read also only without -t, which times out. python with -c, -m, --version or any --help option is not a reader. A simple $…​ counts as one word, so head -n $N+1 file has its file operand.

A reader is fed in these cases:

  • A pipe goes into it.

  • A < redirect, a heredoc or a herestring is on it.

  • The same redirect is on the loop or the group that holds it.

  • An earlier exec < redirects stdin.

The denial closes the stdin of the whole command, never of one reader: a reader that a pipe feeds would read nothing. For a one-line command the text starts with checkout-guard: send this instead, with run_in_background: true, then end your turn: and gives the command in this form:

{ <command>; } </dev/null

If the command has more than one line, a comment, a backtick, a trailing & or a long text, the denial tells the agent to wrap the whole command in a line {, the command, and a line } </dev/null, or to name the file the reader should read. A form is offered only when the hook allows it and bash -n and zsh -n parse it. When neither form passes, the hook allows the command.

FT_BG_STDIN_GUARD=0 turns this denial off. An error in the check allows the command.

Known misses. The check does not see these cases:

  • A reader inside $(…​), backticks, bash -c or eval.

  • A command that the hook’s tokenizer splits where the shell does not. The check allows such a command: a pipe into a { } or ( ) group, an output process substitution >(…​), an escaped operator such as -exec …​ \;, a heredoc delimiter that is not a plain word, a blank or comment line after a trailing |, a function definition, a case, or a $…​ with parentheses inside. Quoted strings and comments do not count.

  • An operand that expands to nothing, such as cat $F with F empty.

  • A reader behind a wrapper other than an assignment, env, nohup, time, command, exec or !, such as nice, sudo, stdbuf or /usr/bin/env.

  • A reader that the list does not name, such as grep, sed, awk, jq, xargs, ssh without -n, or bash or sh with no script. python3 -i script.py is also missed; a bare python3 -i is denied.

  • A foreground call. The Bash timeout bounds it.

Known residual. A background wait loop with no deadline that also runs a starved reader is denied twice: first for the loop, then for the reader in the bounded form.

No-op waits and sleep-check chains

Two wait shapes added to checkout-guard.py cost a turn and wait for nothing. Between 2026-11-08 and 2026-11-11, agents sent about 120 echo waiting turns. On 2026-11-10, one agent polled one background job with 13 calls of sleep 58; grep …​. Each call re-read the whole context.

Shape 1: a command that only prints a waiting word. The hook denies it for every agent and for the main loop. The command must be exactly one echo whose text is a waiting word: waiting, wait, idle, pending or standby. The word may be quoted, may continue with words joined by -, _ or a space, may end with ., ! or :, and is not case-sensitive. These commands are denied:

echo waiting
echo "waiting on bfd7e07um"
echo waiting-for-green
echo 'Waiting for CI...'

The denial text starts with checkout-guard: a command that only prints a waiting word. It says that waiting needs no command. If a child agent or a background command of yours runs, end the turn with no tool call, and its completion wakes you. The text ends with the wait card.

Shape 2: a sleep-check chain. For the agents of the roster, the hook counts a foreground sleep N; <read-only checks> as a foreground wait. The previous section describes the conditions and the rules that follow.

Command Result

sleep 58; grep -c ok out.log

Counts as a foreground wait of 58 seconds. The second one within 900 seconds is denied.

sleep 30; gh pr checks 29; tail -n 5 run.log

Counts as a foreground wait of 30 seconds.

What still passes.

  • echo ok and echo done. Verifier and ops agents use them as liveness probes.

  • Any echo that holds a $, a backtick, a redirect, a pipe or a second command, for example echo waiting > f or make; echo wait.

  • sleep 2; osascript …​ and any sleep before real work. A command that is not a read-only check is work.

  • A sleep of less than 30 seconds in a chain.

  • Every command with run_in_background: true.

  • The main loop and the agents on the 5-minute cache, for shape 2.

The hook is fail-open for both shapes. A command that the hook cannot parse, or a sleep argument that is not a literal number, passes.

Variable Meaning

FT_NOOP_WAIT=0

Turns off both shapes: the echo denial and the sleep-check chain rule.

FT_FG_WAIT_GUARD=0

Turns off the foreground-wait guard, and with it the chain rule. The echo denial stays on.

Replayed against the logged calls of 2026-11-08 to 2026-11-11, shape 1 newly denies 99 calls, and all 99 were polls with nothing to read. Shape 2 counts 51 unique chains, and all 51 were polls of background output.

The leaf bound

checkout-guard.py also bounds a coding leaf. A coding leaf is a sub-agent whose type ends with -coding-agent. The main loop and every other agent never reach this check. A coding leaf re-reads its whole context on every turn. Leaves reached 417K to 542K tokens of context while they read test consoles. The canon is rules/agents/common.md, section "Context bound for coding leaves". The hook is an economy guard: it fails open, it runs in Claude Code only, and it does not parse bash -c or eval.

The hook has three parts.

  1. Output guard. The hook denies a build or test runner whose output is unbounded. The runners are, for example, mvn, gradle, pytest, npm test, go test and a test script. The denial applies in the foreground and in the background. The output is bounded when the runner writes its stdout to a file, or when the last command of the pipeline is tail, wc or test_verdict.py. The hook also denies a cat of a .log file, a .output file or a /tasks/ path. The denial text gives the one-command form: redirect to a log, print rc and tail -n 40, and on a failure grep -m 3 -A 30 of the failure lines. FT_LEAF_OUTPUT=0 turns this part off.

  2. Context note. On the first Bash call of an agent past FT_LEAF_CTX (200000 tokens), the hook adds a note once. The note says to hand back at the next settled point only if more than about B tool calls of work remain. If fewer remain, the leaf finishes the unit. B falls as the context grows. The note prints B for 200K, 250K, 300K and 400K. FT_LEAF_NOTE=0 turns this part off. The note ends with the hard line when the hard line is on.

  3. Hard line. Past FT_LEAF_HARD_CTX (400000 tokens), the hook denies every new runner, bounded or not. The denial tells the leaf to write the ## HANDOFF and return Status: HANDBACK. Other commands still run. FT_LEAF_HARD_CTX=0 turns this part off.

The hook has no size trigger. The dispatcher judges the size of a unit.

Variable Default Effect

FT_LEAF_OUTPUT

1

0 turns off the output guard.

FT_LEAF_NOTE

1

0 turns off the context note.

FT_LEAF_NOTE_STATE

the state directory

A path for leaf-note.json.

FT_LEAF_CTX

200000

The line for the context note. price-gate.py reads the same variable for its SendMessage denial (see Dispatch Economy Reference, price-gate).

FT_LEAF_HARD_CTX

400000

The hard line. 0 turns it off.

FT_LEAF_RELOAD_COST

535000

An estimate of the cost of a fresh continuation, in input-equivalent tokens. B is computed from it with the saving model of price-gate.py.

The note is sent once for each agent id. The hook records the agent in leaf-note.json before it prints the note. If the file cannot be written, the hook prints no note. Two leaves that write the file at the same time may lose one entry. The effect is that one note is sent again.

A hand-back is not a failure. price-gate.py does not flip the arm of a continuation, which has the description <unit> continue (fresh) or a line handback: fresh in the first 600 characters of the brief. The rules of the dispatcher are in Dispatch Economy Reference, Leaf hand-back.

The ops nudge

checkout-guard.py also notes a main loop that runs many git, gh, ssh or scp calls with a large context. Each call re-reads the whole context. The note applies to the main loop only (a payload without agent_id). It never denies a command.

A command counts when a simple command starts with git, gh, ssh or scp, after a cd <dir> && prefix and VAR=value prefixes. Only a call made while the last turn holds more than 200000 tokens of context counts. The third counted call within 10 minutes adds this note as additionalContext:

checkout-guard: main loop at ~300K context; this is git/gh/ssh call 3 in 10 min, and each one re-reads the whole context. Hand the batch to ONE ft-ops agent with the list and what done means (main-rules: "Main loop over ~200K"); keep only approvals and rulings.

The number in the text is the real context size and call count. A denied command gets no note.

Variable Default Meaning

FT_MAIN_OPS_NUDGE

on

0 turns the note off.

FT_MAIN_OPS_CTX

200000

Tokens of context above which a call counts.

FT_MAIN_OPS_GAP_S

1800

Seconds between two notes.

The state file is main-ops-nudge.json in the state directory. The hook removes sessions untouched for 7 days. A failed write or an unreadable transcript gives silence.

The lane nudge

The main loop ends a turn with a status line such as lanes 14/25: running lanes, then the target. This is the literal form that main-rules.md asks for. The hook also reads the forms lanes ~12/25 and the Russian forms that the transcripts show. lane-nudge.py runs on Stop. It takes the status line from the turn’s final text in the Stop payload (last_assistant_message); without it, it re-reads the transcript for up to 2 seconds until the turn’s final message has landed, and stays silent if it has not. When the transcript counts fewer running background agents than the target, it blocks the stop once and asks for the next backlog items. The reason is fixed text and holds only numbers:

lane-nudge: your last status line says lanes 5/25 and the transcript counts 3 running background agents;
their own sub-agents are not counted. Start the next backlog items now. If you cannot, say so in one line:
"backlog empty", or "backlog waits on <event or owner decision>". Details: python3 ~/.claude/hooks/lane-status.py

A line without a target, such as lanes 38 — backlog: …​, is a status too. The hook then takes the target from the last lanes R/T line that this session wrote (target in lane-nudge.json), else from FT_MAX_LANES. The session’s own line wins, because it carries the number that you asked for. The reason names the source. With neither, there is no refill decision. The next lanes R/T line replaces the stored target. The hook removes a session’s entry after 7 days without a change. hold_target in the same file is never used as a target, so a wrong value that an older version stored there has no effect.

The hook also compares the claim with the count. When the final text claims more than 5 lanes above the count, and more than 50% above it, the hook blocks the stop, at most once per hour. The text gives both numbers and asks the session to recount, or to list what else it counts as lanes (trains, CI runs). A hold does not silence this check.

The hook counts every running background agent of the main loop, helpers such as Explore and ft-ops included. It reads the count from the transcript: a launch starts an agent, and a finish notice, a hand-back or a stop ends it. A SendMessage to an agent starts it again, and a finish notice or a hand-back stamped before that message ends nothing. The sub-agents of these agents are not counted. An agent silent for more than 3 hours is presumed dead and is not counted.

The hook reads a finish notice or a hand-back only at the start of a message, so quoted text cannot end an agent:

  • A <task-notification> counts only when the text starts with it, after blank space. The hook takes the first notification of the text and ignores any later one.

  • The hook reads the task id and the status only from the head of the notification, before its first <summary>. The head must start with <task-id>. A title or a report that quotes these tags cannot end an agent. A notification with no id and status before its <summary>, or with another tag before the id, ends nothing.

  • A [Subagent hand-back] text counts only when its first line is an <agent-message from="…​"> tag. The hook accepts the prefix Another Claude session sent a message: before the tag. It takes the first agent name only.

  • The marker [Subagent hand-back] counts only right after the head. The hook allows up to two harness warning lines between them. A line counts only when it starts with one of the two live prefixes, Note: The server-side auto mode classifier or SECURITY WARNING: auto mode blocked, and is at most 500 characters long. Other text between them means no hand-back.

  • The stop text Successfully stopped task: <id> counts only when it starts the message and the tool result carries a task_id.

  • A line of origin human never ends an agent, and neither does a line that holds a tool result.

  • A queued line (queue-operation with enqueue) counts only when its text starts with the notification tag. A queued owner prompt that quotes a notification does not end an agent.

A missed finish keeps an agent counted. That suppresses a nudge for up to 3 hours and never causes one.

For the refill, the hook compares the count of the transcript with the target, not with the running number in the status line. With lanes 8/12 and a count of 8, the hook fires, unless one of the cases below applies. The refill nudge stays silent in these cases. A case that also silences the claim check is listed again below:

  • It is switched off (FT_LANE_NUDGE=0, or the file ~/.local/state/ft-ai-toolkit/lane-nudge-off).

  • The caller is a sub-agent, or the stop is already the result of a hook block (stop_hook_active).

  • The last status line is older than your newest message, or the target is 0 or unknown.

  • The main loop has said why the work waits. A message that says the backlog is empty, or that the backlog waits on an event or on an owner decision, is a hold. The hook matches phrases such as backlog empty and backlog waits on, and their Russian equivalents. A negation cancels the match: the backlog is not empty, backlog isn’t done yet and not blocked are not holds. So are a work item (backlog item 3 done) and a statement about running agents (the rest of the agents wait for CI). The state file lane-nudge.json records the hold. A hold ends when the target changes, when you write a new message, or after 2 hours.

  • The previous nudge of this session is less than 1 hour old.

  • The transcript walk did not finish in its 8 seconds.

  • The final text is neither in the payload nor in the transcript within 2 seconds.

  • Any error occurs (fail open, exit 0).

The claim check compares the claim of the final text with the count. These cases silence it. A hold does not:

  • It is switched off (FT_LANE_NUDGE=0, or the file lane-nudge-off).

  • The caller is a sub-agent, or stop_hook_active is set.

  • The final text has no status line, or its only lanes <number> line is one that the hook cannot read. An older status line is never judged in its place.

  • The final text has only a lanes R/T pair inside prose, such as Merged. Lanes 64/73 wait for CI. Such a pair names lanes and claims no count.

  • The final text is neither in the payload nor in the transcript within 2 seconds.

  • The hook is killed at its 15 second timeout. The saved walk then stays on disk, so the next stop goes on from it.

  • The claim is 5 lanes or fewer.

  • The claim is at most 5 lanes above the count, or at most 50% above it. A claim below the count is never judged.

  • A claim check blocked less than FT_LANE_NUDGE_GAP_S ago.

  • The transcript walk did not finish in its 8 seconds.

  • Any error occurs.

  • The state file cannot be written.

The count is fast only with a saved walk. The first stop on a large transcript reads at most 8 seconds of it and saves the offset it reached. That stop decides nothing that needs the count. The next stops go on from the saved offset until the whole transcript is read. After a walk that took more than 4 seconds, the health notice also waits for the next stop. The offset is in lane-health/<session id>.json, also with FT_LANE_HEALTH=0. When that file cannot be written, a transcript that takes more than 8 seconds is never counted. The saved walk assumes that a transcript is only appended to. A transcript rewritten in place with the same inode and at least the same size is not walked again from its start. With FT_LANE_HEALTH=0, the cached health verdicts in that file are ignored, so no lane is left uncounted by an old verdict. A stored time more than one day ahead of the clock counts as no time, so it cannot silence the hook.

Two terms differ in meaning: the lane target and the lane cap. The target is the number in the status line, and the nudge counts all background agents against it. The cap is FT_MAX_LANES in price-gate.py with a default of 6, and it counts only top-level orchestrators. The cap can therefore deny the launch that the nudge asks for. The denial says to start the lane when a lane hands back, or to resume a paused one. Set FT_MAX_LANES to at least the number of orchestrators that you want to run at once. See Dispatch Economy, The lane cap.

Variable Default Meaning

FT_LANE_NUDGE

on

0 turns the hook off.

FT_LANE_NUDGE_GAP_S

3600

Seconds between two nudges of one session, and between two claim checks that block.

FT_MAX_LANES

none here

The target for a lanes N line when the session stored none. price-gate.py reads it as the lane cap.

FT_LANE_HOLD_S

7200

Seconds that a hold lasts.

FT_LANE_STALE_S

10800

Seconds of silence after which an agent is not counted. lane-status.py reads the same variable.

FT_LANE_STATE_DIR

~/.local/state/ft-ai-toolkit

Directory of lane-nudge.json, the per-session state.

The hook reads these variables from its own environment. The installer sets none of them and adds no key to settings.json env, because a new key there reaches the shell of every agent. The hook writes its state before it prints the block, so a failed write gives silence and never an unlimited block.

Known limits:

  • After a nudge, a shortfall can go unnudged for up to 59 minutes.

  • A hold can silence the hook for up to 2 hours when the main loop launches lanes and then falls short again.

  • A dead agent that the hook still counts suppresses a nudge for up to 3 hours. It never causes one.

  • lane-nudge.py and main-compact.py both run on Stop, side by side. When the nudge blocks the stop, it writes the marker lane-nudge-block.json (session id and time) before it prints the block. main-compact.py types nothing for the same session within 60 seconds of that marker. The nudge writes the marker after its transcript walk, which can take more than a second. So the detached sender of main-compact.py reads the marker again after a 2-second wait, through main-compact.py --clear <session id>, and sends nothing when the marker is present or the check fails. A marker that appears after that second look still lets the /compact land in the continued turn. No live Terminal.app run drove this case, or a permission dialog that an Enter answers.

  • The status line is the last line of the message that starts with lanes R/T or lanes N and then ends or goes on after a dash, ·, (, [, ., ;, :, a comma, a ` or the word `running`. A comma followed by a word that holds a digit starts a list (`lanes 64, 73`, `lanes 64, K31`). A ` counts only when a spaced em dash follows later on the line. Markup may sit around the number and the word (lanes 38, lanes: 38). A line that starts with lanes <number> but goes on in another way is unread. It hides older status lines only when its message has no readable one, so the hook never quotes an older one as the last. When no line of the message is such a status line, the hook takes the last lanes R/T pair that starts a line or a sentence, and never stores its target. A pair inside a bracket, a list item or a comma list is a set of lane names, such as batch D2 (lanes 64/73), and not a status. A line that starts with лейны or лейнов is read like a lanes line. In prose, the Russian forms need a target. R and T are numbers of at most 9 digits each. A longer number is not a status. A date shape such as lane 11/02 merged is not a status. A day below its month, such as lane 10/31 merged, reads as a status.

  • Two sessions that stop in the same instant can overwrite each other’s entry in lane-nudge.json. The cost is one repeated or one missed block. This is accepted.

  • A queued owner prompt that starts with a pasted notification ends the agent, because a queued line has no origin to tell the two apart.

  • A hold phrase in the past tense still holds. Example: the backlog was empty yesterday, now 40 new. The cost is one silence of 2 hours.

The health notice

lane-nudge.py has a second branch beside the nudge. It finds lanes that ended, froze or never reported. It runs with or without a lanes R/T status line, and a hold does not silence it. It runs at most once every FT_LANE_HEALTH_GAP_S seconds (default 300) for each session. A pass stops after 4 seconds, and the agents that it did not reach are not judged.

The pass looks only at top-level background agents that the nudge counts as running. A harness flag finished means that the agent is stopped right now. It does not mean that the agent ended. Each turn end sets the flag, and a resume clears it. An agent counts as stopped when finished is true and its transcript was not written later than 60 seconds after the meta file. Any other agent is run. The pass classifies a stopped agent in this order:

State Meaning Counted as running

UNSEEN

A hand-back was delivered, and its report never reached this session.

No

wait

A job of the agent still has a writer, or a child of the agent is alive. Nothing to do.

Yes

FROZEN

Open jobs exist, none has a writer, and no child is alive. Its wait is gone and nothing will wake it.

Yes

FROZEN?

Only open monitors exist, and the agent was silent for 3600 seconds or more (FT_LANE_MONITOR_S).

Yes

ENDED

Nothing wakes the agent, and it gave no successful hand-back.

No

A child is alive when the agent started it, the transcript holds no completion notice for it, and the child is run or wait. A child that is deeper than one level counts as alive. A job that the harness moved to the background, a child that the agent resumed by SendMessage, and a child that a queued message will resume all hold the agent in wait, and a completion notice stamped before that message does not end the child, even when the transcript writes it later. Only the sender’s own children reopen, and both wordings of a moved job open one: the harness moves a command either after its timeout or after a long run. The LEFT event is a record of a top-level lane that left an unnamed live item or had a wait ended. It is announced once, and declared items never announce.

The notice has one line for each new event. It shows at most 10 lines. The rest is a count: +N more, listed by the command below.

lane-nudge: 2 lane(s) need you:
  UNSEEN a90953db "F-COR-13 Stage 3 implement" handed back at 13:46Z but the report never reached you: python3 ~/.claude/hooks/lane-status.py --session sess-1 --report a90953db11112222
  ENDED  acd9c8f6 "Run options resume" ended without a hand-back at 13:46Z: relaunch it from its journal, or close its backlog item
Details: python3 ~/.claude/hooks/lane-status.py --session sess-1 --project /Users/x/.claude/projects/-Users-x-app

The other lines have this form, with a fixed text, the state, the id and the cleaned description:

  • FROZEN: <id8> "<description>" waits on <items>, whose process is gone (silent <time>): SendMessage <id> to re-arm it, or TaskStop <id>

  • FROZEN?: <id8> "<description>" waits only on <items> (silent <time>): SendMessage <id> to check it, or TaskStop <id>

  • LEFT: <id8> "<description>" left <n> unnamed live item(s) (<items>) and ended <n> wait(s) (<ids>): end what is yours or take it over (python3 ~/.claude/hooks/lane-status.py)

The Details: command names the session and the transcript directory, so it reads the right session. The class column is 7 characters wide, the length of FROZEN?. An id that is not a safe token appears as #<sha1[:8]> and is never part of a suggested command. An unsafe session id or directory shows as the placeholder <session-id> or <project>, and so does the session in a --report command (--session <session-id> --report <agent id>). When the health notice and the lane notice fire together, the health notice follows the lane reason.

Variable Default Meaning

FT_LANE_HEALTH

on

0 turns the health notice off. The off switch of the nudge (FT_LANE_NUDGE=0) and the checks for a sub-agent and for stop_hook_active apply first.

FT_LANE_HEALTH_GAP_S

300

Seconds between two health passes of one session.

FT_LANE_FROZEN_S

900

Seconds of silence after which an unfinished agent is judged. A value below 60 counts as 60.

FT_LANE_MONITOR_S

3600

Seconds of silence after which an agent with only monitors is FROZEN?.

One persistent set of keys for each session decides what is announced once. The key is <agent id>:<class>:<event time>, and the set records when each key was announced. The pass judges only the agents that the nudge counts as running. It announces every key of such a lane that is not in the set yet, when the pass first judges the lane, however late that is. At most 10 lines print. The keys of the lines that do not print are also marked as announced, and the notice says +N more. A resumed agent that ends again, or a lane that goes from FROZEN to wait and back to FROZEN, gets a new event time and so a new key. It is announced again. The hook removes keys older than 7 days and keeps at most the 500 newest. If the state file is lost, every running lane that is dead now is announced once more. An old state file with fields of an earlier version loads without error, and the next save drops those fields.

If lsof is absent or times out, the writers are unknown. Then a lane with an open job is wait and never FROZEN, and a class that was cached before keeps its class and its time. The pass sets the flag writers_unknown in its state. lane-nudge.py stays silent on such an outage by design, and lane-status.py prints it (see lane-status.py).

A transcript over 8 MB is read in parts. At first sight the pass reads only the last 8 MB, and the lane reads as wait, because a job or a child that started before the tail is invisible. Each later pass scans forward from the start, at most 8 MB per pass, until the scan is complete. Then the lane is judged like a full read. A single line over 8 MB stops the scan, and the lane stays wait. The first agent of the rotation and its direct children always finish a first-sight scan, with the 8 MB tail at most, whatever the clock. The 4-second limit applies between agents. An agent that the pass defers heads the next pass. The state of a child has no cache between calls, so a child that was read from its tail stays wait.

The pass keeps its state in lane-health/<session id>.json in the state directory, with mode 0600: the incremental transcript walk, the announced keys and the cached verdicts. A failed write gives silence. The nudge counts neither UNSEEN nor ENDED agents as running.

Process ownership

ownership-check.py answers one question: what did a sub-agent leave running? It reads the agent’s own transcript and lists the things that the agent started and did not end. It runs on two events, and it routes by the event name. It never blocks the work itself. It fails open: any error allows the call and prints nothing, because a hand-back is the only way that an agent delivers its result. FT_OWNERSHIP=0 turns the whole hook off.

The hook reads structure, not text. A job is a Bash call with run_in_background: true that has a matching tool result. Quoted text inside a tool result never creates an item or ends one. Only the agent’s own lines count.

Kind What it is Live while

job

A background command of the agent.

A process writes to its output file.

monitor

A Monitor task of the agent.

The agent has not ended it. The hook treats an open monitor as live.

worktree

A git worktree add with no later git worktree remove.

The directory exists. A relative path counts only after a cd <abs path> && prefix.

browser

An agent-browser session. The session is --session <s>, an AGENT_BROWSER_SESSION= prefix, or default.

The process in its <s>.pid file runs. close ends it, and close --all ends every session.

detached

A command with nohup, setsid, ssh -f, docker compose …​ up -d or docker run -d, or with a trailing &.

Its process runs: the pid that its launch printed ($!), or a process of the user that started during the launch call and carries the program name, unless the first harness shell above it runs another command or started outside the launch windows. A process with no harness shell above it, a command with no key (under 16 letters and digits, or a secret first) and a loaded or resumed item are still matched by start time and name. A background call’s window lasts until its job ends, and a relaunch of the same command keeps the first launch. A gone or reused pid is settled, and a process of the same name that started outside those windows is never this item. A container or stand is live until docker stop, docker rm or docker compose …​ down names it. A kill, pkill or killall that names an item also ends it.

agent

A child agent that the agent launched.

The child is alive (see The health notice).

The hand-back check

The event is PreToolUse with the matcher SubagentHandback. A call without an agent_id is allowed. The hook lists the live items of the agent. An item is declared when the report names it in a live: line. If at least one live item is undeclared, and the hook did not yet deny this set for this agent, the hook denies:

ownership-check: your hand-back leaves 3 live thing(s) of yours unnamed:
  job bj1 (pid 4312) -> end it: kill 4312 | or name it
  browser sel-cases -> agent-browser --session sel-cases close | or name it
  worktree /abs/path -> git -C /abs/repo worktree remove /abs/path | or name it
End each one, or name it in your report as a line "live: <kind> <id> · <what> · <next step for whoever takes over>"
(delegation-contract.md §10). End a process only by the pid shown, never by its name: other lanes run the same scripts. To wait for a pid, in the background: `e=$((SECONDS+3600)); while kill -0 "$pid" 2>/dev/null && [ $SECONDS -lt $e ]; do sleep 30; done`. Then hand back again.

The other line forms are detached <program> (pid <pid>: <command>) → kill <pid> | or name it, agent <id8> (alive child) → TaskStop <id> | or name it, and <kind> <id> (inherited) → end it, or name it. A detached line never suggests a name pattern, because a lane cannot tell its own process from another lane’s by name: only a $! pid that still carries the program name gets a kill, a pid found by its start time under this call’s harness shell, or with none above it, gets → kill only a pid you know is yours, and an item with no known pid asks for & echo $! next time. The health notice reads no process table, so it lists a detached item as before. The browser session default (no --session, or --session default) is one name that every lane shares, so it never causes a deny, a close command or a LEFT notice: when other items cause a deny, it appears as the note line browser default (shared by every lane) → not yours alone: leave it open, use --session <name> next time. An id that is not a safe token appears as #<sha1[:8]>, and its line has no suggested command. The second hand-back with the same set passes. The deny state is one file for each agent, ownership/<session id>/denied-<agent id>.json. If the hook cannot write that file, it allows the hand-back.

The reviewer floor

The same hand-back check refuses the hand-back of an ft-fix-host that ends without an independent reviewer. The floor is met when the agent’s own transcript holds at least one verifier and one ft-test-adversary dispatch (an Agent or Task tool use with that subagent_type, or its -next variant, whose result is there and is not an error; a background launch counts). A dispatch made by a child, such as the bugfix-agent, does not count, and a reviewer name inside a prompt or a result does not either. Without both dispatches, the report must carry one reviewers: line at a line start in its first or its last 4000 characters (right after the TIER_AB line is simplest; a line cut by the start of the last window does not count), in the grammar of agents/ft-fix-host.md item 8:

  • reviewers: none - <OUTCOME>: <reason>, for a run that ships no code: the outcomes that skip to Stage 5 in /ft-fix, plus the stops. PARTIALLY_CONFIRMED, EXTERNAL_GAP and INTENTIONAL_DIVERGENCE ship a fix, a workaround or a diff with a registry entry, so they are not outcomes here. The first 600 characters of the report must not say "fixed", "ready", "done" or "committed" in any case, or name a commit: a hash of 7 or more hex digits after the word commit and a space, a colon or a backtick. So "not done" and "already fixed" also count as claims. The scan stops at 600 characters, so a Changes: block further down is not read.

  • reviewers: self-check - <verifier|adversary|both> unavailable, with the skill’s prominent self-check line. Each role that the line names needs at least one attempted dispatch (an error result counts), and the role that it does not name must have run. A line that names the verifier needs "self-check only — no independent review"; one that names only the adversary may carry "no independent test-adequacy review" instead. The hook reads that line anywhere in the message, so a pasted deny text, which quotes it, also satisfies it when the dispatch checks hold. This is a declared residual.

A dash can be -, an en dash or an em dash, and the line can be a bullet or bold. The floor checks a declared escape, not the quality of a review. It refuses at most 3 times (keys floor#1 to floor#3 in the deny state); a refusal logs ` floor=1` at the end of its log line, and a hand-back that passes under the floor logs ` floor=open`. A hand-back under the floor whose deny state cannot be written passes and logs ` floor=nostate`. When live items and the floor both fire, the agent gets one deny with both texts. A transcript with no lines of the agent’s own, an unwritable deny state, or an error inside the floor allows. Other agent types are never checked, except ft-developer (below). FT_REVIEWER_FLOOR=0 turns the floor off.

The ft-developer floor

The same check refuses an ft-developer hand-back that claims delivery without a review of its own. The grammar is the Hard-rules item "Reviewer floor" of agents/ft-developer.md; this section holds the mechanics.

  • The claim. READY, DELIVERED or DONE, in upper case and as a whole word, in the first 3 non-blank lines of the report (TIER_AB lines skipped). A word with "not", "no" or "nothing is" up to 40 characters before it, cut at the last period, is no claim. A report whose first line starts with a stop, in upper case and as a whole word (after markdown and a STATUS: or State: key; Split view is no stop) claims nothing and is never refused. A stop phrase, boundary C reached, not yet complete or Stage 6 DONE, silences only the claim words from it on, on its line and the later ones: DONE - X shipped (Stage 9 DONE) still claims, and a first line that opens with boundary C reached claims nothing.

  • The launch head. The exemptions and the journal are read only from the launcher’s lines of the first prompt: the text before Original request:. A slice brief carries no such marker, so with none a line Mode: slice is the head by itself when it is the first non-blank line or follows only the brief openers, in this order and each optional: one line Context: …​ budget <k>KB (the opening line of every brief, delegation-contract.md section 1, which may go on after the budget) and one Bounds: line (the brief templates write it as their second line). The parent writes those lines and no ticket text can precede them; a second opener, another order or any other line before Mode: slice means no head. So Mode: slice may come after Context: only, after Bounds: only, or after Context: then Bounds:. Mode: slice is the whole word: Mode: slice-ish is another mode. Any other prompt without the marker has no head, so it gets no exemption and no journal read. Exempt: a run whose parent is an ft-developer, checked whatever the prompt says: its own .meta.json carries a parentAgentId that is a plain token of letters and digits (the id price-gate _launch_parent reads), and the parent’s agent-<id>.meta.json beside it has agentType ft-developer or ft-developer-next. Both metas are read as regular files of at most 1 MB. A parent of any other type (ft-fix-host, bugfix-agent, general-purpose), an id with a dot or a slash, or a meta that is missing, corrupt, a directory or nested too deep leaves only the head rule. Also exempt: a Mode: slice line, a Group: line with a name other than merge, and a head that starts Resumed from a split with no Group: line (a split seed; the /ft-dev group launch that carries a Group: line is not this). The parent of those runs reviews the merged result.

  • Form A. A verifier or ft-test-adversary dispatch (or its -next variant) or a code-review Skill call of the agent’s own, whose result is there and is not an error. A background launch counts; a child’s dispatch does not. If the agent’s own decide.py --kind grade result says grade: DECIDED architecture-led, a verifier dispatch must also name checkpoint F (checkpoint F or cpF) in its description or the first 600 characters of its prompt, and the deny names "checkpoint F (diff)" and does not offer the journal route below, which never stands in for checkpoint F. Off that grade, a head that starts Resumed from also passes when the journal on its Journal: line holds a Stage 4 or Stage 7 checkpoint block, a cpF-r<n> round, the word adversary or code-review. The journal is read only as a regular *.md file of at most 2 MB under the run directory. A head with no Journal: line, or a journal that cannot be read, fails open and is not logged.

  • Form B. A line reviewers: none - NO_CODE: <reason>, and no git commit, merge, cherry-pick, am, rebase, revert or pull of the agent’s own that ran. The hook splits each Bash command into simple commands and skips the global options of git (-C, -c, --git-dir, --work-tree, --namespace), so cd /wt && git -C /wt commit counts and git merge-base, an echo and a heredoc body do not. A command that ran includes one that exited non-zero; a command a hook denied did not run. A command that does not parse counts as a write. The vault note’s commit, git -C "$FT_VAULT_PATH" commit, counts too: a run that commits a note uses form A or C.

  • Form C. A line reviewers: self-check - <verifier|adversary|both> unavailable, at least one attempted dispatch for each role it names, and a prominent line that covers each named role: "self-check only — no independent review" covers both, "no independent diff verification was performed" covers the verifier, and "no independent test-adequacy review" covers the adversary. A role it does not name need not have run (the lightweight path has no verifier).

The reviewers: line follows the rules of the ft-fix-host floor: a line start, the first or the last 4000 characters, dashes, bullets and bold. The bound, the deny state, the log suffix and FT_REVIEWER_FLOOR=0 are shared.

Declared residuals: the floor checks a declared escape, not the quality of a review; a lone adversary or /code-review meets form A on any grade except a decided architecture-led one; a weak or forged journal passes a resumed run; a resumed, dossier or self-graded architecture-led run is not checked for checkpoint F; a merge launch without Group: merge is exempt when it starts Resumed from a split; a -next dispatch that cannot run satisfies the attempt of form C; a report with a lower-case claim or no claim word is not checked; a delivered diff left uncommitted passes form B, since only the agent’s own git writes are seen and its leaves never commit; a hand-written group or slice prompt with neither the marker nor a Mode: slice first line gets no exemption (with no commit of its own it passes form B); form C naming only the adversary passes an architecture-led run with no checkpoint-F verifier (the cp1 design; the ft-fix-host floor differs); a decide.py --kind grade and a git commit in one Bash command count as the grade only, so that commit is unseen; with no parentAgentId in its meta, a Mode: slice line is honoured with no proof that a parent launched the run; a ticket text that quotes Original request: makes the text before it the head (the same shape as price-gate _launcher_head); an agent that can write files can write its own .meta.json, its parent’s or its transcript and so forge the exemption, the same trust class as the transcript evidence of form A. A git write is not seen through eval, $(…​), backticks, sh -c, command git, env git, sudo, nohup, time, xargs, exec, nice, a variable such as $g commit, or a git alias; the global options --config-env, --attr-source and --super-prefix are not skipped, so a write after one with its value as the next word is unseen; plumbing (commit-tree then update-ref) is not a write it knows. The unchanged Held._git has the same gaps.

The hook declares an item in these cases:

  • The live: line holds the item id as a whole token. Text outside a live: line never declares.

  • A job: the line holds a pid of one of its writers.

  • A detached item: the line holds the program name or a pid that the deny shows.

  • The id is compared without one trailing /.

  • The live: lines come from the message, and from the recovery: field of the last ## HANDOFF of each journal that the agent cites. The hook reads a journal only when it is a regular *.md file of at most 2 MB under ~/.local/state/ft-ai-toolkit/run/. It reads at most 5 journals.

Inherited items come from the newest ## RESUMED block of the journals that the first prompt of a resumed agent cites. Only the outcomes kept and re-armed <new id> are inherited. The outcomes killed and gone are not. An inherited item is live unless the transcript of the successor ended it. It feeds the deny, the declaration check and the record. It is never killed.

The bugfix-agent and refactor-agent floor

The same check refuses a standalone bugfix-agent or refactor-agent hand-back that holds a diff of its own and no reviewer, at most 3 times. It reuses the ft-developer evidence; it adds no second mechanism.

  • A diff. An own git commit, merge, cherry-pick, am, rebase, revert or pull that ran, or an own Edit, Write or NotebookEdit that ran, except a write under the run-journal directory (~/.local/state/ft-ai-toolkit/run/). A diff typed by a delegated leaf is unseen. A hand-back with none of these is never refused.

  • A stop. Only a hand-back led by CONTEXT_RESET whose first 600 characters carry no fix claim (the reviewers: claim words and commit <sha>) is never refused. PARTIAL, BLOCKED, STOPPED and SPLIT may ship code, so they get no exemption.

  • A reviewer. A verifier, ft-test-adversary or /code-review of its own that ran (a background launch counts, a child’s dispatch does not).

  • The escape. The reviewers: line of agents/ft-fix-host.md item 8, in the same grammar: reviewers: none - <OUTCOME>: <reason> for a run that ships no code (a refactor adds NOT_WORTH_IT, BEHAVIOR_CHANGE_REQUIRED, BLOCKED_NO_SAFETY_NET, SCOPE_BREACH), or reviewers: self-check - <verifier|adversary|both> unavailable with the prominent line.

  • Exempt. A brief that carries a line Pipeline: ft-fix anywhere before Original request: (the price-gate.py marker; also after a reset relaunch’s line-start Resumed from a reset. Original brief: ` prefix), read only from the first user message: its host enforces the floor. Residual: a brief with no `Original request: marker is read whole, so a quoted ticket line Pipeline: ft-fix exempts it; that text is the parent’s, never the agent’s, and price-gate.py pairs the marker the same way.

FT_REVIEWER_FLOOR=0 turns it off. The log suffix ` floor=1`, then ` floor=open`, is the same.

The stop event

The event is SubagentStop, for every agent type. It never blocks and prints nothing. The hook treats the stop as final when the agent delivered a successful hand-back (the tool result must read success: true), or when the agent ran in the foreground. A stop that is not final writes no record and kills nothing. A hand-back that reports success: false (a duplicate after new work) is not final. The harness can fire the stop before it writes the hand-back’s own tool result to the transcript. When the last tool use is a hand-back whose result is not there yet, the hook reads the transcript again every 0.1 seconds for at most 2 seconds. If the result has still not arrived, the stop is not final.

At a final stop, the hook ends each live wait job that the report does not name. The kill rule:

  1. The job is an own job, not an inherited one, and is_wait is true for its command.

  2. The process is a writer of the job output. The hook reads the writers with one lsof call that has a 3-second timeout.

  3. The process has the same user id.

  4. The command line of the process contains /shell-snapshots/snapshot-, so it is a shell of the harness.

  5. The process is still a writer when the hook sends the signal.

  6. The hook sends SIGTERM, then SIGTERM to the direct children of that process. It never signals grandchildren and never sends SIGKILL.

FT_OWNERSHIP_KILL=0 turns the kill off and keeps the record. Gates, servers, detached processes, browsers, worktrees and every declared item stay alive and are only listed.

What counts as a wait

is_wait is conservative. When it cannot prove that a command is a wait, the command is not a wait. Six rules apply in this order:

  1. The command is not a wait, with no further parsing, if it holds one of these: (but $ is allowed), <<, a backtick, $', ${(, or a backslash before a newline (a line continuation).

  2. The command is not a wait if the parser cannot close a quote or a substitution, finds no simple command, or reaches a ( or ) outside quotes and outside $(, $, <( and >(. So a subshell ( sleep 5 ), an arithmetic command ((…​, a zsh glob qualifier *(…​) and zsh =(…​) are not waits: the last three can run code.

  3. The parser checks every word for expansions, with the quotes of that word. Outside single quotes, only these are accepted: $NAME and ${NAME} (never followed by [), $?, $$, $#, $@, $*, $<digits>, $#NAME, a literal $, and $…​ when its body holds no substitution, backtick, <(, >( or [. Any other $ form makes the command not a wait, for example $_ (the previous command’s last word), $(, ${!x}, ${x@P} and ${x:-..}. Single quotes are inert.

  4. Every simple command starts with an allowed word: sleep, test, [, [[, true, false, :, echo, printf, date, grep, egrep, tail, head, cat, wc, stat, ls, kill -0, gh pr checks …​ --watch or gh run watch. The words until, while, do, done and ! are allowed as shell syntax. A command with &, a subscript, or -v or -t in test, [ or [[ (zsh evaluates -t’s operand as arithmetic) is not a wait. `printf takes a literal format (no $, brace or glob, not starting with -: printf -v NAME assigns) with only %s, %b, %q and %% (zsh evaluates a numeric argument). test, [ and [[ take no brace, glob, [ or positional parameter in an operand, an operand starting with - is a literal operator (never -$v), and they must not name a variable given a single-quoted value; a [[ that compares numbers (-eq and the like) reads only what a $…​ body may read (rule 5). gh takes no --web/-w, no brace or glob word and no variable but one this command gave digits or $…​. Anything else is not a wait: ssh, a script, mvn, docker, python, curl, gh pr view.

  5. A VAR=value prefix or assignment must be a literal or a single-quoted value that does not start a word with - (it would expand into an option), to a lower-case name that is not a zsh tied array (path, fpath, cdpath, manpath, mailpath, module_path, psvar, argv), or to one of GH_TOKEN, GITHUB_TOKEN, GH_REPO, TZ, LANG, LC_ALL, NO_COLOR. Any other upper-case name is the environment’s and is refused (PATH, IFS, LD_*, GH_BROWSER, GIT_*). A $…​ body may read only a variable this command gave nothing but digits or $…​, or SECONDS, EPOCHSECONDS, RANDOM and LINENO; never a positional parameter. Arithmetic re-evaluates a value, so y=PATH=0 or a PATH from the environment would assign or recurse.

  6. At least one command really waits: sleep, tail -f or tail -F, gh pr checks …​ --watch, or gh run watch.

A heredoc is recognised only on an unquoted << that the parser reaches. Rule 1 makes such a command not a wait anyway.

Consequence: a wait that contains #, a backtick, <<, a line continuation or a subshell is not recognised as a wait. Declare it in the report with a live: wait <id> · <what> · <next step> line. An undeclared command of this kind is listed, and it is never ended.

The record

At a final stop, the hook writes one record for each agent: ownership/<session id>/<agent id>.json, mode 0600, written atomically.

{"ts": 1730745600.0, "agent_id": "a90953db...", "agent_type": "bugfix-agent", "description": "...",
 "final": true, "live": [{"kind": "job", "ident": "b33eu1rrs", "detail": "...", "wait": true, "pids": [4312]}],
 "declared": ["bx0qg9odf"], "killed": [{"ident": "b33eu1rrs", "pids": [4312]}],
 "undeclared_left": ["3f2a9c1b0e"]}

The record has one more field, idents: the real paths of the live worktrees of the agent. janitor.py and the health notice read these records. The log ownership-check.log in the state directory gets one line for each event: <time> <event> <agent id> <agent type> final=<true|false> live=<n> declared=<n> killed=<n> verdict=<allow|deny|record|skip>, and on the hand-back of a floor role under the reviewer floor one more field, floor=<1|open|nostate> (refused, passed after the last refusal, passed because the deny state could not be written). The log rolls to ownership-check.log.1 after 1 MB. If the hook crashes, it still allows the call and prints nothing. It logs one line that ends in verdict=error error=<ClassName>, with the class name only and never the message. The detail field is redacted: it hides the values after --password, --token, --api-key, --passphrase, -u user: and Authorization:, the user information of a URL, sshpass -p, docker login -p, PGPASSWORD=, MYSQL_PWD=, any PASS, TOKEN, SECRET or KEY variable prefix, and the password of sqlplus user/pass@.

Variable Default Meaning

FT_OWNERSHIP

on

0 turns the hook off on both events.

FT_OWNERSHIP_KILL

on

0 turns off the SIGTERM at the stop. The record is still written.

FT_LANE_STATE_DIR

~/.local/state/ft-ai-toolkit

The state directory of the records and the log.

Known limits:

  • The writer check needs lsof. If lsof is absent or times out, the writers are unknown. Then a job with an output counts as live, the hook denies nothing for it, and it kills nothing.

  • The hook ends only waits. A gate, a server, a detached process, a browser or a worktree is listed and left in place.

  • The hook sees only what the transcript shows. A process that the agent started in a way the transcript does not show is not an item.

  • A failed write of the deny state allows the hand-back, so a broken state directory removes the check.

  • A hand-back that names a thing passes, even if nobody takes the thing over later.

The canon for the report is in rules/agents/delegation-contract.md §10 and rules/agents/run-journal.md: the recovery: field lists each live thing as live: <kind> <id> · <what> · <action>, with the kinds job, wait, gate, monitor, worktree, browser, stand, forward, detached and agent, and the actions re-arm, kill, keep (<who watches it>), remove and close. A resumed run settles each live: item first and appends a ## RESUMED <time> block with one line for each, ending in re-armed <new id>, killed, gone or kept.

The test stand convention

A test stand is a set of containers that an agent starts for a test. rules/agents/common.md requires these labels: ft.owner=<agent id or lane>, ft.ttl=<hours> and ft.created=<ISO-8601 UTC>. The compose project is ft-stand-<owner>-<yyyymmddHHMM>. Stop it with docker compose -p <project> down -v. Do not use down or rm without -v, because the orphaned volumes reached about 250 GB. Until the stand is stopped, it is a live: stand <project> item of the agent that started it. The pool part of janitor.py lists an expired stand and never removes it.

Refresh gate

refresh-gate.py avoids an agent run that would republish the same page. It runs on PreToolUse and PostToolUse for Agent and Task. Any other tool passes. It fails open on every path except the two denials below: a bad payload, a cap, a deadline, a git or regex problem, or a corrupt state file allows the call.

A brief opts in with lines that start at the beginning of a line of its prompt:

Line Meaning

Refresh-inputs: <path or glob>, …​

The files that the refresh shows. Commas or spaces separate the items; prose after the paths is dropped, and a line with no readable path lets the dispatch through. git:<abs repo>@<ref> names a commit. Relative paths resolve against the working directory.

Refresh-ignore: <regex>

Lines that match are left out of the fingerprint of an input file. The file must be 5 MB or smaller. An invalid regex allows the call.

Refresh-key: <text>

The name of the refresh. The default is the description in lower case with the digits removed, so page 12 and page 13 are one refresh.

Refresh-max-age: <n>h

An unchanged refresh older than this runs again.

Refresh: force

Run the refresh anyway, and record it.

The PreToolUse event computes a fingerprint: a hash over the sorted path, size and modification time of each input file, or over the content without the ignored lines. The hook walks globs itself. The whole check stops after 2 seconds, and the call is allowed. A git rev-parse has a timeout of 2 seconds. More than 200 files or 50 MB also allow the call, with no record. The fingerprint waits under the tool_use_id of the call.

The PostToolUse event promotes that fingerprint to the record of the key, only when the launch succeeded. It never computes the fingerprint again. A dispatch that price-gate.py denied, or that failed to launch, records nothing.

Two denials exist:

refresh-gate: nothing in Refresh-inputs changed since the refresh at YYYY-MM-DD HH:MMZ (<key>), still inside its Refresh-max-age of Nh; it would republish the same page. Skip it, or add "Refresh: force" when it must run.

If the brief has no Refresh-max-age: line, the text between the key and the semicolon reads , no Refresh-max-age set so it does not expire.

refresh-gate: a refresh brief declares what it shows: add "Refresh-inputs: <files>" (and "Refresh-ignore: <regex>" for lines you write yourself); it is then skipped when none changed. Sent again unchanged, it passes.

The second denial applies only to a status page refresh by its shape: a general-purpose call (or one with no subagent_type) whose description holds the word refresh or republish (the whole word, in any case), whose description or prompt names a publish word or a page, and whose prompt holds no Refresh-inputs: line. A coding, review, ops or doc agent that mentions refresh is never denied; a Refresh-inputs: line opts any agent in to the first denial. It fires once for each key in a session. Sent again unchanged, the call passes.

State: refresh-gate.json in the state directory, mode 0600, written atomically. The hook removes keys older than 30 days and parked fingerprints older than 1 hour. The hook has no environment switch. Known limits:

  • A refresh agent that launches and then fails leaves the record. The next refresh runs only after an input changes, after Refresh: force, or after Refresh-max-age.

  • Two hooks that run at once can lose an update. The hook then fails open.

Brief gates

Three scripts were built to make delegation cheap without removing a reviewer: delegation-gate.py, evidence-store.py and diff-router.py. Only diff-router.py runs today. Each has a boundary document that states what it enforces and what it cannot do. The shared contract is rules/agents/delegation-contract.md. It is installed as ~/.claude/rules/agents/delegation-contract.md.

Contract rule In short

Brief

A brief is an evidence pack: a goal, references (paths, not contents) and a declared budget. It never carries the parent transcript. The first line is Context: <n> refs · <m> inline lines · budget <k>KB.

Definition of done

Measurable: an artifact at a path, a command with its outcome, or a file:line. The receiver echoes each item with its evidence.

Write scope

The brief’s file list is the write boundary. A needed edit outside it stops the work and returns SCOPE_BREACH.

Four bounds

Rounds, agent-runs, turns and wall-clock minutes. They are declared before the work. A receiver at a bound stops and returns what is proven.

## HANDOFF

Any stop that is not a completed run writes a ## HANDOFF block to the run journal: state, proven, open, resume, recovery.

The overriding rule: economy never removes the last independent reviewer. The mandatory core of rules/agents/verification-routing.md section 1 is emitted unconditionally for each checkpoint. The core is Correctness, Security and API-contract, or Requirements-coverage, Security and API-contract at checkpoint D. diff-router.py plan --drop-lens on a core lens exits 2. No gate rule denies a core-lens dispatch.

The one named exception is the port-lane profile. It keeps Correctness, and it never removes the last independent reviewer.

Script and policy What it does What you see What it cannot do Installed

delegation-gate.py + brief-schema.json. Boundary: deploy/evals/delegation-gate.md.

Not installed. Registered by hand, it is a PreToolUse gate on Agent|Task. It reads the brief before the dispatch. It denies a brief with no Context:, DoD: or Bounds: line (R1), no budget <k>KB (R2), an inline payload over budget (R3), a pasted transcript (R4), no artifact reference (R5), a repeat dispatch over an unchanged tree with no declared delta (R6), or an implementer with no writes: set (R7). R8 denies two parallel dispatches whose writes: sets overlap. R9 and R10 check a cited route.

Nothing today. Registered by hand: one deny message that lists every violation. A repeat review with a recorded verdict is answered in the deny text, and the dispatch is not paid for. python3 ~/.claude/hooks/delegation-gate.py --audit 20 shows the last decisions.

It judges structure, not content. It does not check that a receiver honored the writes: set, the bounds or the ## HANDOFF rule. --override "<reason>" is recorded but not authenticated. R8 has a residual race.

c. Not installed, by the owner’s ruling of 2026-11-03: the installers neither copy nor register it. deploy/evals/delegation-gate.md states why: as shipped it denies about half of real dispatches. To use it anyway, copy delegation-gate.py and brief-schema.json to ~/.claude/hooks/. Then add a PreToolUse entry with matcher Agent|Task and command python3 ~/.claude/hooks/delegation-gate.py, in the form of the settings example below.

evidence-store.py + evidence-schema.json. Boundary: deploy/evals/evidence-store.md.

Stores immutable evidence packs (addressed by hash) and review verdicts (addressed by a key over contracts, diff, task, lens, role, pack and test state). Replays a verdict only for an identical key.

No replay today: only the deny text of delegation-gate.py carries a replayed verdict, and that gate is not installed. evidence-store.py cache-decision exits 0 when it resolved from cache and 1 when the lens must run.

It cannot record a verdict by itself, and no pipeline calls its verdict record today, so the cache stays empty until someone runs the command. It never replays a failed, partial or non-independent verdict. It does not see a change of model or tool. Outside a git tree the cache is off.

b. Both installers copy it, with no caller. deploy/evals/evidence-store.md states why the cache stays off. FT_EVIDENCE_CACHE=off turns off replay only.

diff-router.py + route-schema.json. Boundary: deploy/evals/diff-router.md.

diff-router.py plan --checkpoint <c> classifies the changed files and chooses the lenses. It writes a route manifest to ~/.local/state/ft-ai-toolkit/routes/. The pipelines cite it as route:<hash>.

A lens list with a cited reason for each lens and for each skipped lens. Exit 1: a conservative default fired every routed lens. Exit 2: a refused override. Exit 3: no diff to route.

It cannot make a lens run. It matches paths and diff lines, not meaning. The caller supplies --sdd-surface, --ledger-sound and similar flags. Its check command tests that a cited route exists and is fresh, and no hook runs that test today. Nothing checks that the orchestrator obeyed the route.

b. Both installers copy it. settings.json allows diff-router.py plan without a prompt.

By the owner’s ruling of 2026-11-03, the installers (economy.py, install.sh and install.ps1) do not copy delegation-gate.py, do not copy brief-schema.json and do not register the hook. The evidence replay path lives inside this gate. The pipelines still call diff-router.py. No pipeline calls evidence-store.py. Nothing replays a verdict or checks a brief.

The port-lane profile

The port-lane profile is the one named, scoped exception to the mandatory core. The owner ruled on 2026-11-29 that this lighter review is accepted for ft-acs-qa port lanes. It is not a general relaxation. The canon is the paragraph "The one named exception" in rules/agents/verification-routing.md section 1. The router behavior is in deploy/evals/diff-router.md section 7. The review rules are on Quality Pipelines Reference, The port-lane profile.

Commands. The orchestrator runs these commands. Each one needs the lane journal.

Command Effect

diff-router.py profile port-lane --repo <repo> --journal <journal> --grade simple-addition --user-visible no

Stage 1. It prints one profile: port-lane line and stores nothing. The orchestrator copies the line into the Stage 1 section of the journal.

diff-router.py plan --checkpoint feature-F --round 1 --profile port-lane …​

Stage 7, round 1. It selects Correctness, Security when it fires, and the first test-adversary pass.

diff-router.py plan --checkpoint feature-F --round 1 --profile port-lane …​ --post-fix <manifest>

Stage 7, after the one fix batch. It compares the final diff with the manifest that the orchestrator emitted after round 1.

Exit codes. Exit code 4 is new. profile and plan exit with 4 when the router refuses the profile. The output lists every failed token, for example branch-not-port or grade-not-simple-addition. A refused plan routes as it does without --profile and adds the line PROFILE REFUSED <tokens>. --post-fix also exits with 4 for a manifest that does not belong to the run. With --post-fix, exit code 3 means no diff. Treat exit code 3 as a finding, never as "nothing new to review". For exit codes 0 to 2, see the table above.

Observed and self-asserted facts. The router checks the origin, the branch, the degraded observation and the launcher marker itself. The grade, the user-visible flag, the round, the checkpoint and the journal are values that the caller states. The router checks them against the journal where a check exists. It does not prove them.

Budget. price-gate.py raises the run-cost budget from 6 to 12 agent-runs. It does this only when all four predicates hold:

  1. The launcher marker Profile: port-lane is recorded on the lineage root.

  2. The first Stage 1 section of the journal names the grade simple-addition.

  3. The last profile: port-lane line of that section is accepted.

  4. No regrade: line stands in the journal.

If one predicate fails, the grade table applies. budget_source names the failed predicate.

Post-fix check. --post-fix takes its baseline from the manifest file that the orchestrator emitted after round 1, not from the route store. It spawns Security for each new citation: a new secret-read or security-class line, a removed security-class line, or an edit of a security-path file. It spawns Security also when a round-1 citation is gone from the final diff (a security-class line added in round 1 and removed by the fix batch). It spawns Correctness for each new, renamed or deleted file. If nothing is new, it prints post-fix: nothing new to review and exits with 0.

Residual. Lines that the fix batch changes inside an already-reviewed file, without a new citation, get no independent re-read. The egress of an already-read secret is outside the Security trigger.

What the profile cannot enforce.

  • It cannot compel an orchestrator that never calls the router.

  • It cannot detect an --emit file that someone edited and hashed again. The self-hash catches accidents only.

  • It cannot prove the values that the caller states.

Failure mode. The router reads the lineage marker through price-gate.py. A host installed with SKIP_ECONOMY=1 has no price-gate.py. A host that cannot read the marker refuses every profile. The refusal fails closed to the full mandatory core.

Command-line scripts

Five scripts are commands. The main loop and the agents run them through Bash, and you can run them yourself. artifact-registry.py is also registered as a hook. The installer copies the five to ~/.claude/hooks/, and main-rules.md names them to the main loop. Each has --selftest, which runs offline on temporary files.

Command What it replaces Exit codes

lane-status.py

The question "where are the lanes", asked by hand

0 ok; 2 no session or unusable argument; 3 --report found no hand-back

janitor.py

The manual cleanup of merged worktrees, orphaned processes and dead waits. Dry run by default.

0 ok or nothing to clean; 2 bad arguments; 3 a command failed

vault-note.py

The manual steps to write a vault note

0 ok or unchanged; 1 internal error; 2 refused; 3 conflict; 4 git failure; 5 lock; 130 interrupted

artifact-registry.py

Finding the arguments of an old Artifact call

0 ok; 2 no match, several matches, bad arguments or an unreadable registry; 3 local file missing

session-audit.py

The one-off scans of the transcripts

0 ok or no transcripts; 2 bad date

lane-status.py

python3 ~/.claude/hooks/lane-status.py [--session ID] [--project DIR|NAME] [--all] [--report AGENT_ID]

The command prints the running sub-agents of one session, oldest action first. Without options it reads the newest session of the current project under ~/.claude/projects. --project takes the directory name or a path. Write a name that starts with a dash as --project=-Users-x. The command is read-only and uses no network. If it finds no session, it names the directory that it searched and exits with 2. The message also names the next action: run the command from the project directory, or pass --project. A --session id that matches no file is named in the message, with the advice to drop --session or pass --project. --help describes every flag.

The command continues the saved walk of the health branch (lane-health/<session id>.json) and never writes it. It reads at most the last 128 MB of the transcript past that point. When it has to skip a part, it prints a partial: line: agents launched in the skipped part are missing, and agents that ended in it can still be counted. It looks for the stops of children in the last 64 MB of the main transcript. A child stopped before that can show as running, until it is silent for longer than the limit.

session b66ef1dc  status line: none since your last message  counted by the nudge: 2 running, 1 silent over 3h (--all)
AGE    CTX   TYPE                     LAST             DESCRIPTION
1m     180K  ft-developer             -                Resume part B at checkpoint F
1m     44K     verifier               Bash             cpF lens Test-plan adequacy executor round 1
Field Meaning

Header, status line

The newest status line after your last message and its age, or none since your last message.

Header, counted by the nudge

The number that lane-nudge.py counts, from the same code: running agents, then the agents silent over the limit. The limit is FT_LANE_STALE_S (default 3 hours) and the header prints it. The table hides the silent agents and their children in one footer line, <N> silent over <limit> hidden (children included). --all lists them.

AGE

Time since the last line of the agent’s own transcript, in seconds, minutes or hours. The file time replaces it when that line has no time. No claim of the agent counts. A row can show 4h while the nudge still counts the agent, because the nudge goes by the file time.

CTX

Tokens of context in the agent’s last turn.

TYPE

The agent type. Children of a running agent are indented under it. The nudge does not count children, and the footer gives the row count with children.

LAST

The last tool that the agent called.

The table has a STATE column between LAST and DESCRIPTION. It shows the verdict of the health check of ownership-check.py for each top-level agent, without the 4-second limit of the nudge. The verdicts are the same as in The health notice.

STATE Meaning

run

The agent works.

wait

The agent is stopped, but a job or a child of it is alive.

UNSEEN

The agent handed back, and the report never reached this session.

ENDED

The agent ended without a hand-back.

FROZEN

The agent waits on a job that no process holds.

FROZEN?

The agent waits only on monitors and was silent for FT_LANE_MONITOR_S seconds or more.

When the health check is unavailable, the column shows ? and a line says so. When lsof gave no answer in this pass, a lane with an open job shows wait, and the line health: lsof unavailable, FROZEN not judged appears above the attention: lines. Under the table, one attention: line for each row that is not run or wait gives the same action text as the notice. A line left by finished agents: <n> item(s) counts the live items that finished agents left. UNSEEN and ENDED agents are not counted by the nudge, so the number in the header stays the number of the nudge.

python3 ~/.claude/hooks/lane-status.py --session <session id> --report <agent id>

--report prints the report of an agent that never reached you. It needs --session. The notice prints both. The id is a full agent id or a unique prefix of 4 to 128 letters, digits, - or _. An ambiguous prefix exits with 2. The command reads only <project>/<session>/subagents/agent-<id>.jsonl under ~/.claude/projects. It prints the message input of the last SubagentHandback that succeeded, indented, redacted and capped at 20 KB, as data. If the agent made no successful hand-back, it exits with 3 and prints one line. Exit codes of the command: 0 ok; 2 no session or an unusable argument; 3 --report found no hand-back.

janitor.py

python3 ~/.claude/hooks/janitor.py [--apply] [--root DIR]... [--min-age-h 12] [--only worktrees|processes|waits|runlogs] [--min-age-days 7] [--min-size-mb 10] [--json]
python3 ~/.claude/hooks/janitor.py --pool [--host H]... [--apply]
python3 ~/.claude/hooks/janitor.py --selftest

The command finds what finished lanes left behind: merged worktrees, orphaned processes, dead waits and old bulky logs. It is a command, not a hook. The installer copies it to ~/.claude/hooks/ and registers nothing for it. It changes nothing without --apply. Without --apply, each candidate prints as <class> <target> · <why it is ours and idle> · <command>, with the command quoted for a shell. With --apply, it runs the argument lists itself, never through a shell and never with a forcing flag. It prints removed|ended|skipped <target>: <reason> for each candidate and then the counts. ended means that the command sent SIGTERM. The summary line adds , failed N (exit 3) when N commands failed.

Exit codes: 0 ok (also janitor: nothing to clean), 2 bad arguments, 3 a command failed while the others ran. --pool with --only or --root exits with 2. A root equal to $HOME or / exits with 2. A name taken from the file system must match ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, or the command skips it.

Laptop mode is the default. It has four classes. The roots are the immediate children of each --root, else FT_JANITOR_ROOTS, else ~/Projects.

Class What the command removes or lists

Worktrees

A linked worktree when every condition holds. The worktree exists, is not locked and is not prunable. It was untouched for --min-age-h hours (default 12): HEAD, index, logs/HEAD and the root. No process has its working directory inside it (one lsof call). No ownership record of the last 24 hours and no run journal changed within --min-age-h names it. Its HEAD is an ancestor of origin/HEAD, else origin/main, else origin/master. It is clean: nothing tracked is modified, nothing is untracked, and every ignored path is under target/, node_modules/, build/, dist/, .angular/, pycache/, .pytest_cache/, .gradle/ or out/. The command runs git worktree remove <path>, never with --force, and then git worktree prune.

Processes

Only processes of your user that are older than 1 hour. selftest: a parentless --selftest run of a hook or of rig-ui-selftest (the pattern is FT_JANITOR_SELFTEST_RE) gets SIGTERM. chrome: the Chrome for Testing of agent-browser under ~/.agent-browser/browsers/ with no daemon (parent process 1) gets SIGTERM, with its crash handler. browser: an agent-browser daemon is only listed, with its close command; a daemon with no session pid file is listed with no kill or close hint, because nothing proves it is yours; for the session default, which every lane shares, it lists a note instead (close it only after checking that no lane is using a browser, for example with lane-status.py). rig-jvm: a surefire or failsafe fork whose mvn is gone (parent process 1) gets SIGTERM. A fork is a process whose command line has ForkedBooter, a surefirebooter*.jar or an @…/surefireargs* file; the default fork of surefire and failsafe 3.x shows only the jar. rig-container: a container whose name contains ryuk, oracle-free or testcontainers is only listed, with docker stop <name>, and only while no fork and no Maven verify, integration-test or failsafe:…verify run of any user is alive. An orphaned fork counts as alive, because its containers go away when it ends. The command reads the names with one docker ps call; if docker is missing or fails, it prints a skipped line and still exits with 0. wait: a harness job shell that waits and whose job is over gets SIGTERM, then its direct children. job: any other parentless harness job shell is only listed.

Run logs

Bulky machine output in the run directory, $FT_LANE_STATE_DIR/run (default ~/.local/state/ft-ai-toolkit/run). A candidate is a regular file named .log, .out or .txt (the suffixes that gate, reactor and flake-loop runs write; journals .md and state .json are never in the set) that is older than --min-age-days (default 7), at least --min-size-mb (default 10) MB, not open by any process (one lsof per 100 files; a failed lsof keeps every file and exits with 3), not named HANDOFF, and not under a directory that holds a *.md journal changed within the same number of days. A log directly in the run directory is kept only when a fresh journal there names it (its file name in the text, or the journal’s name as its prefix), because every lane’s journal sits in that directory. Symlinks, other file types and anything outside the run directory are never candidates, and a symlinked subdirectory is not entered. A run directory that is itself a symlink (moved to another volume) is resolved once and used when its target is an existing directory owned by the current user that is neither the home directory nor an ancestor of it; otherwise the class is skipped with a line naming the target. Candidates then print their resolved paths. --apply unlinks each file in Python, never through a shell and never with rm -r, and then removes the directories that this left empty, but never the run directory. Each candidate prints with its size, followed by janitor: runlogs total N files, SIZE. The class also runs when --only is not given.

Lane state

With --apply, the command removes ownership/<session>/ and lane-health/<session>.json older than 7 days. A dry run lists them. If ownership/ or lane-health/ is a symlink, the command skips it and prints <name> is a symlink; left alone.

The local Stop hook ~/.claude/scripts/detect-stuck-rig-procs.sh, which is not in this repository, still runs until the FLOW24 trial ends. It kills a parentless process with ForkedBooter in its command line with kill -9 on every turn and warns about the same containers. rig-jvm and rig-container cover the same cases in this manual command, with SIGTERM on a fork older than 1 hour.

A wait is over in one of three cases: (a) the consumer is gone (parent process 1), (b) the agent that started it is settled, or (c) the target finished. Case (b) does not apply to a wait that its agent declared in an ownership record of the last 24 hours. The line then reads declared kept by its agent (ownership record). Cases (a) and (c) still end a declared wait, by design: they are facts (no reader is left, or nothing is left to wait for), while a declaration only overrides the guess that case (b) makes about ownership. Case (b) holds when the transcript that structurally started the job shows a delivered hand-back (success: true), or the agent state is stopped. The command judges the agent with the writer table of its own lsof call. In case (c), the target finished: gh pr checks <n> on a merged or closed pull request, gh run watch <id> on a completed run, or a kill -0 loop on a literal pid that no longer exists. The target check accepts only literal digits and a -R owner/repo that matches ^/[A-Za-z0-9._-]$. A GH_REPO= or GH_HOST= prefix, or a missing literal, makes the shell list-only. If no case applies, the command keeps the shell and prints harness wait of task <id> kept: consumer live (ppid <n>), no delivered hand-back of its agent found, <target reason>. If the lsof call failed, the state of the agent is unknown. The command keeps the shell, replaces that part with whether its agent <id> finished is unknown (lsof of its job outputs failed), marks the item as failed, and exits with 3. The gh calls share a budget of 30 seconds. Before each signal, the command reads the process again and skips it when the start time or the command line changed.

Pool mode (--pool) is local only. It needs ~/.claude/mvn-slot.sh, which this repository does not ship. Without that file, the command prints janitor: pool mode needs ~/.claude/mvn-slot.sh (local-only, not shipped by this repo); skipped and exits with 0. The hosts come from --host or FT_JANITOR_POOL_HOSTS. The command never reads the hosts file. For each host, it runs one mvn-slot.sh call with an embedded POSIX shell payload. The payload refuses to run unless the user is mvnslot and /var/lib/mvn-slot exists.

Target on the host Action

Dangling volumes older than 1 day

docker volume rm <name>

Unused images older than 7 days

docker image prune -a -f --filter until=168h

ws-sandbox-* directories

Removed only when the newest file in the tree is older than 3 days and no process of the user has its working directory or an open file there. Otherwise listed.

/var/lib/mvn-slot/work/* older than 2 days

Listed only. mvn-slot evicts them itself.

Test stands (containers with the label ft.owner) whose ft.created plus ft.ttl hours has passed

Listed only, with docker compose -p <project> down -v. See The test stand convention.

Make the first pool run a dry run on one host: janitor.py --pool --host <h>. Read the list before you add --apply. Never run it on a host unattended. A host that fails or refuses is reported with the last line of mvn-slot and is not retried. The payload uses GNU find and /proc, so it is Linux only.

On Windows (os.name is nt), the command prints janitor: process and pool classes are POSIX-only; worktrees only and runs only the worktree class. lsof is absent there, and a failed lsof call keeps every worktree (the check fails closed), so the command keeps every worktree on Windows.

FT_JANITOR_ROOTS, FT_JANITOR_POOL_HOSTS and FT_JANITOR_SELFTEST_RE are the only environment settings for users. The names JANITOR_TMP, JANITOR_WORK and JANITOR_EXPECT_USER exist for tests and work only with JANITOR_SELFTEST=1.

vault-note.py

python3 ~/.claude/hooks/vault-note.py --repo <slug> --type bugfix|decision|feature --key <JIRA-or-slug> \
  --title "<title>" --body-file <path|-> [--severity minor|major|critical] [--update] \
  [--hub <slug>] [--create-hub] [--jira K] [--area A] [--summary "<hub text>"] [--vault P] [--dry-run]

The command writes one note into the team vault, adds its entry to the hub note, commits the two files and pushes. The note contract is in skills/obsidian-knowledge-vault/SKILL.md. The vault is the --vault path, else $FT_VAULT_PATH. The path must hold AI/_Index.md and a .git directory. If neither is set, the command exits with 2 and names deploy/scripts/install.sh --doctor. Until the vault works, print the note in your report.

You supply the body: the sections of the note, in English. The command writes the frontmatter, the title line and the Hub line. --help prints the header of the script: the flags, the exit codes and the named residuals of this page.

Type New note path Required sections

bugfix

AI/Bugfixes/<repo> - <key>.md. --severity is required.

Symptom, Root cause, Fix, Notes (or Notes / follow-ups)

decision, feature

AI/Decisions/<repo> - <key>.md

Context, Decision, Alternatives, Consequences

How the command decides, in order:

  1. It refuses a bad argument, a body with text before the first ## ` heading, a missing section, Cyrillic text and a secret pattern. A refusal writes nothing, leaves `git status of the vault clean and exits with 2. A refused note is reworded, never written by hand.

  2. It takes .git/vault-note.lock. It waits up to 60 seconds, breaks a lock older than 300 seconds, and exits with 5 when it gets none.

  3. It runs git pull --rebase before it writes anything. A conflict is aborted with git rebase --abort, and the command exits with 3. Another writer’s uncommitted edit also exits with 3. After exit 3, nothing is written: clear the conflict or ask the other writer to commit, then run the command again. A failure such as no network exits with 4.

  4. It looks for an existing note with the same repo and key, in AI/Bugfixes, AI/Decisions and AI/. The lookup ignores case: the key dev-2841 finds DEV-2841 and DEV-2841-some-slug. Two notes whose names differ only by case exit with 2. A path that exists but is not a note (a directory, a broken link) exits with 2. A note exists and --update is missing: exit 2, so you read the note and merge first. --update replaces every section from the first `## ` heading on and keeps the head of the note.

  5. It adds - [[<note>|<summary>]] to the hub note of the repo, or of --hub. A missing hub note exits with 2 unless you pass --create-hub, so a mistyped slug creates no stray hub. The Hub line of the note and the hub entry name the same hub. With --update, the hub is --hub, else the hub that the up: line of the note names when that hub exists, else the hub of the repo. An up: line that names a note which is not a hub exits with 2.

  6. It commits only the note and the hub, then pushes. A rejected push is retried once after a new pull. Every git call has a timeout of 120 seconds, and the whole run stops after 240 seconds.

An interrupt (Ctrl-C, SIGTERM or SIGHUP) aborts an open rebase and exits with 130. If the push was cut off, the message says that the commit may have reached the remote. A later --update on an unchanged note still pushes a local commit that an earlier run could not push. The line then says pushed existing local commit <sha>. A rerun without --update after such an unpushed commit says that the note already holds this run’s body and sits in a local commit that was never pushed. It says so only when three conditions hold:

  • Every unpushed commit that touches the note carries the commit subject of this tool (<type>(<repo>): <key> …​, case ignored).

  • The note is clean.

  • The note on disk equals what --update with this body would write (case ignored).

The message then tells you to rerun with --update and the same body, or to run git push in the vault clone. The --update rerun rewrites no note text. It pushes every local commit that the clone has ahead of the remote, not only the commit of this note. In every other case it gives the plain note exists advice.

A stop after the write says what it left in the vault clone. If the commit failed, the message lists the files that are written but not committed and gives the commands: git add, git commit and a push command. The push command is git push. If the branch has no upstream, it is the command that gives the branch one (see below). The message tells you to run these commands first and only then to run the tool again, because the tool refuses while those files are left in the vault. The exit 3 message offers git restore for an edit that is not yours. If the commit worked and the push failed, the message names the local commit and says to run git push. If the branch of the vault clone has no upstream, the message gives git branch --set-upstream-to=<remote>/<branch>. It picks the remote in this order: the branch remote configuration, origin, the only remote, the push remote of the branch, else the placeholder <remote>. A remote is ignored when its name does not look like a remote name, for example a URL, a value with @ or a value that starts with -. This holds for configured remotes and for the names that git remote lists. The only-remote choice still counts the raw list, so one valid remote is not chosen when an invalid one sits beside it. If the remote answers that it does not have the branch (an exact match of refs/heads/<branch>), the message gives git push -u <remote> <branch>. If the remote cannot be asked, the message never gives git push -u. A vault file that the command cannot read or write exits with 4.

Exit 1 is an internal error, a bug of the script. The message names the exception class and never the content. Nothing is pushed unless the output already held a commit line. Check git status in the vault clone.

On success the command prints one line: vault-note: <created|updated> <path> commit <sha> pushed. It adds hub created, head kept N lines (stale text in the head stays visible), the scan state and, when a checkpoint note for the same key exists, still owed: fold and delete <checkpoint note>. The command never folds or deletes a checkpoint note. --dry-run prints the note and the hub line and touches nothing. The command removes control and format characters from every line it prints, on success, in the --dry-run preview and in error messages. Each such character shows as ?, and a tab shows as four spaces.

The secret scan covers every text value. It refuses key shapes (API keys, tokens, private keys), assignments such as password: x, commands that carry a password and connection strings with a password. The message names the line and the class and never repeats the value. There is no override.

A pattern cannot tell a pair of ordinary words from a user name and password. For that case, create the file ~/.config/ft-ai-toolkit/vault-secret-values with mode 0600. Write one secret per line. Never write an ordinary word: the scan matches a value anywhere in the text, so a plain word would refuse many notes. The command skips blank lines and never prints a value. The file may start with a byte order mark (BOM, the UTF-8 signature that Notepad and PowerShell 5.1 write): the command reads the file as utf-8-sig, so the mark does not stick to the first value. If other users can read the file, the success line says to run chmod 600 on it. If the file is absent, the success line and --dry-run say secret scan: shapes only, no values file. The command works without the file, but it then cannot catch such a pair. Credentials do not belong in CLAUDE.md or in a vault note.

Named residuals of the script:

  • The scan judges shapes. A flag form such as --password <value> and a bare <user>:<password>@host pass. Add the value to the values file.

  • A rerun can call a note "already holds this run’s body" after a clean rebase under a teammate’s edit to a part that the body keeps. The advice stays true, because --update then changes nothing but the push.

  • The command breaks a stale lock with a check and a delete. That is not atomic, and the window is a few microseconds.

  • --update --dry-run prints the existing head of the note without a scan. The H1 line that the command copies into the hub entry and the commit subject, when you pass no --title, is not scanned either.

artifact-registry.py

The script has two roles. As a PostToolUse hook on the Artifact tool, it records each published link. As a command, it prints what a new Artifact call needs.

python3 ~/.claude/hooks/artifact-registry.py list
python3 ~/.claude/hooks/artifact-registry.py show <title|url|file>
python3 ~/.claude/hooks/artifact-registry.py backfill [--days N] [--root DIR]
Mode What it does

Hook (no arguments, input from a pipe)

Appends one JSON line to ~/.local/state/ft-ai-toolkit/artifacts.jsonl (override: FT_ARTIFACT_REGISTRY). It records a call only when the action is publish or absent, the call is not an asset and the response holds a link. The link must start with https://claude.ai/artifact/ or https://claude.ai/code/artifact/. A structured url must match in full. From text, the hook takes the first such address and drops trailing .,;). A link that holds a control character (0x00 to 0x1f or 0x7f to 0x9f) is not recorded, on the structured path and on the text path. It prints nothing and fails open. The file holds share links, so the script creates it with mode 0600.

list

One row for each link, newest first: age, title, file state (ok, changed or MISSING) and link.

show

Prints the arguments of one Artifact call as JSON (file_path, url, and root or files when used). It warns file changed since publish, because a reused file name would overwrite a shared link. Several matches: it lists them and exits with 2. No match: exit 2. File missing: exit 3.

backfill

Reads the publishes of the last 30 days (--days N) from the transcripts under --root DIR (default ~/.claude/projects) and records the ones that the hook did not see. It reads the structured tool result of a user line only, and it ignores a repeat of the result in a request dump. A publish with no structured result records nothing. It is idempotent. One run takes 1 to 2 minutes over 27 GB. Run it once after the install, in the background.

Limits:

  • The script records and prints. It cannot call Artifact.

  • After an account switch an old link returns 404. That link belongs to the other account, and the tool refuses a republish that passes its url. Drop the url and publish: the link changes. Whoever holds the old link must get the new one.

  • The script cannot restore a local file that a reboot removed from /private/tmp.

  • Unverified: the hook reads tool_response as a dictionary with a url, or as text. No live PostToolUse payload was captured. The first publish after the install confirms the shape. backfill does not depend on it: it reads the structured tool result in the transcripts.

session-audit.py

python3 ~/.claude/hooks/session-audit.py [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--project TEXT] [--top N] [--json] [--jobs N]

The command reads the transcripts under ~/.claude/projects and reports where the tokens and the turns went. The default window is the last 3 days (UTC). --project filters the project directories by a substring. The command skips the scratchpad probe projects unless --project names them. It is read-only, offline and needs only Python. A bad date exits with 2. A window with no transcripts prints one line that names the project filter and the dates, with the advice to widen --from and --to or drop --project. With --json, that line is a JSON object. An unreadable transcript is named on stderr and skipped.

Costs are the notional list price of deploy/evals/spend-report.py: opus 5 and 25, sonnet 2 and 10, haiku 1 and 5 dollars per million input and output tokens, cache read at 0.1x and cache write at 1.25x. One assistant message counts once, even when it spans several transcript lines.

session-audit 2026-10-31..2026-11-02 UTC project=all files=4493 (notional list price)
cost $N: read $N, write $N, output $N, input $N
main $N (runs N, turns N) | sub-agents $N (runs N, turns N)
top agents: $ turns peak-context-tokens type description
by type: type runs $ median-$ median-peak-context-tokens
mechanical errors: N turns (exit and other not counted): <class> N, ...
waits: N turns, $N (bash sleep/until/watch, Monitor)
vault work: N turns, $N (from the first vault write ... the messages touching the vault themselves: N turns, $N)
owner asks (regex, approximate): lanes N, status or stuck N, republish N
  • Mechanical errors are failed tool results. The classes are hook-deny, perm-denied, edit-miss, file-missing, too-large, timeout, exit, cancel, other and sleep-blocked, the refusal of a bare sleep.

  • Waits are messages that run a Bash sleep, until or watch loop, or call Monitor.

  • Vault work has two figures on one line. The first is a window: it runs from the first message that writes to the vault or runs git on $FT_VAULT_PATH to the end of that agent. It includes every later turn of that agent, so it is the upper bound. The second figure counts only the messages that touch the vault themselves. The two figures differ on purpose, and the report keeps both. The manual audit of 31 October to 2 November found about $336 with its own scan. The script gave $1868 for the window and $408 for the touching messages on 4884 files (run journal, not re-run for this page).

  • Owner asks count your own messages that match a pattern. The count is approximate.

The text report prints agent descriptions with control characters removed. --json prints counts, classes and numbers, and never a description or any raw text, because transcripts hold credentials.

State and logs

File under ~/.local/state/ft-ai-toolkit/ Written by, and what for

tier-ab.jsonl (FT_TIER_AB_LOG)

price-gate.py: every swap and A/B arm, with the dispatch’s description and tool-use id. It is the source of every A/B count on this page.

decisions.jsonl (FT_DECIDE_LOG)

decide.py: every Jev question and answer.

turn-guard.log

turn-guard.py: every orchestrator turn end it saw, allowed or blocked.

lane-ended.json (FT_LANE_ENDED_STATE)

turn-guard.py: the time a top-level lane ended for good. price-gate.py reads it to remind the main loop to refill its lanes.

main-ctx.json, bugfix-note.json

The notes' "already said" state (FT_MAIN_CTX_STATE, FT_BUGFIX_NOTE_STATE).

leaf-note.json (FT_LEAF_NOTE_STATE, else FT_LANE_STATE_DIR)

checkout-guard.py: the context and the time of the context note for each coding leaf, keyed by agent id. It removes entries older than 7 days.

lineage.json, lineage.json.lock (FT_LINEAGE_STATE)

price-gate.py, the only writer: the lineages of split and reset runs, with their instances, bound agent ids, agent-run counts, recorded raises, cpf2 (the journals that dispatched a checkpoint-F round 2), delta (the granted delta fix) and trivial (the trivial fix of each journal). It writes under the lock to a temporary file and replaces the old file in one step. It never overwrites a file that it cannot parse, and it removes entries that nobody touched for 7 days. It fails open: an unreadable file means no count and no denial. The trivial and delta reads of cpf2, delta and trivial fail closed to FIX_LANE. See Dispatch Economy Reference, Lineage bounds.

boundary-hold.json, boundary-hold.json.lock (FT_BOUNDARY_HOLD_STATE)

price-gate.py: for each agent id, the time of its last hold (ts), its hold events (each with ts, ctx and epoch) and the dispatches it held (held: the subagent_type and description of each). It does not store the move; the hook reads the move again from the journal. It writes under the lock to a temporary file and replaces the old file in one step. It never overwrites a file that it cannot parse, and it removes entries that nobody touched for 7 days. It fails open: a file that is unparsable or is not a JSON object means no hold until someone removes the file, and nothing is logged. See Dispatch Economy Reference, price-gate.

lane-nudge.json (FT_LANE_STATE_DIR), lane-nudge-off

lane-nudge.py: the time of the last nudge and the active hold for each session. The file lane-nudge-off turns the hook off.

lane-nudge-block.json (FT_LANE_STATE_DIR)

lane-nudge.py: the session id and the time of the last block, written before the block is printed. main-compact.py reads it and types nothing for 60 seconds.

lane-health/<session id>.json (FT_LANE_STATE_DIR)

lane-nudge.py: the transcript walk, the announced keys and the verdicts of the health notice, mode 0600. janitor.py --apply removes files older than 7 days.

ownership/<session id>/<agent id>.json, denied-<agent id>.json (FT_LANE_STATE_DIR)

ownership-check.py: the record of a finished agent and the deny state of its hand-back, mode 0600. janitor.py --apply removes a session directory older than 7 days.

ownership-check.log (FT_LANE_STATE_DIR)

ownership-check.py: one line for each event. It rolls to ownership-check.log.1 after 1 MB.

refresh-gate.json (FT_LANE_STATE_DIR)

refresh-gate.py: the fingerprint of each refresh key and the parked fingerprints of calls in flight, mode 0600.

fg-wait.json (FT_LANE_STATE_DIR)

checkout-guard.py: the time and the command of the last allowed foreground wait of each 1-hour-cache agent, mode 0600.

main-ops-nudge.json (FT_LANE_STATE_DIR)

checkout-guard.py: the counted git, gh, ssh and scp calls and the time of the last ops note for each session.

main-compact.json, main-compact-off

main-compact.py: the time of its last /compact per session, and the file that turns it off.

artifacts.jsonl (FT_ARTIFACT_REGISTRY)

artifact-registry.py: one line for each published artifact. Mode 0600, because it holds share links.

run/

The run journals and packs that the orchestrators write (run-journal.md). turn-guard.py saves the final report of each coding leaf under the run’s units directory.

routes/

diff-router.py route manifests and their audit log.

evidence/ (FT_EVIDENCE_STORE)

evidence-store.py: evidence packs and recorded verdicts. It appears on the first command that writes, and no pipeline runs one today.

price-gate.py reads these caps and paths from its own environment. The installer sets none of them.

Variable Default Meaning

FT_REVIEW_CAP

2

The checkpoint F round after which the hook denies a verifier* or ft-architecture-audit dispatch of ft-developer (review_cap). The denial names the FIX_LANE recipe. The trivial re-check (cpF r3 trivial-fix <lens> re-check) and the delta re-check (cpF r3 delta-fix <lens> re-check) are the exceptions. The re-check round is FT_REVIEW_CAP + 1, so cpF r3 at the default cap.

FT_GROUP_RESETS

2

The number of resets that a group or merge instance may make. A relaunch past it is denied (reset_cap).

FT_LINEAGE_MAX

10

The number of instances that one lineage may hold. A relaunch that carries Resets: handled is denied when the root already holds this number.

FT_LINEAGE_STATE

~/.local/state/ft-ai-toolkit/lineage.json

The path of the lineage state file. The lock file has the same path with the suffix .lock.

FT_BOUNDARY_HOLD

1

The value 0 switches the boundary hold of price-gate.py off.

FT_BOUNDARY_HOLD_MAX

3

The number of boundary-hold events for each harness compaction epoch.

FT_BOUNDARY_HOLD_RESERVE

4

The number of held resends that the bound root must still be able to pay, with the relaunch, before the hook holds.

FT_BOUNDARY_HOLD_STATE

~/.local/state/ft-ai-toolkit/boundary-hold.json

The path of the boundary-hold state file. The lock file has the same path with the suffix .lock.

decide.py reads Jev’s key from ~/.config/ft-ai-toolkit/openrouter.key (FT_DECIDE_KEY_FILE). vault-note.py reads the optional file ~/.config/ft-ai-toolkit/vault-secret-values. The file is described under vault-note.py.

What the installer changes in ~/.claude

The installers apply all of it in one step (Install step). This is the exact list, so you can check it or apply it by hand.

File Change If you already have something there

~/.claude/hooks/price-gate.py, decide.py, turn-guard.py, unit-check.py, checkout-guard.py, heredoc-guard.py, encoded-exec-guard.py, docker-workload-guard.py, main-compact.py, main-rules.py, lane-nudge.py, artifact-registry.py, ownership-check.py, refresh-gate.py and the commands lane-status.py, vault-note.py, session-audit.py, janitor.py

Copied from deploy/templates/hooks/. price-gate.py loads turn-guard.py for the lane cap. FT_MAX_LANES sets the cap. The default is 6, and it is a setting. lane-nudge.py, lane-status.py and janitor.py load ownership-check.py from the same directory. janitor.py is copied and never registered: you run it.

Overwritten when it differs from the toolkit copy.

~/.claude/main-rules.md

Copied from deploy/templates/claude-md/main-rules.md. main-rules.py gives it to the main loop at session start. An optional ~/.claude/main-rules.local.md is yours, for rules of one machine. The installer never writes or reads it.

Overwritten when it differs from the toolkit copy.

~/.claude/hooks/git-safety-check.sh

Copied (both installers). The bugfix and refactor agents call it from their frontmatter and skip it when absent.

Overwritten.

~/.claude/settings.json → hooks.PreToolUse

One entry: matcher Agent|Task|SendMessage, command python3 "<home>/.claude/hooks/price-gate.py", timeout 15 s.

Left alone when any PreToolUse command already runs price-gate.py. A timeout under 15 s is raised, because a timed-out hook lets the dispatch through unpriced (evidence §41).

~/.claude/settings.json → hooks.PreToolUse (second entry)

Matcher `Bash

Monitor`, command python3 "<home>/.claude/hooks/checkout-guard.py", timeout 5 s (evidence §52). Its checkout check sees only a sub-agent’s command, and only in a checkout listed one per line in ~/.config/ft-ai-toolkit/guarded-checkouts (or FT_GUARDED_CHECKOUTS). The checked commands are mvn, mvnw or mvn-slot.sh (not -version, not -f a pom outside), and git add/commit/reset/checkout/switch/restore/clean/merge/rebase/cherry-pick/revert/stash/am/apply/rm/mv/pull. The check applies in the starting directory, after a cd in the same command, or under git -C. A worktree under .claude/worktrees/ passes. A path that the hook cannot resolve passes. The installer never writes the list. FT_PGREP_WAIT=0 turns off the pgrep -f wait-loop denial. FT_FG_WAIT_GUARD=0 turns off the foreground-wait denial. FT_BG_WAIT_GUARD=0 turns off the background wait-loop denial. FT_FG_DEADLINE_GUARD=0 turns off the foreground wait-loop denial. FT_BG_STDIN_GUARD=0 turns off the background stdin denial. FT_NOOP_WAIT=0 turns off the waiting-word denial and the sleep-check chain rule. A sub-agent’s Monitor call gets a note, never a denial: each event wakes the agent and each stop of a sub-agent wakes its parent, so the filter must emit only failure lines and the done marker. FT_MONITOR_NOTE=0 turns the note off.

Left alone when any PreToolUse command already runs checkout-guard.py.

~/.claude/settings.json → hooks.PreToolUse (third entry)

Matcher Bash, command python3 "<home>/.claude/hooks/heredoc-guard.py", timeout 5 s.

Left alone when any PreToolUse command already runs heredoc-guard.py.

~/.claude/settings.json → hooks.PreToolUse (fourth entry)

Matcher Bash, command python3 "<home>/.claude/hooks/encoded-exec-guard.py", timeout 5 s.

Left alone when any PreToolUse command already runs encoded-exec-guard.py.

~/.claude/settings.json → permissions.allow

The rule Bash(python3 ~/.claude/hooks/diff-router.py plan:*), so the pipelines run the free, read-only routing preflight without a prompt.

Left alone when any rule already contains diff-router.py plan.

~/.claude/hooks/diff-router.py, route-schema.json, evidence-store.py, evidence-schema.json, version-gate.py

Copied from deploy/templates/hooks/ by both installers. They are not registered as hooks: the agents call them through Bash. diff-router.py refuses to route without route-schema.json, so a missing source stops the install. version-gate.py is called by the doc writer through Bash, not registered.

Overwritten.

~/.claude/settings.json → env.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS

"30". The harness default is 20. A checkpoint’s six lenses and the Explore calls of lanes that start together fill it (measurement).

Left alone when set.

~/.claude/settings.json → env.PONYTAIL_SUBAGENT_MATCHER

"^no-subagent$". The ponytail plugin injects its ruleset, about 1.4K tokens, into every sub-agent. This regex matches no agent, so the plugin stays out of sub-agents.

Left alone when set. The key reaches the shell of every agent. A machine with mvn-slot must list PONYTAIL_* as inert in its ~/.claude/mvn-slot/lib-classify.sh, a file outside this repository, or mvn-slot refuses pool calls (as the economy.py source comment states, unverified here).

~/.claude/settings.json → hooks.SubagentStop

One entry, no matcher: command python3 "<home>/.claude/hooks/turn-guard.py", timeout 10 s.

Left alone when any SubagentStop command already runs turn-guard.py.

~/.claude/settings.json → hooks.PreToolUse (fourth entry)

Matcher SubagentHandback, command python3 "<home>/.claude/hooks/ownership-check.py", timeout 10 s.

Left alone when a PreToolUse command already runs ownership-check.py. A timeout below 10 s is raised.

~/.claude/settings.json → hooks.SubagentStop (second entry)

No matcher, command python3 "<home>/.claude/hooks/ownership-check.py", timeout 10 s.

Left alone when a SubagentStop command already runs ownership-check.py. The installer checks each event on its own, so a settings.json that holds only one of the two entries gets the other.

~/.claude/settings.json → hooks.PreToolUse (fifth entry)

Matcher Agent|Task, command python3 "<home>/.claude/hooks/refresh-gate.py", timeout 5 s.

Left alone when a PreToolUse command already runs refresh-gate.py.

~/.claude/settings.json → hooks.PostToolUse (second entry)

Matcher Agent|Task, command python3 "<home>/.claude/hooks/refresh-gate.py", timeout 5 s.

Left alone when a PostToolUse command already runs refresh-gate.py.

~/.claude/settings.json → hooks.Stop

Two entries, no matcher: python3 "<home>/.claude/hooks/main-compact.py" with timeout 10 s, and python3 "<home>/.claude/hooks/lane-nudge.py" with timeout 15 s.

Each is left alone when any Stop command already runs that script. A timeout below the value is raised.

~/.claude/settings.json → hooks.SessionStart

One entry: matcher startup|resume|clear|compact, two commands, python3 "<home>/.claude/hooks/main-rules.py" and python3 "<home>/.claude/hooks/main-rules.py" --part 2, timeout 5 s each. The harness shows the model only a 2 KB preview of a hook command’s output over about 10000 characters, so the rules go out in two parts, each under 9500 characters. main-rules.py --check [dir] exits 1 and names the file that no longer fits; the installer runs it on the installed pair.

Left alone when any SessionStart command already runs main-rules.py, except that the installer adds the --part 2 command to that entry when it is missing. A different matcher is widened to this one.

~/.claude/settings.json → hooks.PostToolUse

Two entries: matcher Artifact, command python3 "<home>/.claude/hooks/artifact-registry.py", timeout 5 s; and matcher CronCreate|CronDelete, command python3 "<home>/.claude/hooks/main-rules.py", timeout 5 s.

Each is left alone when any PostToolUse command already runs that script.

~/.claude/settings.json → autoCompactWindow

600000.

Your own value is kept.

~/.claude/settings.json → enabledPlugins["claude-mem@thedotmack"]

Set to false. This happens only on your y (or ASSUME_YES=1), and only when the value is true.

Never re-enabled.

~/.claude/CLAUDE.md

A block between <!-- ft-ai-toolkit:economy:begin --> and <!-- ft-ai-toolkit:economy:end -->, from deploy/templates/claude-md/economy.md. See The global CLAUDE.md block.

Replaced in place on every run. Nothing outside the markers is touched. Created when the file is absent.

~/.claude/agents/ft-developer.md, bugfix-agent.md, refactor-agent.md, ft-fix-host.md, ft-ops.md, ft-ui-ux-design.md, ft-sdd.md, and the four coding agents

experimental: cacheTtl: "1h" in the frontmatter. It arrives with the normal agent sync.

Overwritten like every agent.

~/.config/ft-ai-toolkit/openrouter.key

Checked for presence and mode 600 only. The installer never reads, writes or prints it.

The settings entry, for a hand edit:

{
  "autoCompactWindow": 600000,
  "env": {
    "CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS": "30",
    "PONYTAIL_SUBAGENT_MATCHER": "^no-subagent$"
  },
  "permissions": {
    "allow": ["Bash(python3 ~/.claude/hooks/diff-router.py plan:*)"]
  },
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Agent|Task|SendMessage",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/price-gate.py", "timeout": 15 }]
      },
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/checkout-guard.py", "timeout": 5 }]
      },
      {
        "matcher": "Bash",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/heredoc-guard.py", "timeout": 5 }]
      },
      {
        "matcher": "SubagentHandback",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/ownership-check.py", "timeout": 10 }]
      },
      {
        "matcher": "Agent|Task",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/refresh-gate.py", "timeout": 5 }]
      }
    ],
    "SubagentStop": [
      { "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/turn-guard.py", "timeout": 10 }] },
      { "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/ownership-check.py", "timeout": 10 }] }
    ],
    "Stop": [
      { "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/main-compact.py", "timeout": 10 }] },
      { "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/lane-nudge.py", "timeout": 15 }] }
    ],
    "SessionStart": [
      {
        "matcher": "startup|resume|clear|compact",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/main-rules.py", "timeout": 5 },
                  { "type": "command", "command": "python3 ~/.claude/hooks/main-rules.py --part 2", "timeout": 5 }]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Artifact",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/artifact-registry.py", "timeout": 5 }]
      },
      {
        "matcher": "CronCreate|CronDelete",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/main-rules.py", "timeout": 5 }]
      },
      {
        "matcher": "Agent|Task",
        "hooks": [{ "type": "command", "command": "python3 ~/.claude/hooks/refresh-gate.py", "timeout": 5 }]
      }
    ]
  }
}

The global CLAUDE.md block

economy.py writes deploy/templates/claude-md/economy.md into ~/.claude/CLAUDE.md, between the markers <!-- ft-ai-toolkit:economy:begin --> and <!-- ft-ai-toolkit:economy:end -->. Claude Code delivers that file to the main loop and to every agent on every turn, so the block holds only the rules that every agent must obey. The rules of the main loop alone are in main-rules.md, which the hook main-rules.py delivers at session start.

Situation What the installer does

The markers are present

Replaces the text between them. Nothing outside the markers changes.

The markers are absent

Appends the block. Creates the file when it is absent.

The block sits under the old ft-ai-toolkit:next-economy markers

Renames the markers and replaces the block in place.

Lines inside the markers are not in the template

Prints a WARN with the line count and the first line. Saves the previous file as CLAUDE.md.bak-<timestamp>. Then replaces the block (evidence §43).

--check or --doctor

Reports MISSING when the block is absent or differs from the template. Writes nothing.

DRY_RUN=1

Prints replace or append and writes nothing.

Put your own rules below the end marker. The block holds no credential, and no credential belongs in CLAUDE.md: Claude Code delivers the file to every agent on every turn.

The block is short on purpose, because it costs tokens in every agent. The rules that only the main loop needs live in ~/.claude/main-rules.md (routes, lanes, relaunch after a context reset, the four commands of Command-line scripts, operational batches). main-rules.py delivers that file as SessionStart context. A probe showed that this context reaches the main thread only, and it arrives again after a compact. Sub-agents therefore do not pay for it. The status line of the main loop keeps the literal form lanes <running>/<target>, which lane-nudge.py reads.

What the block tells every agent (economy.md):

  • A lane messages the main loop only on a blocker or a decision that is not its own. Routine progress goes to its journal.

  • Run any wait over about 4 minutes in the background and end the turn. The stack’s agents keep a 1-hour cache, so the wake is a cache read. An agent on the 5-minute cache (general-purpose, the reviewers) waits in 4-minute foreground chunks for a wait under about 40 minutes. A short wait is ONE foreground command. checkout-guard.py denies a bare sleep (see Timer waits).

  • Avoid the shell traps that cost the most turns: quote == and globs in zsh, use BSD sed -i '', expect a refused foreground sleep, read a file before Edit, call the tool Bash, and run ToolSearch before a deferred tool.

  • Write knowledge by what it costs to load: CLAUDE.md for must-obey rules, .claude/rules/ for one area, the vault for decisions and history.

What the main loop gets in addition (main-rules.md):

  • Route code work through the orchestrators: features /ft-dev, bugs /ft-fix, cleanup /ft-refactor.

  • End the prompt with Resets: handled when you launch ft-developer or bugfix-agent yourself, and relaunch a fresh one on CONTEXT_RESET. Start the pending units of a SPLIT as separate runs. Never send a message to a retired agent.

  • Send a MAJOR or CRITICAL bug through /ft-fix, hosted by one ft-fix-host when you keep your context small. Never send it to a bare bugfix-agent or a general-purpose host. Relaunch a host that returns CLIMB: opus with Climb: opus.

  • Send a small change with no design choice in it to bugfix-agent as MINOR, or to the stack’s coding agent. Send a small addition that follows an existing pattern to /ft-dev (simple-addition). See Quality Pipelines, Choosing the entry point.

  • Send UI/UX work on an existing screen to one ft-ui-ux-design. Larger builds go to /ft-dev.

  • Send a design document for people to one ft-sdd, never to a fork or a general-purpose.

  • Keep the number of running lanes that the owner last asked for. When a lane ends, start the next backlog item in the same turn. Every status line says lanes <running>/<target>.

  • Over about 200K of context, hand operational batches to one ft-ops agent. Keep the approvals and design choices. Past 300K the price gate adds a note that asks you for /compact, and in Terminal.app main-compact.py types the command for you. See Dispatch Economy.

  • Audit before fixing: 1 to 3 audit rounds, then ONE fix batch. Write by day and run heavy batches in the evening.

Install step

install.sh and install.ps1 both run deploy/scripts/economy.py right after the rules sync. They run it again, with --check, in the verification pass of every run and of --doctor (-Doctor on Windows). There is one implementation and two thin callers, so the two installers cannot drift. The install commands, the preview and the options are on Deployment & Usage.

deploy/scripts/install.sh --doctor        # verify only: "economy hooks, settings.json wiring, CLAUDE.md block"
SKIP_ECONOMY=1 deploy/scripts/install.sh   # leave the economy step out (and out of verification)
  • The step first removes the toolkit’s own superseded -next agents, entry skills and rules from ~/.claude. It touches nothing else.

  • The step is idempotent. Each item prints one ok, dry-run, MISSING or WARN line. A second run reports every line ok.

  • An unreadable settings.json stops the step with exit 2 and leaves settings.json and CLAUDE.md untouched.

  • The step needs Python 3 (python3, or python on Windows). Without it the step warns and is skipped.

  • The claude-mem offer follows the installer’s usual rule: a TTY y, or ASSUME_YES=1.

Evidence

The numbers on this page are measured in deploy/evals/dispatch-economy-evidence.md. It is the same record as on Dispatch Economy. evidence §N names a section of that file.

How Claude Code behaves underneath

The rules on this page rest on these observed behaviours. They were measured in Claude Code versions 2.1.29x to 2.1.31x (October 2026).

Behaviour Effect

Every Agent call is asynchronous.

It returns "Async agent launched" at once, with or without run_in_background (5,556 launches, none in the foreground; §67). An orchestrator wakes once per child. A batch is "collected" by ending the turn on each completion until the last.

A sub-agent that ends a turn with nothing running is forced to hand back.

The harness answers with [handback-send-enforce] and the run is over. A running child agent, or a background Bash that it started, keeps it alive. An armed Monitor does not, and neither does a child that has itself gone idle (§6, §67). turn-guard.py blocks that turn end once.

Notices travel up.

A child that ends a turn while its own background job runs sends its parent an interim notice. Each notice is a turn of the parent, paid at the parent’s context size. No setting, env var or hook suppresses it. Version 2.1.311 fixes auto-mode wake loops and the SubagentStop flood. A long-running session needs a restart (claude --resume). Measured: 202 such wakes in 5 hours cost $28 and did nothing (§67). On 2026-10-27 there were 239 in 12 hours, $43 of $161 (§69).

The prompt cache lives five minutes for a sub-agent.

It lives one hour for an agent whose frontmatter says experimental: cacheTtl: "1h". A wait past the TTL (time to live) rewrites the context at 1.25x (2x for the 1-hour cache) instead of reading it at 0.1x. A 1-hour agent waits in the background and ends its turn. A 5-minute agent waits in 4-minute foreground chunks (§56). The provider also sometimes drops every cache at once (§60, §67).

A foreground Bash is capped at 10 minutes.

A command that hits the cap moves to the background and keeps running. "Repeat on timeout" stacks copies (§6).

Agent types load at session start.

A running session learns a new agent type through an agent_listing_delta attachment, minutes after the file appears (§66).

Installing hooks, rules or agents does not invalidate the cache of running agents.

§60.

Measurements behind the rules

Rule Measurement or date

price-gate.py ends each denial with ready-to-paste lines

Eight denials on 2026-11-01 had no such line for a judgment lens or the test adversary on a cheaper model.

heredoc-guard.py

One journal append ran git clean -fdxq in the main checkout.

encoded-exec-guard.py

One lane shipped a script to the pool hosts as an encoded payload piped into bash inside an ssh command, on 2026-11-13.

phase-gate.py

Seven phases that CLAUDE.md declared mandatory fired twice in 14 days.

context-guard.py

One session spent 52% of its context on images and ended early.

price-gate.py timeout of at least 15 s

On 2026-10-23, three timeouts at 5 s in one night let dispatches through unpriced (§41).

CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS of 30

The harness default of 20 refused 56 dispatches over 2026-10-15 and 2026-10-16, at 3 to 14 lanes.

lane-nudge.py

Replayed over the lanes session of 2 November with the delivered code, it nudged 8 times for the UTC day when it was first repaired and 10 times at the last run. The transcript grew between the runs, and the change adds no nudge. The bar of 1 to 8 was set on a shorter transcript of the same session, and the owner accepted 8 to 10 (run journal, not re-run for this page). The earlier design with a 900-second doubling gap gave 23 nudges on that day.

checkout-guard.py timer denial

Replayed over 183,295 real Bash commands, it denied 428. The review of the distinct shapes found no false positive.

vault-note.py secret scan

Over 2,096 notes in the vault, the key shapes alone refuse 98 (4.68%, bar 5%). Of 5 known credential lines, the shapes catch 1 and a values file catches all 5.

session-audit.py

A run over 3 days of transcripts takes about 6 seconds. It reported waits of $427 where the manual audit found $402. For vault work it reports a window ($1868) beside the messages that touch the vault ($408), and the manual audit found $336. See session-audit.py.

artifact-registry.py backfill

Over 3 days of transcripts it found 271 publishes.

turn-guard.py

Replayed over 4,075 orchestrator turn ends (2026-10-10 to 2026-10-16, ftacs), it would have blocked 33 of the 41 forced hand-backs that cut a run short. It would also have blocked 75 turn ends that the harness let through, about one extra turn per lane per day. Live overnight on 2026-10-15 and 2026-10-16 it blocked 7 turn ends, and three agents kept working.