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:

EventWhen It FiresWhat’s Captured
SessionStartClaude Code session beginsSession ID, model, working directory, source (startup/resume)
UserPromptSubmitUser sends a promptPrompt text
PreToolUseBefore a tool executesTool name, input parameters
PostToolUseAfter a tool completesTool output, duration
PostToolUseFailureTool execution failsError message
StopAssistant finishes respondingLast assistant message, triggers trace send
SessionEndSession closesFinal cleanup, triggers trace send
SubagentStartSubagent/cowork spawnedSubagent ID, type
SubagentStopSubagent completesTranscript 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

FieldSourceExample
nameAuto-generated"Claude Code session (3 turns)"
descriptionFirst user prompt"Fix the login bug in auth.py"
durationSession timing45.2 (seconds)
input_summaryFirst prompt"Fix the login bug"
output_summaryLast assistant message"Tests added and passing"

Execution Steps

Each trace includes an ordered list of steps:

Step TypeActionFields
User promptuser_promptdescription, input_preview
Tool calltool_use:{name}input_summary, output_summary, duration_ms
Tool errortool_use:{name}error.error_type, error.message, error.recoverable
Subagentsubagent:{type}metadata.subagent_id, metadata.agent_type

Environment Context

Every trace includes environment metadata:

TagValue
modelClaude model used (e.g., claude-sonnet-4-5-20250514)
session_idClaude Code session identifier
working_directoryProject directory path
permission_modeUser’s permission level
framework"Claude Code"

Error Tracking

Tool failures are captured as structured errors:

FieldDescription
error_type"ToolFailure"
messageError message from Claude Code
recoverabletrue (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.