Skip to content

Claude Code Integration

Séance integrates with Claude Code through wrapper scripts and shell hooks. Claude Code is the only agent that uses session-level status tracking.

How It Works

Claude Code doesn't use a TypeScript plugin. Instead, Séance:

  1. Intercepts launch via a wrapper script in resources/bin/claude-code
  2. Injects hook commands into Claude Code's hook system via ~/.claude/settings.json
  3. Receives events through the Unix socket as Claude Code runs

Hook Events

Claude Code EventSéance HookWhat It Shows
SessionStartsession-startRunning
UserPromptSubmitprompt-submitRunning
PreToolUsepre-tool-useRunning
PostToolUsepost-tool-useRunning
PermissionRequestnotificationNeeds input
NotificationnotificationNeeds input
StopstopIdle
SessionEndsession-end(cleared)

Features

  • Permission detection — shows "Waiting for permission" when Claude Code asks to run a command
  • Session tracking — tracks session lifecycle from start to end
  • Desktop notifications — notifies on completion and permission requests
  • Focus suppression — notifications don't steal focus when your terminal is active

Limitations

  • Session-level status — Claude Code uses session-level tracking, meaning status is shared across all surfaces in a workspace. If you have two Claude Code sessions in the same workspace, the status panel shows whichever updated last. Other agents (OpenCode, Kilo, MiMo Code) use per-surface tracking, where each terminal has independent status.

  • No subagent tracking — Claude Code fires SubagentStart/SubagentStop events, but Séance doesn't handle them yet. The sidebar won't show subagent activity indicators.


For Contributors

Integration Approach

Claude Code is the only agent that does not use a TypeScript/Python plugin. Instead, Séance integrates through two mechanisms:

  1. Wrapper script (resources/bin/claude) — intercepts claude launches inside Séance terminals. Discovers the real claude binary, exports SEANCE_CLAUDE_PID, and fires session-end on exit via trap ... EXIT.

  2. Shell hooks via settings.json — Séance injects hook commands into ~/.claude/settings.json (the hooks array). Claude Code fires these hooks during its lifecycle, which call back to seance ctl claude-hook.

This approach is necessary because Claude Code's hook system is configured via JSON, not a plugin API.

Event Mapping

Claude Code EventSeance HookUI Status
SessionStartsession-startRunning
UserPromptSubmitprompt-submitRunning
PreToolUsepre-tool-useRunning
PostToolUsepost-tool-useRunning
PermissionRequestnotificationNeeds input
NotificationnotificationNeeds input
StopstopIdle
SessionEndsession-end(cleared)

Key Implementation Details

  • Status mode: Session-level. Status key prefix claude, mode session. All other agents use surface-level mode.
  • clear_status_on_end is true — status clears on session-end.
  • has_notification_hook is true — notifications fire on permission requests and completions.
  • Auto-install: Hook injection modifies ~/.claude/settings.json via the auto-install mechanism in src/app.zig.
  • Wrapper script: resources/bin/claude. Passes through if SEANCE_SURFACE_ID is not set (not running inside Séance).

Upstream Framework Events

Source: docs.anthropic.com/en/docs/claude-code/hooks

Claude Code has a comprehensive hook system with many more event types than the OpenCode/Kilo family:

EventDescriptionSéance Handles?
SessionStartSession begins or resumesYes
SessionEndSession terminatesYes
UserPromptSubmitUser submits a promptYes
UserPromptExpansionSlash command expands to promptNo
StopClaude finishes respondingYes
StopFailureTurn ends due to API errorNo
PreToolUseBefore tool call executesYes
PostToolUseAfter tool call succeedsYes
PostToolUseFailureAfter tool call failsNo
PostToolBatchAfter parallel tool batch resolvesNo
PermissionRequestPermission dialog appearsYes
PermissionDeniedTool call denied by auto-modeNo
SubagentStartSubagent spawnedNo
SubagentStopSubagent finishesNo
TaskCreatedTask created via TaskCreateNo
TaskCompletedTask marked completedNo
NotificationClaude Code sends notificationYes
MessageDisplayAssistant message text displayedNo
PreCompactBefore context compactionNo
PostCompactAfter compaction completesNo
WorktreeCreateWorktree being createdNo
WorktreeRemoveWorktree being removedNo
TeammateIdleTeammate about to go idleNo
ConfigChangeConfiguration file changedNo
InstructionsLoadedCLAUDE.md/rules file loadedNo
CwdChangedWorking directory changedNo
FileChangedWatched file changed on diskNo
ElicitationMCP server requests user inputNo
ElicitationResultUser responds to MCP elicitationNo
SetupClaude Code starts with --initNo

Missing Event Coverage

Events that Claude Code can emit but Séance does not currently handle:

EventPotential Use for Séance
SubagentStart / SubagentStopMore accurate subagent count tracking
TaskCreated / TaskCompletedShow task progress in status
PostToolUseFailureShow tool failure indicators
StopFailureShow error status on API failures
PreCompact / PostCompactShow compaction activity
WorktreeCreate / WorktreeRemoveTrack worktree activity
TeammateIdleTrack multi-agent coordination
CwdChangedUpdate directory display
FileChangedTrack file modifications
UserPromptExpansionTrack slash command usage

Impact: Claude Code has the richest event system. Séance only uses a small subset, missing opportunities for detailed status reporting like subagent lifecycle, task progress, and error states.

MIT Licensed