Parse and prettify Claude Code JSONL session logs
Project description
claugs
Parse and prettify Claude Code JSONL session logs.
Installation
pip install claugs
For file watching support:
pip install "claugs[watch]"
Usage
claugs has two subcommands: show (render sessions) and watch (live monitoring).
Show
Render sessions with filtering. Accepts JSONL files, directories, or --latest/--session.
# Render a session file
claugs show session.jsonl
# Last 50 lines of the most recent session
claugs show --latest -n 50
# Find and render a session by UUID
claugs show --session abc123
# Read from stdin
cat session.jsonl | claugs show
# Render sessions from a project directory
claugs show ~/myproject
# Markdown export
claugs show --latest --format markdown > export.md
Directories are automatically resolved to Claude's project format (e.g., ~/myproject becomes ~/.claude/projects/-home-user-myproject).
Watch
Monitor session files for new messages in real-time (like tail -f):
# Watch all Claude sessions
claugs watch ~/.claude/projects/
# Watch from any project directory (auto-resolves)
claugs watch .
claugs watch ~/myproject
# Watch with initial context (last N lines)
claugs watch . -n 10
Search
--find is a filter on show that narrows to files containing the search text:
# Find sessions containing "error" and render them
claugs show --find "error"
# Just list matching filepaths
claugs show --find "error" -l
# Combine with time filters
claugs show --find "bug" --since "yesterday" ~/myproject
Time Filtering
Filter messages by timestamp using --after/--since and --before/--until:
# Today's messages
claugs show --since "today" ~/myproject
# Last 2 hours
claugs show --since "2 hours ago" .
# Specific range
claugs show --after "2026-03-17" --before "2026-03-18" .
Accepts ISO dates, natural language (yesterday, noon, tomorrow), and relative times (now -2h, 30 minutes ago, 5d).
Grouping
When scanning multiple files, --group-by controls how results are organized:
# Group by project directory
claugs show --since "today" ~/.claude/projects/ --group-by project
# Interleave messages by hour across files
claugs show --since "today" . --group-by time:%Y%m%d%H
# Combine: project first, then hourly interleaving within each
claugs show --since "today" . --group-by project,time:%Y%m%d%H
Visibility: --show / --hide / --show-only
A unified system controls what appears in the output. Use --list-filters to see all available filter names:
claugs show --list-filters
Toggle visibility:
# Hide thinking blocks and tool content
claugs show --latest --hide thinking,tools
# Show metadata (hidden by default)
claugs show --latest --show metadata
# Only show assistant messages
claugs show --latest --show-only assistant
# Compact mode (hides thinking, tools, metadata, timestamps, system messages)
claugs show --latest --compact
# Compact but keep thinking visible
claugs show --latest --compact --show thinking
Priority chain: --show-only sets the base, --show adds back, --hide removes. --show always wins over --hide for the same filter name.
Filter categories
Message types: assistant, user, system, summary, queue-operation, result, file-history-snapshot, progress
Subtypes: user-input, tool-result, subagent-result, system-meta, local-command, init, compact-boundary, success
Content: thinking, tools, metadata, timestamps, line-numbers
Tool names: Any tool name from the data (e.g., Bash, Read, Edit) — use --show or --hide with the tool name directly.
Output Formats
# ANSI terminal colors (default for TTY)
claugs show session.jsonl
# Markdown
claugs show --format markdown session.jsonl > export.md
# Plain text (default when piped)
claugs show session.jsonl | less
Text Filtering
# Include only messages matching a pattern
claugs show --grep "error" session.jsonl
# Exclude messages matching a pattern
claugs show --exclude "cache" session.jsonl
Architecture
JSONL → Pydantic Models → RenderBlocks → Formatters → Output
- Models (
models.py) — Pydantic-based message types with a discriminated union. Each message type auto-registers via class hierarchy introspection. Subtypes and content filters also self-register via class variables. - RenderBlocks (
blocks.py) — Format-agnostic rendering primitives (HeaderBlock, TextBlock, CodeBlock, etc.) - Formatters (
formatters.py) — Convert RenderBlocks to ANSI, Markdown, or plain text - Stream (
stream.py) — Message filtering (should_show_message) and stream processing - FilterConfig (
models.py) — Unified visibility system withis_visible(name)resolution - Grouping (
grouping.py) — Two-pass file cursor algorithm for--group-byinterleaving - DateParse (
dateparse.py) — Human-friendly date/time parsing for--after/--before
Adding new message types
- Define a class inheriting from
BaseMessage(or a subclass) withtype: Literal["your-type"] - Add
_filter_descriptionand optionally_filter_default_visible/_known_subtypes - Add it to the
Messagediscriminated union - It auto-registers in the filter system —
--list-filters,--show/--hide, andparse_message()all pick it up
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claugs-0.6.9.tar.gz.
File metadata
- Download URL: claugs-0.6.9.tar.gz
- Upload date:
- Size: 562.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
805e980e4e25f4b71d5eb9041da49d402abe2b0118dc353485d012b3742a384e
|
|
| MD5 |
f1766820c93a64a2bb99262eeae512ed
|
|
| BLAKE2b-256 |
b2a48b496372594cdd31b27fd77255665bd93cb78f0870c3bceb9ce179d7e0c4
|
File details
Details for the file claugs-0.6.9-py3-none-any.whl.
File metadata
- Download URL: claugs-0.6.9-py3-none-any.whl
- Upload date:
- Size: 39.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb324189c94b66913f82d16d1c6cca35e3b95cabf12f0997389579b9f14be529
|
|
| MD5 |
efc42a0cd08383fef06bd98dfec7677d
|
|
| BLAKE2b-256 |
d9f8197d48918c69595adf0216caa89bafc1bbbd4fd3656c15f2eb012995c67a
|