Claude Code
Trace your Claude Code (Anthropic CLI) conversations with Respan for full observability into thinking, tool calls, and agent workflows.
Set up Respan
- Sign up — Create an account at platform.respan.ai
- Create an API key — Generate one on the API keys page
- Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Use AI
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
Claude Code is Anthropic’s agentic coding tool that lives in your terminal. With Respan integration, you get hierarchical traces of every conversation including thinking blocks, tool calls, and token usage.
How It Works
Claude Code stores conversation transcripts as JSONL files. Our integration uses the Stop hook to parse these transcripts and send structured traces to Respan.
For details on trace structure and span types, see the Observability Data Model.
Prerequisites
- Claude Code installed (
npm install -g @anthropic-ai/claude-code) - Respan API key
- Python 3.8+ with
requestslibrary
Installation
1. Set Environment Variables
Add these to your shell profile (.bashrc, .zshrc, or PowerShell $PROFILE):
2. Download the Hook Script
Download the hook script to your Claude Code hooks directory:
3. Configure Claude Code Settings
Add the hook to your Claude Code settings at ~/.claude/settings.json:
If settings.json already exists, merge the hooks section with your existing configuration.
4. Enable Per-Project (Optional)
To enable tracing for specific projects, create .claude/settings.local.json in your project directory:
Captured Data
The integration captures rich metadata from Claude Code transcripts:
Span Types
Trace Fields
Debugging
Check the log file for issues:
State File
The hook tracks processed turns in ~/.claude/state/respan_state.json:
Delete this file to reprocess all turns.
Common Issues
Example Output
After setup, you’ll see traces in Respan with full hierarchy:
Comparison with Cursor Integration
Source Code
The full source code is available on GitHub: Respan/respan-example-projects/claude_code