Hook Integration

Connect coop to your AI coding tool.

The hook integration has two parts: a poll hook for receiving messages and a /coop command for sending them. Both are installed with a single CLI command.

Install

coop hook install

This does two things:

  1. Writes a poll hook to ~/.claude/settings.json that fires on UserPromptSubmit and SessionStart
  2. Writes the /coop slash command to ~/.claude/commands/coop.md

How the poll hook works

Every time you submit a prompt in your AI coding tool, the hook runs:

coop session poll --format=hook --mark-read 2>/dev/null || true

It:

  1. Reads the tool's stdin to get the current session_id
  2. Polls your enrolled session(s) for unread messages
  3. Returns additionalContext injected as environment context
  4. Marks messages as read so they don't appear again

If there are no messages, the hook returns {} and the tool sees nothing extra.

The hook uses || true and a 5-second timeout. Network failures never block your AI coding tool.

What your tool sees

When messages exist, they appear as context before your tool processes your prompt:

## Coop Notifications

### From @alice in feature-auth (2m ago)
> The auth middleware needs token refresh handling.
> I've added a stub in src/middleware/auth.ts:42.

---
Reply: `coop session send feature-auth "message"` or use /coop

How /coop works

Type /coop in your AI coding tool to send a message. Your tool will:

  1. Read the current conversation to understand what you've been working on
  2. Compose a concise, actionable summary (under 2000 chars)
  3. Show you the message and ask for confirmation
  4. Run coop session send to deliver it

You can also pass arguments: /coop tell alice the auth fix is ready — your tool will use your input to compose the message.

Verify installation

$ coop hook status
Poll hook — user scope (~/.claude/settings.json): installed
Poll hook — project scope (.claude/settings.json): not installed
/coop command (~/.claude/commands/coop.md): installed

Uninstall

coop hook uninstall

Removes the poll hook from settings.json and deletes the /coop command file. Other hooks and commands are preserved.

Project-scoped hooks

By default, hooks are installed at user scope (~/.claude/settings.json). To install at project scope instead:

coop hook install --scope project

This writes to .claude/settings.json in the current directory. Note: the /coop command is always installed at user scope since slash commands are user-level.

Next: Sending Messages →