agentleFS
avivsinaiavivsinai/agent-message-queue/CLAUDE.md

agent-message-queue

CLAUDE.md94 starsChanged 12 days agoMITView on GitHub

Repository instructions and engineering contract for coding agents. AGENTS.md is a symlink to this file so harnesses selecting either name load the same guidance. Agent Message Queue (AMQ) is a daemon-free, file-based message bus for local coding agents. Maildir-style tmp -> new -> cur delivery gives crash-safe messages without a database or server. AMQ owns messaging, threads, routing, receipts, handoff state, and operational diagnosis. Orchestrators own worktrees, dependency scheduling, task decomposition, and PR landing. - Unix-like tools. Small commands compose…

The file

We split this CLAUDE.md into the rules it gives an agent

9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never create release branches, tags, or GitHub releases manually.

    line 33
  2. Very specific:

    Keep one version across CHANGELOG.md, .release-please-manifest.json, and skill/plugin metadata.

    line 34
  3. Very specific:

    Keep io.github.avivsinai.<binary> identifiers and never add a re-sign step to the Homebrew formula.

    line 38
  4. Distinctive:

    Use the CLI for mailbox operations.

    line 44
  5. Very specific:

    Use amq cleanup for mailbox retention and amq dlq purge for an explicit dead-letter purge.

    line 45
  6. Very specific:

    Hot-reload rule: every long-running process must hot-reload its configuration without restart, keep the last good value on a refused edit, …

    line 155
  7. Very specific:

    Use docs/cli.md or amq <command> --help for exact flags.

    line 164
  8. Very specific:

    Run tests of changed packages, narrowest first (make test uses a scratch HOME).

    line 191
  9. Distinctive:

    Never commit placeholders, weaken validators, regenerate goldens to hide a defect, or split code from its test.

    line 235

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

Repository instructions and engineering contract for coding agents. AGENTS.md is a symlink to this file so harnesses selecting either name load the same guidance.

Project Overview

Agent Message Queue (AMQ) is a daemon-free, file-based message bus for local coding agents. Maildir-style tmp -> new -> cur delivery gives crash-safe messages without a database or server. AMQ owns messaging, threads, routing, receipts, handoff state, and operational diagnosis. Orchestrators own worktrees, dependency scheduling, task decomposition, and PR landing.

  • Unix-like tools. Small commands compose through files, exit codes, and JSON. There is no daemon or broker, and AMQ never owns another tool's lifecycle.
  • Robust. Delivery is crash-safe. Uncertain state fails closed with a typed refusal that names the reason; there is no silent fallback.
  • Harness-agnostic. AMQ works the same across harnesses and terminals through the seams they already expose. It starts a harness only on the user's explicit launch command, and never restarts or reconfigures a user's harness. When a capability is missing, it falls back and prints a one-line reason.

Release Rules

Full release, signing, secret, and recovery procedures live in docs/release.md. Five rules every session must obey:

  • Request releases only through scripts/release.sh X.Y.Z; Release Please alone updates the changelog and version metadata.
  • Never create release branches, tags, or GitHub releases manually.
  • Keep one version across CHANGELOG.md, .release-please-manifest.json, and skill/plugin metadata.
  • PR titles use type(scope): description (squash merge drives release notes; use BEGIN_COMMIT_OVERRIDE for multiple entries).
  • Keep io.github.avivsinai.<binary> identifiers and never add a re-sign step to the Homebrew formula.

Operational Constraints

  • Handles are lowercase, match [a-z0-9_-]+, and do not start with -.
  • Use the CLI for mailbox operations. Never edit queue files directly.
  • Use amq cleanup for mailbox retention and amq dlq purge for an explicit dead-letter purge. Logs and derived extension caches have documented bounds.
  • AMQ remains daemon-free. Supervisors can run wake or monitor, but AMQ does not own their lifecycle.

Build and Development Commands

make build          # go build amq, amq-keepalive, amq-bridge, amq-acp, amq-remote, amq-owner-sign, amq-board
make test           # go test ./...
make fmt            # gofmt -w
make vet            # go vet
make lint           # golangci-lint
make check          # static gates the pre-push hook runs (skills, CLI docs, board page, go.mod tidy, fmt, vet, lint)
make ci             # check plus tests, smoke, and the contract and hook-env checks (CI runs this)
scripts/worktree.sh add <name> [<base-ref>]  # detached worktree under ~/workspace/agent-message-queue-wt
scripts/worktree.sh remove <name>            # remove only when git reports no modified or untracked work
make check-skills   # validate canonical and symlinked skill content

Formatting and lint require the Go toolchain pinned in go.mod and the golangci-lint version pinned in the Makefile; other versions are refused.

Architecture

One line per package group (internal/archtest enforces layering on the import graph: only cmd/amq links internal/cli, and internal/remote does not link internal/acp):

cmd/                    amq (CLI), amq-board (fleet snapshot), amq-remote & amq-owner-sign (remote sessions), amq-bridge (cross-host courier), amq-acp (preview ACP v2), amq-keepalive (macOS wake supervisor)
core queue              internal/{fsq,format,lock,ownedfile,receipt,followup,thread,presence,roster,config,amqhome,exitcode}
CLI & routing           internal/{cli,route,sessionguard,agentidentity,claudeidentity,codexidentity,execidentity,writerlock}
wake & terminal         internal/{harness,dialogguard,desktopnotice,notificationattempt,wakecmd,wakelock,terminalrelay,hookfile,selfupgrade,update,semver}
launch & supervision    internal/{launch,codexlaunch,keepalive,loginservice}
fleet board & usage     internal/{board,usagecache,usageformat,usagehold,usagenormalize,usagetransport}
companions & bridges    internal/{remote,relay,claudepeer,bridge,acp,swarm,integration}
layering & test         internal/{archtest,testenv}

Mailbox layout:

<root>/agents/<agent>/{inbox/{tmp,new,cur},outbox/sent,receipts,receipts-pending,follow-ups,dlq/{tmp,new,cur}}/
<root>/bridge/{host-id,identity,trusted/<host>,outbox,drop,receipts}/

Core Contracts

  • Beads: tasks come from Beads, the issue tracker this repository uses; a bead is one work item with an id like agent-message-queue-abcd, and the board links a pull request to its bead via the bead's external_ref: gh-N or the PR's Bead: <id> trailer.
  • Atomic delivery & format: writers create and sync in tmp, then rename into new; readers scan new and cur. Messages are JSON frontmatter, ---, and Markdown body; P2P threads use p2p/<lower>__<higher>.
  • Message kinds & handoffs: see message kinds and send useful handoffs; send the initiator the result and the evidence for the specific request.
  • Receipts: consumers write drained or dlq receipts under their own mailbox (receipts list|wait, send --wait-for). A receipt write failure after a committed claim is parked in receipts-pending/ only when the park write succeeds; the command still prints the payload and returns an error, and the next drain, read, or monitor writes the receipt without delivering the message again. A crash before parking or a failed park write leaves the receipt unwritten.
  • Follow-ups: --follow-up, --news-within, and --reminder-notify arm one inbox notice; see amq-cli skill, message format, and CLI reference.
  • DLQ: corrupt messages move to DLQ with a dlq receipt; delivered is terminal/idempotent, pending/indeterminate without a visible inbox refuses retry even with --force (which bypasses only the retry-count cap). See operations.
  • Sessions: child queue roots pinned by AM_ROOT, AM_BASE_ROOT, and AM_SESSION with managed tokens; fail closed on mismatch. Route with --session or --project, not a foreign raw --root. See session-routing.md.
  • Wake & doctor: wake ownership, targets, lifecycle, readiness, and repair have separate commit domains; never weaken uncertain state. Run amq wake check --me <agent> --json before wake mutation — the check is read-only advice, only restart_capability=agent_safe permits an agent to act, and repair, recover-owner, and retire each have distinct scopes and independently revalidate exact process, target, generation, root, and owner identity before mutating. Doctor mutation requires the authenticated pinned base or --root --ignore-session-pin. See wake-operations.md, wake-state-invariants.md, and wake-doorbell-acknowledgement.md.
  • Managed launch recovery: mode-0600 journal closes create-before-binding; uncertain/partial state is action-required and preserved. See launch-recovery.md.
  • Extension metadata & companions: layer data lives under extensions/<layer>/ (adr-layer-extensions.md). See also adapter contract, two-host fleets, bridge protocol, wake capability vector, remote control, remote compat, amq-remote, amq-acp, and amq-board.

Configuration

  • Four scopes: agent (<root>/agents/<me>/), root (<root>/meta/), project (.amqrc, .amq/launch.json), and user (~/.amq/ via internal/amqhome; no feature joins its own home path).
  • Hot-reload rule: every long-running process must hot-reload its configuration without restart, keep the last good value on a refused edit, and keep identity bound into locks, targets, or resume state (--me, --root, --inject-*) restart-only. Do not add configuration that a running process reads only at startup; which processes reload what is in configuration.md.

CLI Surface and Coordination

Use docs/cli.md or amq <command> --help for exact flags.

AreaCommands
Onboarding & sessionssetup, launch, session create|list|resume, env, who, shell-setup, completion
Messaging & threadssend, reply, handoff, list, read, drain, thread [open|list|settle], trace, receipts list|wait, watch, monitor
Routing & presenceroute explain|peers, peer pair, presence set|list
Health, wake & DLQdoctor, cleanup, upgrade, wake [check|config|repair|restart|recover-owner|retire|dialog|install-dialog-hook|uninstall-dialog-hook], dlq list|read|retry|purge
Provisioning & extrasinit, coop init|exec|join|leave|install-hooks|uninstall-hooks|hook, swarm ... (bridge to Claude Code Agent Teams; a teammate still needs the team leader to relay AMQ messages), integration symphony|kanban
  • Exit codes: 0 success, 1 general error, 2 usage, 3 not found, 4 timeout, 5 context mismatch, 6 action required (--json preserves exit codes). amq handoff with the sender as the reviewer is a usage error (exit 2).
  • --json-schema requires --json and is supported by amq doctor and amq wake check (1 or 2, default 1), and by amq thread open and amq thread settle (1).
  • send and reply resolve --body from a literal, @file, or stdin; empty or whitespace-only input is a usage error unless --allow-empty is passed.
  • During active work, run amq drain --for-turn between phases, reply to the initiator on the existing thread, use send --wait-for drained when delivery proof matters, and never run watch while a wake is live. Full workflow: COOP.md, amq-cli skill, and amq-spec skill.

Testing

Run tests of changed packages, narrowest first (make test uses a scratch HOME). A child fixture takes its write destination from its parent and refuses without it, so a test run by hand with a child selector needs no scratch HOME. Opt-in live proofs (AMQ_*_LIVE=1) are documented in CONTRIBUTING.md. Bash SessionStart hook-script tests in internal/keepalive/hookinstall require AMQ_HOOK_SCRIPT_TESTS=1 and run serially with -p 1.

Two kinds of test exist:

  1. One small happy-path test per user-visible behavior ships in the same PR.
  2. A regression test for an observed field, CI, or review defect ships with the fix and reproduces that failure and nothing more; its comment names the bead, review finding, or CI run it came from.

Both must be deterministic and fast (under 5 s, no child process, no network) unless the defect lives at that boundary. Do not add speculative negative cases, mutation demonstrations, guard tests about tests, or tests for existing behavior with no observed defect. Delete or rewrite slow or flaky tests to this bar. Before adding a test, name the contract it protects, the regression that fails it, and why existing coverage misses it; add rows to existing tables rather than duplicating them. Do not add production flags, env vars, exports, or wrappers solely for tests (named fault-injection/crash-point seams are permitted only when no production code path sets or reads them). Verify every regression test fails on pre-fix code before shipping.

Security

  • Queue directories are mode 0700, files 0600; handle/ID validation blocks path traversal.
  • send and reply warn on unregistered handles (handles not in a base or session roster and with no identity record). With --strict, send and reply turn unregistered handles and unreadable/corrupt config into errors, and other commands refuse handles missing from config.json.
  • External injector executable plus ordered fixed args form its saved identity; message-derived payloads are sanitized.
  • Preserve uncertain ownership or filesystem state; never add a force path that guesses at process, target, generation, or owner identity.

Commit, Doc, and Skill Conventions

  • Install hooks with ./scripts/install-hooks.sh. Use conventional commits (fix(wake): ...), run focused tests before committing, and follow pushed CI runs to completion.
  • Never commit placeholders, weaken validators, regenerate goldens to hide a defect, or split code from its test.
  • PR titles, bodies, and commits state the user-visible change and reason (at most one trailing bead/finding reference; no review-round narration). Test names describe behavior, not bead ids. Production comments state invariants, not provenance.
  • Docs: README.md (onboarding), INSTALL.md (install/companions/platforms), COOP.md (co-op/fleet operations), CLAUDE.md (agent contract/index), docs/ (evergreen architecture, contracts, and operational references in present tense; put a known limitation as one sentence beside an issue link; no historical narration; plans and frozen specs belong in issues, PRs, or the AMQ spec workflow).
  • Skills: canonical directories live in skills/{amq-board,amq-cli,amq-lead,amq-remote,amq-spec}/ (.claude/skills/, .agents/skills/, .grok/skills/ are symlinks). Edit canonical directories only, do not create divergent copies, and run make check-skills; project skills take precedence over user installations. Skill version fields are owned by the release (Release Please markers); do not edit them by hand.

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.