Fast full-text search across Claude Code session transcripts.
- Fast: Uses ripgrep for file-level matching (~70ms across 1000+ sessions), then Python for structured filtering
- Filter by speaker: Search only your messages (
--user) or Claude's responses (--assistant). The--userfilter is smart — it excludes tool results (bash output, file reads) that are stored as user records in the JSONL format - Filter by project: Narrow results to a specific project directory (
--project) - Filter by date: Only include recent sessions (
--since) - Zero dependencies: Python stdlib only. Auto-detects ripgrep (system install or Claude Code bundled binary), falls back to grep
- Color output: Highlights matches, color-codes speakers, shows session metadata
- JSON output: Machine-readable output for integration with other tools (
--json)
# Clone the repo
git clone https://github.com/yourusername/claude-session-search.git
cd claude-session-search
# Option A: Symlink to your PATH
ln -s "$(pwd)/ccs" ~/.local/bin/ccs
# Option B: Copy the script
cp ccs ~/.local/bin/ccs
chmod +x ~/.local/bin/ccsccs works without ripgrep (falls back to grep), but ripgrep is ~20x faster:
# macOS
brew install ripgrep
# Ubuntu/Debian
sudo apt install ripgrep
# Or: ccs auto-detects Claude Code's bundled ripgrep — no install needed# Search all sessions
ccs "RabbitMQ"
# Only in your messages
ccs "backup script" --user
# Only in Claude's responses
ccs "docker compose" --assistant
# Filter by project
ccs "webhook" --project my-app
# Only recent sessions
ccs "deploy" --since 2025-03-01
# Show resume commands
ccs "auth fix" --verbose
# JSON output
ccs "migration" --json3 matches in 2 sessions
2025-03-28 migrate-webpay-checkout [~/Sites/magento]
[claude] 01:46 ...RabbitMQ exchange recreation after fresh container start...
2025-03-20 switch-production-vulcan-to-leti [~/Sites/magento]
[you] 14:00 ...Redis, OpenSearch, and RabbitMQ connection settings should match...
[claude] 14:01 ...checking RabbitMQ configuration in app/etc/env.php...
- Phase 1: ripgrep (or grep) scans all
.jsonlfiles in~/.claude/projects/for the keyword — sub-100ms - Phase 2: Python parses matching files, filters by type/date, extracts context around matches
- Metadata: Reads
custom-titlerecords for session names, falls back to first user prompt
If you use Claude Code, you can create a skill that wraps ccs for natural language queries:
"Search my sessions for where I mentioned RabbitMQ"
"Find in your responses the backup script"
"Search in the lemps project for cron setup"
See the skill example for a ready-to-use skill definition you can drop into ~/.claude/skills/search-sessions/SKILL.md.
Claude Code stores sessions as JSONL files in ~/.claude/projects/<encoded-path>/:
- Each line is a JSON record with a
typefield type: "user"— user message (message.contentis a string) or tool result (message.contentis a list withtool_resultblocks)type: "assistant"— Claude response,message.contentis a list of content blocks (text, thinking, tool_use)type: "custom-title"— session rename event withcustomTitlefield- Records include
sessionId,timestamp,cwd,gitBranch
CCS_SESSIONS_DIR— Override the sessions directory (default:~/.claude/projects)
MIT