Reference documentation for analyzing Claude Code conversation history files
Reference documentation for analyzing Claude Code conversation history files. This skill provides query patterns and structural knowledge for extracting insights from JSONL conversation logs.
Claude Code stores conversation history in ~/.claude/projects/ with directories named after encoded working directory paths.
~/.claude/projects/
|-- -Users-leon--claude/ # /Users/leon/.claude
| |-- {session-uuid}.jsonl # Main conversation
| |-- {session-uuid}/
| |-- subagents/
| | |-- agent-{hash}.jsonl # Subagent conversations
| |-- tool-results/ # Large tool outputs
|-- -Users-leon-git-myproject/ # /Users/leon/git/myproject
|-- ...
Working directory paths are encoded:
| Original | Encoded | Rule |
| -------------- | -------------- | ------------------- |
| /Users/leon | -Users-leon | Leading / -> - |
| /git/project | -git-project | Internal / -> - |
| /.claude | --claude | /. -> -- |
Each line in a JSONL file is a self-contained message with:
type: Message type (user, assistant, system, queue-operation)uuid: Unique identifier for this messageparentUuid: Links to predecessor message (forms conversation chain)timestamp: ISO 8601 timestampmessage: Payload containing role, content, and usage statisticsAssistant messages have structured content blocks:
Shell commands + jq compose better than custom tooling for this use case:
The documentation approach lets the LLM compose queries on demand rather than learning a custom API.
Skills are invoked via bash with pattern python3 -m skills.{name}.{module}. This pattern is general enough to capture all skills without enumeration:
python3 -m skills\.([a-z_]+)\.
Capture group 1 extracts the skill name. No need to maintain a list of valid skill names.
Subagent files are named agent-{hash}.jsonl but the hash is not stored in the parent conversation's Task tool call. Correlation requires:
This is mildly inconvenient but not worth building tooling for -- it's a rare operation.
The usage object in assistant messages contains:
input_tokens: Tokens in prompt (excluding cache)output_tokens: Tokens in responsecache_read_input_tokens: Tokens read from cachecache_creation_input_tokens: Tokens written to cacheTotal billable input = input_tokens + cache_creation_input_tokens (cache reads are cheaper).
# Find conversations over 1MB
find "$PROJECT_DIR" -name "*.jsonl" -size +1M
# Get token totals for each
for f in "$PROJECT_DIR"/*.jsonl; do
tokens=$(jq -s '[.[].message.usage? | select(.) | .input_tokens] | add' "$f")
echo "$tokens $f"
done | sort -rn | head -10
# Which skills were used in a conversation?
grep -oE "python3 -m skills\.[a-z_]+" file.jsonl | \
sed 's/python3 -m skills\.//' | \
cut -d. -f1 | \
sort -u
# Find all planner skill conversations
grep -l "python3 -m skills\.planner\." "$PROJECT_DIR"/*.jsonl
# Show token progression (identify where context grew)
jq -c 'select(.type=="assistant" and .message.usage.input_tokens > 50000) |
{ts: .timestamp[11:19], tokens: .message.usage.input_tokens}' file.jsonl
This skill provides the structural knowledge for history analysis. For analyzing specific patterns:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer