Claude Code Trace: Export Your AI Chat Sessions Easily
Export Your Claude Code Chat Sessions with cctrace
cctrace is an innovative open-source command-line tool developed to streamline the process of exporting your chat sessions from Claude Code. For developers, data scientists, and AI enthusiasts, having a comprehensive record of AI interactions, including internal reasoning and tool usage, is invaluable. cctrace provides a robust solution, ensuring all critical data is captured and made accessible.
What is cctrace?
cctrace, short for "Claude Code Trace," is a Python-based utility that allows users to export their Claude Code chat sessions into various formats such as Markdown, XML, and raw JSONL. It's designed to be user-friendly, offering both a simple slash command integration within Claude Code itself and flexible command-line options for advanced customization.
Key Features:
- Automatic Session Detection: Intelligently identifies your current Claude Code session, even with multiple concurrent sessions, returning the session ID, transcript, and all metadata.
- Complete Data Capture: Exports all messages, "thinking" blocks (internal reasoning), tool usage with inputs and outputs, and comprehensive metadata.
- Multiple Output Formats: Generates human-readable Markdown files for easy review, structured XML for programmatic processing, and raw JSONL for detailed analysis.
- Slash Command Integration: Export directly from your Claude Code session using a simple
/export
command. - Timestamped Archives: Each export is saved in a unique, timestamped directory for easy organization.
- Auto-Copy to Working Directory: Optionally copies exports directly to your current project directory, simplifying version control and access.
Why Use cctrace?
In today's fast-paced AI development environment, tracking and analyzing AI interactions is crucial. Whether you're debugging prompts, documenting AI behavior, or sharing insights with a team, cctrace ensures you have a complete, well-structured record. Its ability to capture detailed internal reasoning and tool calls provides an unprecedented level of transparency into how Claude Code operates during your sessions.
Getting Started with cctrace
Requirements:
- Python 3.6 or newer
- Claude Code running on Linux or WSL
- Access to the
~/.claude/projects/
directory
Quick Installation:
- Clone the Repository:
git clone https://github.com/jimmc414/cctrace.git cd cctrace
- Run the Installer:
chmod +x install.sh ./install.sh
Usage:
Via Claude Code Slash Command (Recommended):
Simply type /export
or /user:export
within your Claude Code session. The tool will automatically detect and export your current session, displaying a summary directly in Claude Code.
Via Command Line:
For more control, you can run the export_claude_session.py
script directly:
- Export current active session:
python3 ~/claude_sessions/export_claude_session.py
- Export a specific session by ID:
python3 ~/claude_sessions/export_claude_session.py --session-id <your-session-id>
- Specify output format or directory:
python3 ~/claude_sessions/export_claude_session.py --format xml --output-dir /path/to/my/exports
Export Contents Explained
Each export creates a timestamped directory containing various files:
session_info.json
: Comprehensive session metadata, including session ID, project directory, timestamps, and model usage.conversation_full.md
: A human-readable Markdown file of the entire conversation, complete with collapsible sections for thinking blocks and tool usage.conversation_full.xml
: A fully labeled XML file preserving all metadata, message hierarchy, and detailed tool execution information, ideal for automated processing.raw_messages.jsonl
: The original, unmodified JSONL data from Claude Code, perfect for in-depth programmatic analysis.summary.txt
: A quick plaintext overview of the session and export details.
cctrace is an essential tool for anyone working with Claude Code, providing the means to thoroughly manage, analyze, and share AI conversation data. Its open-source nature encourages community contributions and ensures continuous improvement.