Allow two AI coding harnesses (Grok Build, Claude Code, Codex, …) to send messages to each other, while they are running in different terminals in the same project folder.
How it works: internally, everything is managed in a clever way(*) in a sub-folder .amx/ in your project. Agents will run the amx command to read/write files there. No server, no need to pip install or run anything in advance.
(*) Credit to avivsinai's AMQ, which is MUCH more full-featured.
(Full rules for implementers: notes/SPEC.md.)
Requirements: Linux only for now (uses /proc and renameat2); both agents must work in the same project folder on the same machine.
Quick setup = done once, easily reversible, no changes to your machine, no pip install etc.
You merely want your agents/harnesses to: 1) be able to run the amx command whenever they want to; and 2) know when to run it (a "skill").
→ So:
- To be able to run
amx, without "installing" anything or making any configuration changes to your machine:
-
Copy this repository's contents to somewhere on your filesystem.
-
Ensure our
bin/amxcommand is executable:chmod +x path/to/bin/amx -
Add it to your
PATHin your preferred way.- Tip: if you already have
~/.local/bininPATH, then add a symlink that you can always simply delete later:ln -s path/to/bin/amx ~/.local/bin/amx
- Tip: if you already have
-
Test it by simply running
amx --versionfrom anywhere. You can already perform the "Quick feel" below if you want.
- As for the agents "knowing" when to run the
amxcommand to communicate with each other: simply add our skill (skills/amx/SKILL.mdin this repo) to your AI coding harness(es).
- Not sure how to add a skill? Ask your coding harness: "How do I add a skill? I have a
SKILL.mdfile."- FYI, this is harness-specific, but usually simply means to copy that file into
.grok/skills/amx/, if using Grok Build; or into.claude/skills/amx/, if using Claude Code; etc.
- FYI, this is harness-specific, but usually simply means to copy that file into
Done.
(Go to "Quick feel" if you want to get a feel for how your agents/harnesses would work with it to send messages to each other!)
pyproject.toml is set up so a normal editable install can work. Prefer a venv if you try it, so you do not touch system or user site-packages:
#cd /path/to/this/repo/
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
amx --version
# → amx 0.1.0What that does:
- Installs
amxinto the active Python environment from this repo (editable: code stays insrc/). - Adds an
amxcommand in that environment’sbin/.
How to undo:
pip uninstall amx
deactivate # leave the venv
# optional: rm -rf .venvLet's test/experiment/illustrate the amx usage, using two terminals:
- In one Terminal (herein "Terminal A"), create a temporary directory
~/some-dirfor the sake of this experiment, and "identify" this terminal asalice:
# (in Terminal A)
mkdir ~/some-dir
cd ~/some-dir
amx login alice
# → logged in as alice (…)
# (Note: this has also created an .amx/ folder; feel free to `cd` into it and explore it!)
amx whoami
# → alice (…)- Open another terminal ("Terminal B"), and run in it:
# (in Terminal B)
cd ~/some-dir
amx login bob
# → logged in as bob (…)
amx send alice "Hello from bob"
# → sent <some-message-id> to alice- Back in Terminal A, let's read
bob's message and reply to him:
# (in Terminal A)
amx drain
# → --- <id> from=bob at=… thread=p2p/alice__bob
# → Hello from bob
amx reply <paste-the-id-here> "thanks bob"- And similarly,
bobfrom Terminal B can seealice's reply:
# (in Terminal B)
amx drain
# → should show alice’s replyThe common workflow with amx:
- You have two harnesses running in two separate terminals. Both terminals are working in the same project folder + have
amxonPATH+ have the skill (skills/amx/SKILL.md; see Quick setup).- E.g. you run
grokin one terminal,piin the other. - Or maybe
AMX_TERMINAL_ID=term-1 grokandAMX_TERMINAL_ID=term-2 pi, see "Limitation: login might not stick" below.
- E.g. you run
- You work normally. Then you decide to log in as
alicein one terminal,bobin the other, and send messages back and forth as needed. Use natural language, like: “log in as alice”, “ask bob to review this file”, or even “use the amx skill to check for messages from other members and reply to them”, etc.
That's it.
Advanced notes + behind the scenes:
- The skill makes the agent run
amxfor you. - That said, it may sometimes make sense to run commands yourself if you want (essentially the "Quick feel" section), e.g.
amx login alice,amx whoami,amx who,amx logout. - Usually you will NOT want to run
amx drainyourself, because the harnesses/IDEs typically do not include the output of your commands in the context of the conversation. (Well, unless you only intended to see those messages yourself) - If you wanted, you can in theory
login alice, thenlogout, thenlogin bob, all in the same session. Your identity asaliceorbobis indepedent of the "terminal id". - Limitation: If your login as
alicedoes not "stick" to the next command (see below), then you'd have to explicitly set the environment variableAMX_TERMINAL_IDwith a "terminal id" to identify your terminal with, and only then run your harness. E.g. runAMX_TERMINAL_ID=term-1 grokinstead of justgrok.
What: If you log in as alice, but in the next turn whoami says that you're not logged in, don't fret. For some hosts this is expected; use the fix below.
Why this happens: (technical details that you can skip)
- Some harnesses start a new short-lived shell for every command. This causes a
loginin one "turn" to be gone by the next, which breaks the workflow. In addition, some non-standard terminals, likeGhostty, do not have a "stable terminal id" that we can use to identify them uniquely. - Ubuntu's built-in Terminal has a stable terminal id by itself (some env var). Devin (Windsurf) Desktop also has a rather stable "terminal id", but only per Window.
Easy fix: if you're using a non-standard terminal where your login does not stick, explicitly set a "terminal id" before you start the harness, e.g. export AMX_TERMINAL_ID=term-1 and then start the harness (e.g. grok) in that shell. Or even a simpler one-liner: AMX_TERMINAL_ID=term-1 grok.
Much less recommended workaround: ...or tell your agent to prepend each tool with amx login … again.
| Goal | Command |
|---|---|
| Log in / out | amx login alice / amx logout |
| Who am I in this terminal? | amx whoami |
| Which names exist, and who holds them? | amx who |
| Any new mail? (leaves mail in place) | amx pending, or amx pending --verbose |
Read new mail (moves each message to cur/) |
amx drain |
| Send a message | amx send bob "…" |
| Reply to a message | amx reply <id> "…" |
Also: amx --help.
Mail files live under .amx/ in the project (created automatically). You can look at them with ls / cat if you want. The commands above suffice for day-to-day use.
Wrong project / no peers?
amx looks for a .amx/ directory upward from the current directory (or uses AMX_ROOT if you set it). Always cd to the shared project first.
“Handle already claimed” If another terminal still holds the name alice and you really want to be alice, you can claim it by force: amx login --force alice
Old mail
drain only shows new messages (and moves them to inbox/cur/). To re-read old ones, cat files under .amx/agents/<you>/inbox/cur/ or .amx/agents/<you>/outbox/sent/.
Faking two terminals You could in theory fake two terminal ids in one shell if you really wanted to: (for debugging? rather a weird usecase, because you can always simply login/logout from the same terminal)
AMX_TERMINAL_ID=term-1a amx login alice
AMX_TERMINAL_ID=term-1b amx login bob
AMX_TERMINAL_ID=term-1b amx send alice "hi"
AMX_TERMINAL_ID=term-1a amx drain- "Pull", not "push": The peer must actively check mail (
pending/drain), or you ask them to. - Same machine, same project folder only.
nudgebackground process +mute/unmute(so the peer can be woken when mail arrives).