autometta-public
CLAUDE.md0 starsChanged 6 months agoMITView on GitHub
This file is the shared brief for any agent working in this repo - Claude Code, Codex CLI, or any future CLI family. AGENTS.md is a symlink to this file; do not edit them separately. One source of truth, two conventional filenames. Autometta is built for Claude Code and Codex CLI to operate in the same working tree without prejudice. Every change should make sense from both sides. If a doc, template, or script implicitly assumes only one family, flag…
- Reads credentials
In this repository11 other files it gives its agents.
- agent-orchestratorSkill
- autometta-card-reviewSkill
- autometta-escalationsSkill
- autometta-learning-logSkill
- autometta-oracleSkill
- autometta-requeueSkill
- autometta-run-designSkill
- autometta-setupSkill
- autometta-weekly-reviewSkill
- phat-controllerSkill
- yoloSkill
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 61
Git is the state store; filesystem is the message bus: No daemons, no databases, no services.
- Distinctive: line 66
MCP is the only tool integration boundary: No bespoke RPC.
- Distinctive: line 91
Markdown is the deliverable for pass 1: Treat docs and templates as the product, not as docs *about* the product.
- Distinctive: line 143
When an orchestrator session dispatches a worker or verifier directly (not via the tick loop), the canonical pattern is:
- Very specific: line 205
All trailer lines go in one -m so git parses them as a single trailer block.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md / AGENTS.md
This file is the shared brief for any agent working in this repo - Claude Code, Codex CLI, or any future CLI family. AGENTS.md is a symlink to this file; do not edit them separately. One source of truth, two conventional filenames.
Two-family invariant
Autometta is built for Claude Code and Codex CLI to operate in the same working tree without prejudice. Every change should make sense from both sides. If a doc, template, or script implicitly assumes only one family, flag it.
State and memory that agents need across sessions live in the repo, not in any one harness's private directory:
memory/- append-only agent memory shared across families. Seememory/README.mdfor the contract. Do not mirror this into~/.claude/projects/.../memory/or any Codex-side equivalent; the in-repo copy is authoritative.state/-state.yamlplus per-task JSON for the autonomous loop. Runtime contents are gitignored; the directory itself is part of the contract.skills/- agent skills hosted by this repo.agent-orchestratorlives here canonically;mcp-hub/skills/agent-orchestratoris a symlink back.
What this repo is
Autometta is a pattern library, not a runtime. v1.1.0: the contract, the loop and the operator surfaces are stable and in daily use; still one human, one machine. The repo contains prose (README.md, docs/), markdown templates, the skills under skills/ (agent-orchestrator, autometta-setup, autometta-run-design, autometta-card-review, autometta-oracle, autometta-requeue, autometta-escalations, autometta-learning-log, autometta-weekly-review, yolo, phat-controller), a shared memory/ store, and the bash scaffolding for the tick loop (scripts/, schemas/, state/). There is no build and no package manifest - do not invent one. The test suite is the set of scripts/*-smoke.sh contract tests, run through scripts/check-contract-test-gate.sh; a script change that touches a covered contract should extend or add a smoke.
The repo extracts patterns from two prior projects (fractals-from-the-90s dispatch contract; agentic-rag-kimble pass 28-29 autonomous loop) and packages them for solo single-machine multi-agent CLI work. See README.md for the pitch and docs/philosophy.md for the long-form scope.
Two layers, shipped in two passes
- Dispatch contract (pass 1 - shipped): the contract between an orchestrator and one worker for one unit of work. Stage card -> worker prompt -> sandbox boundary -> acceptance command -> verifier handoff. Human drives the orchestrator session. Deliverables live in
docs/andtemplates/. - Autonomous tick loop (pass 2 - shipped): cron-driven tick that reads
state.yaml, dispatches one worker and/or verifier, writes the next state, exits. Two adjacent stages with declared, disjoint path claims may run as a pipeline pair, while verification and landing remain ordered. Budget file is the only safety. The loop layer sits on top of the dispatch contract - never modify the loop in ways that bypass it. Runtime inscripts/, schemas inschemas/, per-repo state instate/. Seedocs/tick-loop.mdfor the design anddocs/setup.mdfor the operator flow.
The operational roles are the tick (deterministic, including the mechanical
recovery that used to need an agent) and the operator's orchestration chat,
plus the worker and the verifier it dispatches. The standard escalation recovery policy is three total worker attempts per stage
(initial plus at most two diagnosed repairs), recorded on the card and bounded
by existing budget/quota gates. The orchestration chat may fix implementation
and demonstrated semantic-preserving harness defects automatically; changed
requirements, relaxed acceptance or extra limits still need approval.
Anything the tick cannot decide
becomes an escalation in the escalations folder for the chat to work
(skills/autometta-escalations). A diagnosis that implicates the harness
itself is recorded, as it happens, as a proposal in memory/proposals.jsonl
(scripts/proposals.sh, skills/autometta-learning-log) and decided once a week with the operator
(skills/autometta-weekly-review, docs/learning-log.md); a proposal is
never authority to edit the harness. Claude Code and Codex lifecycle hooks deliver
new or changed escalations and lifecycle notices at session start, user prompts and after tools;
PostToolUse checks are throttled to 15 seconds. Use the hook's evidence instead
of a model-driven polling loop. Delivery is not acknowledgement or authority to
change state; verify the current episode before acting. Notices include role starts
and exits, landing or awaiting integration, and run completion or halts. Optional
scripts/wakeups.sh enable registration adds bounded idle wake-ups through native
Claude asyncRewake or Codex queue controls. One outstanding batch per chat,
120-second fleet cooldown and rolling fleet caps prevent event storms. A wake-up
never renews its own lease or authorises policy changes. mcp-hub distributes the
hooks; scripts/install-escalation-hook.sh
--check --family all checks their entries. See docs/tick-loop.md, Escalations.
The scheduled controller agent is retired
(docs/proposals/controller-retired.md); scripts/phat-controller.sh remains
as a set of verbs, not a role.
Pass 2 also ships agent observability: a per-agent liveness registry at state/active-agents/<pid>.json, a heartbeat watchdog at scripts/heartbeat.sh that surfaces stalls / over-budget conditions to state/heartbeat.json, a full-window repo ticker (scripts/repo-ticker.sh), the autometta tui run/history/messages view, and a polling primitive (scripts/watch-agent.sh) that any orchestrator-led manual dispatch can block on to catch silent agent deaths. See docs/observability.md. Spend is instrumented separately: tick.sh appends one cost-log line per dispatched role to state/cost-log.jsonl (per-tier cost_usd_est from scripts/rates.sh, cached_input_tokens vs input_tokens, cache_hit_rate). Schema and the prompt-caching notes are in docs/cost-log.md.
Load-bearing beliefs (read before proposing changes)
Decisions, not preferences. Diverging needs an explicit conversation, not a quiet refactor:
- Git is the state store; filesystem is the message bus. No daemons, no databases, no services. One stage card per dispatch; the card path is the prompt.
- Sandbox is the role boundary. Codex
workspace-writemakes worker-self-verification structurally impossible. We exploit this rather than lift it. Verifier always runs outside the worker sandbox. - Cross-family verification by default. Worker in family A, verifier in family B (typically Codex worker, Claude verifier).
- Cron + tick > daemon. A tick reads state, makes one transition, writes state, exits. Resumable, killable, debuggable.
- Budget file, not retries. Hard stop on bounded total spend. No exponential backoff, no circuit breakers.
- MCP is the only tool integration boundary. No bespoke RPC.
Headless gotchas to never re-learn
Invariants when reviewing or writing scaffolding. This list is numbered on its own; docs/lessons.md has the full write-up of all twenty-three, and each item below names the lesson it comes from where the numbers differ:
codex execreads stdin after the prompt arg - always redirect</dev/nullfrom any wrapping harness.- Card-sync race across git worktrees - verifier and worker must see the same card content; serialise writes.
- Log paths must be predictable (the loop writes
state/logs/<stage-id>-worker.logand<stage-id>-verifier.log), not harness-generated task IDs. - Sandbox shadows: a worker that appears to pass acceptance inside its sandbox may be lying about side-effects it couldn't perform.
- Prior-gate regressions: re-running acceptance after a later change can surface a regression in an earlier stage.
- Claude CLI dispatches use
--output-format stream-json --verbose, thenclaude-token-log.shforwards progress and writes the finalTotal tokens:line. The registry marks those entrieslog_streams: true, so heartbeat applies log-mtime staleness per dispatch; legacy Claude registrations remain exempt (seescripts/heartbeat.sh). claude -pneeds--dangerously-skip-permissionsto act autonomously;--permission-mode bypassPermissionscombined with-pexits silently with an empty log.- Codex CLI prefers
$CODEX_HOME/auth.jsonover theOPENAI_API_KEYenv var. If~/.codex/auth.jsonhasauth_mode: "chatgpt"(the default aftercodex login), anop-fetch OPENAI_API_KEY=... -- codex execdispatch still bills the subscription. Fix: a siblingCODEX_HOME(default~/.codex-api-only) withauth_mode: "apikey"; spawn scripts export and--pass CODEX_HOMEthrough op-fetch in api mode and fail closed if the sibling is missing. - Claude worker subshell (
( ... ) &) receives SIGHUP when the LaunchAgent tick exits, silently killing the worker at ~21s with a 0-byte log. Codex is unaffected (no wrapping subshell). Fix is two complementary parts:disown "$pid"immediately after capturing$!inspawn-worker.sh,spawn-verifier.sh, andspawn-verifier-panel.sh(shell job-control SIGHUP), ANDAbandonProcessGroupintemplates/launchagent.plist.tpl(launchd reaping the tick's process group on exit). Keep both. Verified 2026-05-29 with a real LaunchAgent dispatch: a claude worker survived the tick exit and ran to completion. Seedocs/lessons.mdgotcha 9. - A tick can destroy the gitignored
state/state.yaml:commit_state_branch'sgit add state/state.yamlwas a silent no-op (gitignored), so the state branch never backed it up, and a degenerate read/write instate_apply_jsoncan overwrite the only on-disk copy with an emptystages: []stub. Fix:state_apply_jsonread/write guards + a rollingstate/state.yaml.bak, plus a top-of-tick integrity guard that restores.bakor haltsstate-corrupt.commit_state_branchnow snapshots the state files through a throwaway index (write-tree/commit-treeunder its ownGIT_INDEX_FILE), so the gitignore no longer hides them from the state branch. Seedocs/lessons.mdgotcha 10. op readcan block forever on a macOS TCC prompt no one is there to answer, hanging an overnight dispatch with an empty log.op-fetchwraps every read in a watchdog (OP_FETCH_TIMEOUT, default 60s). The TCC grant does not survive abrew upgrade 1password-cli. Seedocs/lessons.mdgotcha 11.IFS=$'\n\t'has no space in it, so an unquoted expansion of a space-joined flag string is a silent no-op split:--effort highreached the CLI as one option name containing a space and every Claude verifier with a declared effort died instantly (error: unknown option '--effort high'), burning all threeverifier_attempt_capretries. Multi-token argument lists travel in a bash array (AUTOMETTA_EFFORT_ARGV), expanded quoted, never through word splitting;# shellcheck disable=SC2086documents such an intent while hiding its failure. Codex was unaffected: clap attaches a short option's value, and codex trims the leading space, so its effort was honoured throughout. Seedocs/lessons.mdgotcha 12.codex exec --ossrefuses any Ollama model without thinking support ("<model>" does not support thinking), which as of codex-cli 0.149.1 leaves only the gpt-oss family usable on the free local route.llama3.3:70b,llama4:scout,qwen3-coder:30banddevstralare all refused, and the last four ran fine in the 2026-08-24 bake-off, so this is a CLI regression under a documented result rather than a standing limit.codex_local_preflightchecked only that the model was pulled, so the failure landed after the stage wasin_progress; it now reads theCapabilitiesblock fromollama showand fails closed before the spawn, failing open only when that block cannot be read. Seedocs/lessons.mdgotcha 19.- A Claude dispatch started from launchd can block forever on a macOS TCC prompt: around its first edit, Claude Code touches the paths named in the user's permission rules, and a rule naming
~/Desktop,~/Documentsor~/Downloadsraises a prompt that no one is there to answer. Every Claude Code release installs to a new versioned path, so each update re-arms it. Keep protected folders out of user-level rules: that is the fix. The tick can also kill a streaming dispatch that stays silent forAUTOMETTA_SILENCE_KILL_SECONDS, but only when that is set above 0; the default is 0 (off), because quiet local compute can outlast any silence limit. Seedocs/lessons.mdgotcha 22. - A provider limit that lands mid-run must not cost the work. An exit with no envelope whose log matches a limit pattern is an instant refusal only if the log was last written within
USAGE_LIMIT_INSTANT_SECONDS(60) of the stage'sstarted_at; that one is rewound untouched. Anything later is pinned on awip/<stage>-attempt-Nref before the rewind, at mostUSAGE_LIMIT_MAX_REWINDS(2) times per stage, after which the exit takes the ordinary missing-envelope path.limit_rewindssurvives a requeue. Seedocs/lessons.mdgotcha 23.
Conventions specific to this repo
- British English in prose. No em dashes. No "AI-tell" vocabulary (
delve,leverage,seamless,robust). The persona-west audit rules apply to all committed prose. - Markdown is the deliverable for pass 1. Treat docs and templates as the product, not as docs about the product.
- Inline
<ALW>...</ALW>tags anywhere in the repo are Tony's open notes, not committed decisions. Resolve in conversation before treating as scope. None should remain indocs/philosophy.mdat this point; if you see one, that is a regression worth flagging. - Per-agent git author attribution is enforced globally (see
~/.claude/rules/mcp-hub-dev-rules.md). Committer is alwaysanthonylwest; author is the agent identity string. Atomic commits. - Don't edit
AGENTS.mddirectly - it is a symlink to this file. - Don't edit
skills/agent-orchestrator/from outside this repo - themcp-hubcopy is a symlink back here.
Skills hosted by this repo
skills/agent-orchestrator/- canonical home. Loaded into~/.claude/skills/agent-orchestratorvia themcp-hubsymlink chain. Edits here are the source of truth for every consumer.skills/autometta-setup/- adopt the dispatch contract and the tick loop in another repo.skills/autometta-run-design/- design a run before anything is queued: cards, pairings, gates, spend.skills/autometta-card-review/- interview the operator and review one card before it is queued: seat check, baseline run, cold read,card-lint.sh --strict.skills/autometta-oracle/- author a focused frozen contract test with proportionate proof, record its digest and any authorised supplemental evidence gates.skills/autometta-requeue/- re-queue a stage safely after a FAIL, a dead agent or a stale run worktree.skills/autometta-escalations/- work the operator's pending escalations from an orchestration chat.skills/autometta-learning-log/- where and how any orchestration chat records halts, harness-caused failures, workarounds and missing guidance as they happen, for the weekly review. Every other orchestration skill points here.skills/autometta-weekly-review/- once a week, decide the open harness proposals inmemory/proposals.jsonlwith the operator and card the approved ones (docs/learning-log.md).skills/yolo/- attend a queued run with the operator away: caps and stop time agreed in one prompt, a written standing authority, a hard stop at a stage's third failed attempt, and a decision log whose lessons go to the proposals ledger.skills/phat-controller/- a pointer: the role is retired, work the queue throughautometta-escalations.
Auth routes: subscription vs API key (agents: read this before any dispatch)
Aligned to the auth-route-security skill. Every dispatch goes through op-fetch, which exec's the child via env -i + allowlist + only the named refs.
- Mode lives in
.autometta.local.yaml(gitignored) in the subscribed repo, underauth.<family>.mode. Resolver fallback (no manifest present) issubscriptionfor both. The shipped template recommendscodex: api+claude: subscription; flip per repo as needed. - Refs live in
op-refs.sh(committed, placeholders, in the autometta repo) +~/.config/autometta/op-refs.local.sh(gitignored, real op:// refs, mode 0600). Variables:OP_REF_OPENAI_API_KEY,OP_REF_ANTHROPIC_API_KEY, optionalOP_REF_CLAUDE_CODE_OAUTH_TOKEN. The XDG location is visible to both the dev checkout and the brew-installed CLI;<repo>/op-refs.local.shworks for dev only. - Sibling CODEX_HOME at
${AUTOMETTA_CODEX_HOME:-~/.codex-api-only}is required for codex api mode (codex prefers~/.codex/auth.jsonoverOPENAI_API_KEY, see lessons.md gotcha #8). One-time setup:mkdir -p ~/.codex-api-only && chmod 700 ~/.codex-api-only && op-fetch --print "$OP_REF_OPENAI_API_KEY" | CODEX_HOME=~/.codex-api-only codex login --with-api-key. Spawn scripts export and pass it through op-fetch via--pass CODEX_HOMEwhenever codex is in api mode.autometta auth check codexverifies both the ref and the sibling. - Service-account token for
op-fetchis read from$OP_SERVICE_ACCOUNT_ENV(default~/.config/op/service-account.env); no biometric prompt. - Dispatch-time override:
AUTOMETTA_CODEX_MODE=api/AUTOMETTA_CLAUDE_MODE=api(or the reverse). Beats the manifest. - Verify before dispatching:
autometta auth status(per-family table + op-fetch presence) andautometta auth check <family>(PASS / FAIL / subscription, with redacted credential, no token spend). - Fail-closed: missing
op-fetch, unsetOP_REF_*, or an unresolvedop://YOUR_VAULT/...placeholder aborts the spawn before any token is spent.
scripts/auth-route.sh <family> emits the NAME=$OP_REF_NAME pair (empty in subscription). scripts/spawn-worker.sh and scripts/spawn-verifier.sh source op-refs.sh, call the resolver, then op-fetch <pairs> -- codex exec ... / op-fetch <pairs> -- claude -p .... Subscription mode still goes through op-fetch, so any stray OPENAI_API_KEY / ANTHROPIC_API_KEY in the parent shell is stripped rather than silently redirecting billing. Full surface in docs/setup.md section 7 and MANUAL.md section 5.
Upgrading the local install (agents: read this when picking up a session)
The CLI ships as a local Homebrew tap rendered from this checkout. If the installed version (autometta --version) is older than the publish-branch HEAD (run git rev-parse --short HEAD in the autometta checkout), the in-flight agent is on a stale toolchain and may not see recent scripts (heartbeat, watch-agent, agent-ticker, install-launchagent, etc.).
Canonical upgrade from any session:
cd /path/to/autometta
git pull --ff-only
scripts/install-homebrew-local.sh
autometta --version # should match git HEAD short SHA
autometta attach <repo> # refreshes the tmux viewer (windows listed in docs/observability.md)The brew tap is rendered at install time; brew update alone is not enough. Re-run scripts/install-homebrew-local.sh after every git pull of this repo.
Manual orchestrator dispatch pattern
When an orchestrator session dispatches a worker or verifier directly (not via the tick loop), the canonical pattern is:
# Source the op:// reference table (autometta repo root)
source "$autometta_root/op-refs.sh"
# Resolve the auth route for this family (emits NAME=ref pairs or empty)
auth_pairs="$(REPO_ROOT="$repo" scripts/auth-route.sh codex)"
# Launch via op-fetch (env -i + allowlist + named refs only). For codex+api
# also export CODEX_HOME pointing at the sibling auth dir so codex reads
# auth_mode: apikey instead of the chatgpt-mode ~/.codex/auth.json
# (see gotcha #8). Pass it through via --pass CODEX_HOME.
CODEX_HOME="${AUTOMETTA_CODEX_HOME:-$HOME/.codex-api-only}" \
op-fetch $auth_pairs --pass CODEX_HOME -- \
codex exec -C "$repo" --sandbox workspace-write "$(cat prompt.txt)" </dev/null >log.txt 2>&1 &
pid=$!
disown
# Register so the heartbeat / ticker can see it
scripts/register-agent.sh "$repo" "$pid" worker codex "$identity" "$card" "$log" "$budget_secs"
# Block until done or stuck; the harness notifies on return
scripts/watch-agent.sh "$repo" "$pid" "stage-NN-worker"watch-agent.sh exit code: 0 clean, 2 STUCK, 3 bad input. STUCK escalates when the heartbeat first flags silent and the grace window expires (defaults 60s poll, 120s grace, both env-overridable). For the claude family swap the launch line for ( cd "$repo" && op-fetch $auth_pairs -- claude -p "$prompt" </dev/null >log 2>&1 ) & and pass claude as the family arg to auth-route.sh and register-agent.sh.
A manual dispatch through scripts/spawn-worker.sh uses the same quota admission
as the tick. Codex subscription cards may start below 100% in every fresh usage
window (a Pro plan reports the weekly one alone); the active card may finish in
overage, then further cards wait. With window_reserve.pace on, a new card also
waits while any listed family it names is ahead of its weekly pace (half-day
slots, remaining headroom over the slots left), and the heartbeat kills a
Codex run that moves the weekly window by more than one slot's allowance;
AUTOMETTA_IGNORE_PACE=1 bypasses the gate. A weekly-only Codex plan normally
lists codex; Claude's five-hour session uses the reserve below. This
also checks a Codex verifier before admitting its Claude worker. Missing/stale
Codex quota holds new cards. Claude keeps its configured reserve (20% by default);
claude_window: 5-hour makes it session-only and checks a new card whose worker
or verifier uses the Claude subscription.
AUTOMETTA_CODEX_QUOTA_POLICY=reserve explicitly selects the legacy Codex policy;
AUTOMETTA_IGNORE_RESERVE=1 bypasses only that reserve, not the default cutoff.
See docs/tick-loop.md for completion, freshness and concurrent-use limits.
op-fetch resolves any named refs via the 1Password service-account token at $OP_SERVICE_ACCOUNT_ENV (default ~/.config/op/service-account.env) and exec's the child with a sanitised env. No biometric prompt, works under cron / LaunchAgent. See docs/setup.md section 7 and docs/observability.md for the full surface.
When using the claude family as a verifier, spawn-verifier.sh resolves a transport (resolve_verifier_transport): an AUTOMETTA_CLAUDE_TRANSPORT override wins, then the manifest's verifier.claude.transport, and with neither set the SDK route is the default whenever its preconditions hold (verifier_sdk_precondition: script, python packages and a usable credential), falling back to claude -p otherwise. Every resolution then passes the route guard (claude_route_refusal in scripts/models.sh): the api-sdk surface calls the raw Messages API, so on a subscription OAuth token it is downgraded to the cli unless agent-sdk is named. Probe with scripts/spawn-verifier.sh --print-transport claude. See docs/sdk-verifier.md.
On verifier PASS, a manual orchestrator commit carries the same role attribution the autonomous loop emits (scripts/tick.sh): author is the worker, the orchestrator and verifier are plain Co-Authored-By lines carrying the canonical identity unchanged, and the Autometta-* trailers name which role each identity played. The orchestrator identity is the card's Orchestrator metadata line. Do not put the role into the display name; docs/dispatch-contract.md forbids it, and the role belongs to the Autometta-* trailer.
git -C "$repo" commit \
--author="$worker_identity" \
-m "$stage_id: $headline" \
-m "Co-Authored-By: $orchestrator_identity
Co-Authored-By: $verifier_identity
Autometta-Orchestrator: $orchestrator_identity
Autometta-Worker: $worker_identity
Autometta-Verifier: $verifier_identity"All trailer lines go in one -m so git parses them as a single trailer block; query a role with git log --format='%(trailers:key=Autometta-Worker,valueonly)'. See docs/dispatch-contract.md step 7.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

