Hook adapter for Claude Code, Codex CLI, and OpenCode that bridges agent lifecycle events to the Moshi API, which fans out push notifications to update the Live Activity on your iPhone.
Claude Code → hooks (stdin) → moshi-hooks → Moshi API → APNs → Live Activity
Codex CLI → notify (argv) → moshi-hooks → Moshi API → APNs → Live Activity
OpenCode → plugin (spawn) → moshi-hooks → Moshi API → APNs → Live Activity
Requires Bun. Zero runtime dependencies.
bun i -g moshi-hooksOr run directly without installing:
bunx moshi-hooks setupFirst, set your Moshi API token:
moshi-hooks token <YOUR_TOKEN>moshi-hooks setup # user scope (~/.claude/settings.json)
moshi-hooks setup --local # user scope (~/.claude/settings.local.json, not committed)
moshi-hooks setup . # project scope (.claude/settings.json in cwd)
moshi-hooks setup --local . # project scope (.claude/settings.local.json in cwd)moshi-hooks setup --codex # writes notify config to ~/.codex/config.tomlmoshi-hooks setup --opencode # generates plugin at .opencode/plugins/moshi-hooks.tsmoshi-hooks uninstall # Claude Code (settings.json)
moshi-hooks uninstall --local # Claude Code (settings.local.json)
moshi-hooks uninstall --codex # Codex CLI
moshi-hooks uninstall --opencode # OpenCodeAll setup/uninstall commands are idempotent and preserve existing hooks from other tools.
| Hook Event | eventType | category | Sends to API? |
|---|---|---|---|
SessionStart |
— | — | No (persists model to state file) |
Stop |
stop |
task_complete |
Yes (visible push) |
SubagentStop |
agent_turn_complete |
info |
Yes (visible push) |
Notification |
notification |
approval_required |
Yes (visible push) |
PreToolUse |
pre_tool |
tool_running |
Yes, filtered (silent) |
PostToolUse |
post_tool |
tool_finished |
Yes, filtered (silent) |
UserPromptSubmit |
— | — | No (skipped) |
Tool events are filtered to only fire for: Bash, Edit, Write, WebFetch, WebSearch, Task.
| Codex event | eventType | category |
|---|---|---|
agent-turn-complete (notify) |
stop |
task_complete |
| OpenCode event | eventType | category |
|---|---|---|
tool.execute.before |
pre_tool |
tool_running |
tool.execute.after |
post_tool |
tool_finished |
session.idle |
stop |
task_complete |
permission.updated |
notification |
approval_required |
Each hook invocation is a separate process. Claude Code pipes JSON to stdin, Codex passes JSON as an argv argument, and OpenCode spawns moshi-hooks from a generated plugin file.
Cross-event state is persisted to /tmp/moshi-hook-{session_id}.json so that later events (like Stop) can include the model name and last tool from earlier events.
Context window usage is estimated by reading the last ~10KB of the transcript JSONL and parsing the most recent usage data.
bun testbun typecheck