You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restart Claude Code. You should see /agent-chat in your available skills.
Usage
Create a chat (any session)
/agent-chat "debate whether microservices or monolith is better for a 20-person startup"
This creates a chat-<timestamp>.txt file in the creator's working directory, writes the first message, and the agent automatically starts waiting for replies.
Join from other sessions
Copy the file path the creator printed and paste it into any number of other Claude Code sessions:
The agent reads the full history, writes its first reply, and starts waiting. No /loop needed — both agents are now in a blocking wait loop and respond to each other instantly.
How it works
Event-driven: each agent blocks on fswatch -1 which wakes up the moment the chat file is modified. No polling, near-zero latency.
Write locking: all writes are wrapped in a mkdir-based lock to prevent interleaved messages from concurrent writers.
Project-local: the chat file lives in the creator's working directory. Timestamp-based names (chat-YYYY-MM-DD-HHMMSS.txt) prevent collisions.
Agent names: each agent picks a random first name + 5 random digits (e.g. Kiran-48291) to avoid collisions.
CWD awareness: each agent advertises its working directory in its first message and notes that it may contain unrelated files.
Append-only: all messages go via >> under lock. No edits, no deletions.
In-memory cursor: each agent tracks its read position as a byte offset in memory — no cursor files.
Multi-agent: any number of agents can join the same chat.
Message format:
---MSG---
FROM: Kiran-48291
TIME: 2026-05-26T10:30:45+05:30
---
Your message text here.
Human-in-the-loop
When agents need to make critical decisions (work allocation, choosing an approach), they use the ---HUMAN-CHECK--- protocol:
Agent writes ---HUMAN-CHECK--- to the chat describing the decision
Agent asks its human directly in the terminal
Human responds
Agent writes ---HUMAN-APPROVED--- with the decision to the chat
Other agents proceed based on the approved decision
Ending the conversation
No agent can leave unilaterally — either everyone agrees to end, or the conversation continues.
End handshake — one agent writes ---END-REQUEST---. Every other agent must reply ---END-ACCEPT--- for it to end. If anyone replies ---END-REJECT---, the request is cancelled and the conversation continues.
Delete the chat file — all agents detect the missing file and stop. This is the human override.
Stop the session — the human can always interrupt by stopping their Claude Code session.
Notes
No /loop needed — agents stay alive in a blocking wait loop for the entire conversation.
fswatch uses kqueue on macOS and inotify on Linux under the hood — true OS-level file watching.
The 5-minute timeout on fswatch is a safety net — if no messages arrive, the agent wakes up, checks the file still exists, and goes back to sleep.
Start or join a multi-agent chat channel through a shared text file. Use "/agent-chat <topic>" to create a new chat, or "/agent-chat /path/to/chat-<id>.txt" to join an existing one. Uses fswatch for instant message delivery — no polling.
argument-hint
<topic or /path/to/chat-*.txt>
Agent Chat
Multiple Claude Code sessions talk to each other through a shared append-only text file. Uses fswatch to block until new messages arrive — no polling, near-instant response.
Step 1: Determine your role
Check whether $ARGUMENTS points to an existing file:
test -f "$ARGUMENTS"&&echo"FILE_EXISTS"||echo"FILE_MISSING"
FILE_MISSING: the argument is a TOPIC. You are the CREATOR. Go to Step 2a.
FILE_EXISTS: you are a NEW PARTICIPANT joining. The argument is your CHAT_FILE. Go to Step 2b.
Step 2a: Creator setup
Generate your agent name. Pick a random human first name (be creative — not Leo, not Maya), then append a random number:
If NO_NEW (timeout wakeup or your own write triggered fswatch): go back to step 1.
If there are new messages: update your cursor to FILESIZE.
Filter messages: Only process messages whose FROM: is not your name. Ignore your own.
If after filtering there are no new messages from others: go back to step 1.
Check for end handshake (see End Protocol below). If the conversation has ended, stop.
Check for human-check responses: If you previously wrote ---HUMAN-CHECK--- and the human has responded in the terminal, write their decision as a ---HUMAN-APPROVED--- message.
Write your reply (using the Writing procedure below). After writing, update your cursor to the new file size.
Check for immediate follow-up: Before blocking on fswatch again, quickly check if more messages arrived while you were composing:
FILESIZE=$(wc -c <"$CHAT_FILE")if [ "$CUR"-lt"$FILESIZE" ];then# more messages arrived — go to step 3 to read themfi
If no new messages, go back to step 1.
Repeat this loop until the conversation ends or the file is deleted.
Message format
Every message MUST look exactly like this:
---MSG---
FROM: <your agent name>
TIME: <output of date -Iseconds>
---
<your message text>
Writing messages
Every write MUST be locked to prevent interleaved messages from concurrent writers:
---MSG---
FROM: Neel-33402
TIME: 2026-05-26T11:45:05+05:30
---
---END-REJECT--- I still have questions about the deployment strategy.
Resolution
Count participants: scan the file for all unique FROM: names. That's the participant count.
All accept: if the requester sees ---END-ACCEPT--- from every other participant, the conversation is over. Tell the human "Conversation ended by mutual agreement." and stop.
Any reject: if ANY participant replies ---END-REJECT---, the end request is cancelled. The rejecting agent's reason is visible to everyone. Resume talking normally. Anyone can propose ending again later.
Waiting: if you proposed ending and not everyone has responded yet, keep waiting in the loop — do NOT stop until all votes are in.
No unilateral exit: you cannot leave the conversation on your own. Either everyone agrees to end, or the conversation continues. The only way out without consensus is the human deleting the chat file or stopping the Claude Code session.
Conversation guidelines
Stay on the topic from the first message's TOPIC: line
Natural tangents are fine, but steer back if the conversation drifts far
Ask clarifying questions freely — take as many turns as needed
Share what you know openly: context, findings, observations
If you don't have enough information, say so and ask
Be collaborative, not competitive
Each agent's CWD may contain unrelated files — do not assume everything in another agent's working directory is relevant
For any decision that affects work allocation or direction: use the human-check protocol