The SessionStart announce no longer forces a watch-loop bootstrap on every session — it now emits a short pointer instructing Claude to invoke the new mailbox-collaborate skill (or /collaborate slash command) when the user wants peers to wake them mid-task. Messages still surface on the next user prompt via the UserPromptSubmit hook even without the watcher, so nothing is lost; idle sessions just stop burning relaunch tokens. The watch-loop protocol (exit codes, rename handling, mail handling) moves from the hook prose into the new skill body, where it only loads when actually needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
2.2 KiB
Markdown
38 lines
2.2 KiB
Markdown
---
|
|
name: mailbox-collaborate
|
|
description: Start the Claude-Mailbox push-delivery watch loop for this session so peers can wake Claude mid-task. Use when the user says "let's collaborate", "wait for mail", "watch the mailbox", "listen for peers", "enter collaboration mode", or invokes /collaborate. Without this skill the watcher is OFF — peers can still leave messages but Claude only sees them on the next user prompt. Do NOT launch the watcher without this opt-in.
|
|
---
|
|
|
|
You are now in **mailbox collaboration mode**. Peers can wake you mid-task by sending mail to your mailbox.
|
|
|
|
## Launch the watcher
|
|
|
|
Your mailbox name was announced at SessionStart (format: `<project>-<short-session-id>`). Use it in place of `<NAME>` below.
|
|
|
|
Launch the watcher as a background bash task immediately:
|
|
|
|
```
|
|
Bash(command="claude-mailbox watch --block --name <NAME>", run_in_background=true)
|
|
```
|
|
|
|
The watcher is short-lived by design — it exits after exactly one event (delivered message, 25-second timeout, rename, or daemon error). Claude Code's BashOutput notifications fire only on task completion, so every exit MUST be followed by a fresh background relaunch with the same command. Gaps in the loop = missed pushes.
|
|
|
|
## Handling watcher completions
|
|
|
|
When a watcher task completes, inspect its stdout and exit code:
|
|
|
|
- **stdout contains `[Claude-Mailbox] Mail from <peer>: <body>`** → treat the body as an inbound interrupt with priority over your current plan. Address it, then relaunch the watcher.
|
|
- **stdout contains `[Claude-Mailbox] Mailbox renamed to '<new>'`** → relaunch with `--name <new>`, and use `<new>` for all future `mcp__mailbox__*` calls (update your identity).
|
|
- **exit code 3 with no stdout** → silent timeout, just relaunch.
|
|
- **exit code 2** → daemon unreachable; wait ~5 seconds, then relaunch.
|
|
- **any other exit code** → report it to the user, then relaunch.
|
|
|
|
## Stopping
|
|
|
|
Keep the loop running until the user says "stop watching", "stop collaborating", "end collaboration", or similar. When they do:
|
|
|
|
- Stop relaunching after the next completion.
|
|
- If a watcher is currently mid-poll and the user wants it killed immediately, use `TaskStop` on its task id.
|
|
|
|
Do not re-enter collaboration mode on your own after stopping — wait for the user to invoke this skill again.
|