The connector hooks into Claude Code’s event system and captures structured data from each session. This page documents what events are captured and how they map to Infinium traces.
Hook Events
The connector listens for these Claude Code hook events:
| Event | When It Fires | What’s Captured |
|---|---|---|
SessionStart | Claude Code session begins | Session ID, model, working directory, source (startup/resume) |
UserPromptSubmit | User sends a prompt | Prompt text |
PreToolUse | Before a tool executes | Tool name, input parameters |
PostToolUse | After a tool completes | Tool output, duration |
PostToolUseFailure | Tool execution fails | Error message |
Stop | Assistant finishes responding | Last assistant message, triggers trace send |
SessionEnd | Session closes | Final cleanup, triggers trace send |
SubagentStart | Subagent/cowork spawned | Subagent ID, type |
SubagentStop | Subagent completes | Transcript path |
How Events Become Traces
Events are grouped into turns — each turn is one prompt-response cycle:
Turn 1:
UserPromptSubmit → "Fix the login bug"
PreToolUse → Read(file="auth.py")
PostToolUse → [file contents]
PreToolUse → Edit(file="auth.py", ...)
PostToolUse → [edit applied]
Stop → "I've fixed the login bug by..."
↓
Trace sent to Infinium
Turn 2:
UserPromptSubmit → "Now add tests"
PreToolUse → Write(file="test_auth.py", ...)
PostToolUse → [file created]
Stop → "I've added tests for..."
↓
Trace sent to Infinium
Each Stop event triggers a trace send. On SessionEnd, a final trace is sent and the session file is cleaned up.
Trace Structure
Each trace sent to Infinium contains:
Top-Level Fields
| Field | Source | Example |
|---|---|---|
name | Auto-generated | "Claude Code session (3 turns)" |
description | First user prompt | "Fix the login bug in auth.py" |
duration | Session timing | 45.2 (seconds) |
input_summary | First prompt | "Fix the login bug" |
output_summary | Last assistant message | "Tests added and passing" |
Execution Steps
Each trace includes an ordered list of steps:
| Step Type | Action | Fields |
|---|---|---|
| User prompt | user_prompt | description, input_preview |
| Tool call | tool_use:{name} | input_summary, output_summary, duration_ms |
| Tool error | tool_use:{name} | error.error_type, error.message, error.recoverable |
| Subagent | subagent:{type} | metadata.subagent_id, metadata.agent_type |
Environment Context
Every trace includes environment metadata:
| Tag | Value |
|---|---|
model | Claude model used (e.g., claude-sonnet-4-5-20250514) |
session_id | Claude Code session identifier |
working_directory | Project directory path |
permission_mode | User’s permission level |
framework | "Claude Code" |
Error Tracking
Tool failures are captured as structured errors:
| Field | Description |
|---|---|
error_type | "ToolFailure" |
message | Error message from Claude Code |
recoverable | true (tool errors are recoverable) |
Data Truncation
To keep payloads manageable, the connector truncates:
- Prompt text: First 500 characters (configurable via
CONNECTOR_MAX_INPUT_PREVIEW) - Tool output: First 500 characters (configurable via
CONNECTOR_MAX_OUTPUT_PREVIEW)
Full data is never sent — only summaries that give Maestro enough context to evaluate quality.