$ show jimmc414/cctrace
This repository is a Python-based CLI tool for exporting, importing, and managing Claude Code sessions. It allows users to export sessions from ~/.claude/projects/ to portable formats (JSONL, markdown, XML), import them to resume work in different environments, and create backups for safe recovery. The tool features both legacy export to ~/claude_sessions/exports/ and enhanced in-repo export to .claude-sessions/, with intelligent session detection, UUID regeneration preserving message threading, and pre-import snapshots for rollback capability. It includes hook scripts for automatic exporting and slash command integration for seamless workflow integration.
The LLM identified 5 files worth highlighting for reuse:
Implements Claude Code's specific path normalization algorithm that converts filesystem paths to the format used in ~/.claude/projects/. Handles cross-platform differences (Windows/Unix), replaces special characters with hyphens, and adds platform-specific prefixes. This is a self-contained utility that could be reused in any project needing to interact with Claude Code's storage system.
During import, the tool regenerates session IDs and UUIDs to avoid conflicts while preserving the parent-child relationships between messages. It maintains a mapping of old to new IDs and updates all references accordingly. This demonstrates sophisticated handling of data integrity during migration operations.
Before performing an import, the tool creates a complete snapshot of the current Claude Code session state. If the import fails or needs to be reverted, the restore_backup.py script can recover the exact previous state. This is a robust safety mechanism that could be applied to any data migration tool.
Creates a detailed manifest file (.cctrace-manifest.json) that captures export metadata, session statistics, and file inventory. This enables verification of export completeness and provides versioning for the export format. The manifest includes cryptographic hashes of files for integrity verification.
These shell scripts provide intelligent automation for session exporting. The auto export hook triggers on shell prompts, while the smart export hook uses more sophisticated logic to determine when to export (based on git status, file modifications, etc.). They demonstrate good practices for integrating with developer workflows.