A CLI tool for browsing Claude Code session history. Reads the JSONL session files stored in ~/.claude/projects/ and renders them as markdown with YAML frontmatter. Supports viewing full conversations, filtering by message type, and listing recent sessions across all projects.
# List recent sessions
claude-query sessions
claude-query sessions --project myapp
claude-query sessions --limit 50
# View a session (full or partial ID)
claude-query show <sessionId>
claude-query show a1b2c3d4
# Filter output
claude-query show <sessionId> --type user # only user messages
claude-query show <sessionId> --type assistant # only assistant messages
claude-query show <sessionId> --no-tools # hide tool_use/tool_result blocks
claude-query show <sessionId> --no-system # hide system messages
claude-query show <sessionId> --compact # truncate long tool results and hide thinking
Requires Bun.
bun install
ln -s $(pwd)/index.ts ~/bin/claude-query