Skip to main content

JSONL Session Structure Analyzer

Analyzes Claude Code JSONL session files to identify safe split points, message boundaries, and optimal chunking strategies for large sessions.

Features:

  • Stream processing (no full file load)
  • Safe split point detection (file snapshots, user messages, assistant end turns)
  • Tool call sequence tracking (prevents unsafe splits)
  • Overlap window calculation
  • Session metadata extraction

Author: Claude + AZ1.AI License: MIT

File: jsonl_analyzer.py

Classes

JournalEntryType

JSONL entry types in Claude Code session files

SplitPointQuality

Quality/safety level of split points

SplitPoint

Represents a potential split boundary

SessionStructure

Session file structure analysis

JSONLAnalyzer

Analyze JSONL session file structure and find safe split points.

Functions

analyze_structure(quick_mode)

Scan file and analyze structure without loading into memory.

find_safe_split_points(target_chunk_size, min_chunk_size, max_split_points)

Find optimal split points for chunking based on target chunk size.

calculate_overlap(split_line, overlap_messages)

Calculate overlap window for conversation continuity.

Get recommended chunking strategy for this session.

Usage

python jsonl_analyzer.py