Full-text search for conversation transcripts

Resolved 💬 4 comments Opened Mar 4, 2026 by yuxi-liu-wired Closed May 30, 2026

claude --resume and /resume only search session titles/timestamps, not conversation content. If you remember a phrase from a past session but not which session it was in, there is no way to find it.

Workaround: a shell script that greps the JSONL transcript files directly.

#!/bin/bash
# claude-search — full-text search across Claude Code conversation transcripts.
# Outputs matching session IDs for use with `claude -r <id>`.
#
# Usage:
#   claude-search "some phrase"
#   claude-search -q "some phrase"    # quiet: IDs only, no snippets

set -euo pipefail

quiet=0
if [[ "${1:-}" == "-q" ]]; then
    quiet=1
    shift
fi

query="${1:?Usage: claude-search [-q] \"search phrase\"}"
base="$HOME/.claude/projects"

if [[ ! -d "$base" ]]; then
    echo "No Claude Code projects found at $base" >&2
    exit 1
fi

find "$base" -name '*.jsonl' -type f | while read -r f; do
    if grep -qlF "$query" "$f" 2>/dev/null; then
        sid=$(basename "$f" .jsonl)
        project=$(basename "$(dirname "$f")" | sed 's/^-home-[^-]*-//')
        title=$(python3 -c "
import json
sid = '$sid'
with open('$HOME/.claude/history.jsonl') as f:
    for line in f:
        try:
            d = json.loads(line)
            if d.get('sessionId') == sid:
                print(d.get('display','')[:80])
                break
        except: pass
    else:
        print('(no title)')
" 2>/dev/null)
        echo "$sid  [$project]  $title"
        if [[ $quiet -eq 0 ]]; then
            python3 -c "
import sys
query = sys.argv[1]
with open(sys.argv[2]) as f:
    text = f.read()
idx = text.find(query)
if idx >= 0:
    start = max(0, idx - 60)
    end = min(len(text), idx + len(query) + 60)
    snippet = text[start:end].replace('\n', ' ')
    print(f'    ...{snippet}...')
" "$query" "$f"
        fi
    fi
done

Put it in ~/.local/bin/claude-search, chmod +x. Then:

$ claude-search "some phrase you remember"
c1019f56-016b-481b-8cec-99a993491f0c  [project-name]  first message of that session
    ...context around the matching phrase...

$ claude -r c1019f56

This should be a built-in feature of --resume. The transcript files are already on disk; they just need to be searched.

Previously requested in #8701 and #6455 (both closed/locked).

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗