agentleFS
aw-praw-pr/autometta-public/CLAUDE.md

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

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
  1. Distinctive:

    Git is the state store; filesystem is the message bus: No daemons, no databases, no services.

    line 61
  2. Distinctive:

    MCP is the only tool integration boundary: No bespoke RPC.

    line 66
  3. Distinctive:

    Markdown is the deliverable for pass 1: Treat docs and templates as the product, not as docs *about* the product.

    line 91
  4. Distinctive:

    When an orchestrator session dispatches a worker or verifier directly (not via the tick loop), the canonical pattern is:

    line 143
  5. Very specific:

    All trailer lines go in one -m so git parses them as a single trailer block.

    line 205

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

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

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. See memory/README.md for the contract. Do not mirror this into ~/.claude/projects/.../memory/ or any Codex-side equivalent; the in-repo copy is authoritative.
  • state/ - state.yaml plus 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-orchestrator lives here canonically; mcp-hub/skills/agent-orchestrator is 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

  1. 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/ and templates/.
  2. 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 in scripts/, schemas in schemas/, per-repo state in state/. See docs/tick-loop.md for the design and docs/setup.md for 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-write makes 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:

  1. codex exec reads stdin after the prompt arg - always redirect </dev/null from any wrapping harness.
  2. Card-sync race across git worktrees - verifier and worker must see the same card content; serialise writes.
  3. Log paths must be predictable (the loop writes state/logs/<stage-id>-worker.log and <stage-id>-verifier.log), not harness-generated task IDs.
  4. Sandbox shadows: a worker that appears to pass acceptance inside its sandbox may be lying about side-effects it couldn't perform.
  5. Prior-gate regressions: re-running acceptance after a later change can surface a regression in an earlier stage.
  6. Claude CLI dispatches use --output-format stream-json --verbose, then claude-token-log.sh forwards progress and writes the final Total tokens: line. The registry marks those entries log_streams: true, so heartbeat applies log-mtime staleness per dispatch; legacy Claude registrations remain exempt (see scripts/heartbeat.sh).
  7. claude -p needs --dangerously-skip-permissions to act autonomously; --permission-mode bypassPermissions combined with -p exits silently with an empty log.
  8. Codex CLI prefers $CODEX_HOME/auth.json over the OPENAI_API_KEY env var. If ~/.codex/auth.json has auth_mode: "chatgpt" (the default after codex login), an op-fetch OPENAI_API_KEY=... -- codex exec dispatch still bills the subscription. Fix: a sibling CODEX_HOME (default ~/.codex-api-only) with auth_mode: "apikey"; spawn scripts export and --pass CODEX_HOME through op-fetch in api mode and fail closed if the sibling is missing.
  9. 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 $! in spawn-worker.sh, spawn-verifier.sh, and spawn-verifier-panel.sh (shell job-control SIGHUP), AND AbandonProcessGroup in templates/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. See docs/lessons.md gotcha 9.
  10. A tick can destroy the gitignored state/state.yaml: commit_state_branch's git add state/state.yaml was a silent no-op (gitignored), so the state branch never backed it up, and a degenerate read/write in state_apply_json can overwrite the only on-disk copy with an empty stages: [] stub. Fix: state_apply_json read/write guards + a rolling state/state.yaml.bak, plus a top-of-tick integrity guard that restores .bak or halts state-corrupt. commit_state_branch now snapshots the state files through a throwaway index (write-tree / commit-tree under its own GIT_INDEX_FILE), so the gitignore no longer hides them from the state branch. See docs/lessons.md gotcha 10.
  11. op read can block forever on a macOS TCC prompt no one is there to answer, hanging an overnight dispatch with an empty log. op-fetch wraps every read in a watchdog (OP_FETCH_TIMEOUT, default 60s). The TCC grant does not survive a brew upgrade 1password-cli. See docs/lessons.md gotcha 11.
  12. 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 high reached 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 three verifier_attempt_cap retries. Multi-token argument lists travel in a bash array (AUTOMETTA_EFFORT_ARGV), expanded quoted, never through word splitting; # shellcheck disable=SC2086 documents 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. See docs/lessons.md gotcha 12.
  13. codex exec --oss refuses 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:30b and devstral are 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_preflight checked only that the model was pulled, so the failure landed after the stage was in_progress; it now reads the Capabilities block from ollama show and fails closed before the spawn, failing open only when that block cannot be read. See docs/lessons.md gotcha 19.
  14. 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, ~/Documents or ~/Downloads raises 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 for AUTOMETTA_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. See docs/lessons.md gotcha 22.
  15. 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's started_at; that one is rewound untouched. Anything later is pinned on a wip/<stage>-attempt-N ref before the rewind, at most USAGE_LIMIT_MAX_REWINDS (2) times per stage, after which the exit takes the ordinary missing-envelope path. limit_rewinds survives a requeue. See docs/lessons.md gotcha 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 in docs/philosophy.md at 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 always anthonylwest; author is the agent identity string. Atomic commits.
  • Don't edit AGENTS.md directly - it is a symlink to this file.
  • Don't edit skills/agent-orchestrator/ from outside this repo - the mcp-hub copy is a symlink back here.

Skills hosted by this repo

  • skills/agent-orchestrator/ - canonical home. Loaded into ~/.claude/skills/agent-orchestrator via the mcp-hub symlink 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 in memory/proposals.jsonl with 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 through autometta-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, under auth.<family>.mode. Resolver fallback (no manifest present) is subscription for both. The shipped template recommends codex: 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, optional OP_REF_CLAUDE_CODE_OAUTH_TOKEN. The XDG location is visible to both the dev checkout and the brew-installed CLI; <repo>/op-refs.local.sh works for dev only.
  • Sibling CODEX_HOME at ${AUTOMETTA_CODEX_HOME:-~/.codex-api-only} is required for codex api mode (codex prefers ~/.codex/auth.json over OPENAI_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_HOME whenever codex is in api mode. autometta auth check codex verifies both the ref and the sibling.
  • Service-account token for op-fetch is 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) and autometta auth check <family> (PASS / FAIL / subscription, with redacted credential, no token spend).
  • Fail-closed: missing op-fetch, unset OP_REF_*, or an unresolved op://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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.