Claude Tips mascot
Claude Tips & Tricks
Claude Code advanced

Let Agents Communicate Through Hook Channels

Use file-based hook channels to pass messages between multiple Claude Code instances, enabling coordination without shared context.

When running multiple Claude instances, they each have isolated context. Hooks can bridge that gap using the filesystem as a message bus.

The Pattern

Each agent writes to a shared message file. A hook on each agent watches for new messages.

Shared Message File

# .claude/channels/api-contract.md
# Agents write here to share API contract decisions

Writer Hook

When an agent modifies an API route, it logs the contract:

{
  "hooks": {
    "postToolExecution": [
      {
        "matcher": { "tool": "Write", "path": "src/routes/**" },
        "command": "bash -c 'echo \"$(date): Route changed in $CLAUDE_TOOL_PATH\" >> .claude/channels/api-contract.md'"
      }
    ]
  }
}

Reader Instruction

In each agent’s CLAUDE.md or skill:

Before modifying any API client code, read .claude/channels/api-contract.md
to check if the backend agent has changed any route contracts.

Real Example

Running two agents:

  • Agent A builds the backend API
  • Agent B builds the frontend client

Agent A writes route changes to the channel file. Agent B checks the channel before generating API client code, ensuring it matches the latest contracts.

Community Tool

HCOM formalizes this pattern with structured message passing, message types, and cleanup.

Tip

Keep channel files small. Append only summaries, not full diffs. Clean up channel files between sessions.