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…
In this repository5 other files it gives its agents.
- amq-boardSkill
- amq-cliSkill
- amq-leadSkill
- amq-remoteSkill
- amq-specSkill
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
- Distinctive: line 33
Never create release branches, tags, or GitHub releases manually.
- Very specific: line 34
Keep one version across CHANGELOG.md, .release-please-manifest.json, and skill/plugin metadata.
- Very specific: line 38
Keep io.github.avivsinai.<binary> identifiers and never add a re-sign step to the Homebrew formula.
- Distinctive: line 44
Use the CLI for mailbox operations.
- Very specific: line 45
Use amq cleanup for mailbox retention and amq dlq purge for an explicit dead-letter purge.
- Very specific: line 155
Hot-reload rule: every long-running process must hot-reload its configuration without restart, keep the last good value on a refused edit, …
- Very specific: line 164
Use docs/cli.md or amq <command> --help for exact flags.
- Very specific: line 191
Run tests of changed packages, narrowest first (make test uses a scratch HOME).
- Distinctive: line 235
Never commit placeholders, weaken validators, regenerate goldens to hide a defect, or split code from its test.
≈ “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
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; useBEGIN_COMMIT_OVERRIDEfor 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 cleanupfor mailbox retention andamq dlq purgefor an explicit dead-letter purge. Logs and derived extension caches have documented bounds. - AMQ remains daemon-free. Supervisors can run
wakeormonitor, 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 contentFormatting 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'sexternal_ref: gh-Nor the PR'sBead: <id>trailer. - Atomic delivery & format: writers create and sync in
tmp, then rename intonew; readers scannewandcur. Messages are JSON frontmatter,---, and Markdown body; P2P threads usep2p/<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
drainedordlqreceipts under their own mailbox (receipts list|wait,send --wait-for). A receipt write failure after a committed claim is parked inreceipts-pending/only when the park write succeeds; the command still prints the payload and returns an error, and the nextdrain,read, ormonitorwrites 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-notifyarm one inbox notice; see amq-cli skill, message format, and CLI reference. - DLQ: corrupt messages move to DLQ with a
dlqreceipt;deliveredis terminal/idempotent,pending/indeterminatewithout 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, andAM_SESSIONwith managed tokens; fail closed on mismatch. Route with--sessionor--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> --jsonbefore wake mutation — the check is read-only advice, onlyrestart_capability=agent_safepermits an agent to act, andrepair,recover-owner, andretireeach 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/viainternal/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.
| Area | Commands |
| Onboarding & sessions | setup, launch, session create|list|resume, env, who, shell-setup, completion |
| Messaging & threads | send, reply, handoff, list, read, drain, thread [open|list|settle], trace, receipts list|wait, watch, monitor |
| Routing & presence | route explain|peers, peer pair, presence set|list |
| Health, wake & DLQ | doctor, cleanup, upgrade, wake [check|config|repair|restart|recover-owner|retire|dialog|install-dialog-hook|uninstall-dialog-hook], dlq list|read|retry|purge |
| Provisioning & extras | init, 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:
0success,1general error,2usage,3not found,4timeout,5context mismatch,6action required (--jsonpreserves exit codes).amq handoffwith the sender as the reviewer is a usage error (exit2). --json-schemarequires--jsonand is supported byamq doctorandamq wake check(1or2, default1), and byamq thread openandamq thread settle(1).sendandreplyresolve--bodyfrom a literal,@file, or stdin; empty or whitespace-only input is a usage error unless--allow-emptyis passed.- During active work, run
amq drain --for-turnbetween phases, reply to the initiator on the existing thread, usesend --wait-for drainedwhen delivery proof matters, and never runwatchwhile 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:
- One small happy-path test per user-visible behavior ships in the same PR.
- 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, files0600; handle/ID validation blocks path traversal. sendandreplywarn on unregistered handles (handles not in a base or session roster and with no identity record). With--strict,sendandreplyturn unregistered handles and unreadable/corrupt config into errors, and other commands refuse handles missing fromconfig.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 runmake 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.
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.

