Claude Parser
A high-performance stream-JSON parser for Claude Code CLI output, designed for benchmarking and training data collection.
Features
-
Stream Event Parsing: Supports all Claude event types:
message_start,message_stopcontent_block_start,content_block_delta,content_block_stoptool_use,function_resultthinkingerrorusage
-
Performance Metrics Extraction:
- Timing measurements (total duration, time to first output)
- Token usage tracking (input, output, total)
- Tool invocation statistics
- Thinking sequence analysis
- Error and recovery patterns
-
Error Handling: Robust error recovery with detailed tracking of error types and recovery strategies
-
Export Functionality: Export parsed data for training in JSON or JSONL format
Usage
use ClaudeStreamParser;
use File;
async
Metrics Collected
Tool Metrics
- Invocation count per tool
- Average duration
- Success rate
- Parameter sizes
Thinking Metrics
- Total sequences
- Token count per sequence
- Duration analysis
- Pattern recognition
Error Metrics
- Error types and frequencies
- Recovery success rates
- Recovery strategies used
Timeline
- Chronological event sequence
- Relative timing information
- Event correlations
Integration with Benchmarking
This parser is designed to work with the RUV-SWARM benchmarking system for:
- SWE-Bench instance evaluation
- Real-time performance monitoring
- Comparative analysis between baseline and ML-optimized approaches
- Training data collection for model improvement
License
Licensed under MIT OR Apache-2.0