Analyze local Claude session transcripts and generate usage reports.
ℹ️ Claude is an Anthropic product. This project is an independent local analyzer and is not an official Anthropic repository.
The analyzer scans local *.jsonl session files, then generates:
- token usage totals (input, cached input, output, reasoning)
- usage by project
- costly sessions and subagents
- prompt extraction by project
- markdown + JSON report output
It supports both:
- legacy JSONL event format (
session_meta,event_msg,token_count) - Claude-style transcript JSONL records (generic parser with usage/prompt extraction)
By default, the tool scans these common directories:
~/.claude/projects~/.claude/sessions~/.config/claude/projects~/.config/claude/sessions- Windows:
%APPDATA%\Claude\local-agent-mode-sessions - Windows:
%LOCALAPPDATA%\AnthropicClaude\local-agent-mode-sessions
You can override/add paths with:
--claude-home PATH(changes the base~/.claudeequivalent)--session-dir PATH(repeatable, adds extra transcript folders)CLAUDE_SESSION_DIRSenv var (multiple folders separated by OS path separator)
Examples:
py analyze-claude-tokens.py --session-dir "D:\ClaudeLogs" --session-dir "E:\Backups\Claude"$env:CLAUDE_SESSION_DIRS="D:\ClaudeLogs;E:\Backups\Claude"
py analyze-claude-tokens.py- Python 3.10+
- No external dependencies
python analyze-claude-tokens.pyWindows PowerShell:
py analyze-claude-tokens.pyDefault output directory:
./reports/<lang>-YYYY-MM-DD_HHMMSS/
Generated files:
token_report.mdtoken_report.json(unless disabled)prompts/*.md
python analyze-claude-tokens.py \
--since-days 7 \
--lang pt-br \
--output-dir ./reports \
--redact-prompts \
--jsonAvailable flags:
--since-days N--since-date YYYY-MM-DD--claude-home PATH--output-dir PATH--session-dir PATH(repeatable)--lang en|pt-br|pt-pt|es--redact-prompts/--no-redact-prompts--json/--no-json
CLAUDE_HOME(primary)OUTPUT_DIRCLAUDE_SESSION_DIRS(extra directories separated by;on Windows,:on Linux/macOS)SINCE_DAYSSINCE_DATEREDACT_PROMPTSWRITE_JSONREPORT_LANG
Example:
$env:CLAUDE_HOME="C:\Users\you\.claude"
py analyze-claude-tokens.py --lang pt-brpython -m unittest discover -s tests -vPowerShell:
py -m unittest discover -s tests -v- Only sessions with
total_tokens > 0are included. - Some Claude Desktop data may be stored in cache/indexed DB formats not directly parseable as JSONL.
- If no data is found, the script now prints all scanned directories; use
--session-dir/CLAUDE_SESSION_DIRSto point to your real transcript locations. - Report language supports
en,pt-br,pt-pt, andes; unsupported locale values gracefully fall back to English.
Claude Code docs show session events exposing transcript_path under ~/.claude/projects/.../*.jsonl, which matches this analyzer’s primary source strategy:
- Initial release.
- INformigados: https://github.com/informigados/
- Alex Brito: https://github.com/alexbritodev
This project is licensed under the MIT License - see the LICENSE file for details.