Skip to content

Instantly share code, notes, and snippets.

@quidmonkey
Created April 24, 2026 16:37
Show Gist options
  • Select an option

  • Save quidmonkey/7fca1b3541d7aeb4d3dcf8b42327e731 to your computer and use it in GitHub Desktop.

Select an option

Save quidmonkey/7fca1b3541d7aeb4d3dcf8b42327e731 to your computer and use it in GitHub Desktop.
Search past Claude conversations for keywords e.g. claudesearch -h
claudesearch() {
if [[ "$1" == "-h" || "$1" == "--help" || $# -eq 0 ]]; then
echo "Usage: claudesearch <keyword> [keyword2 ...]"
echo " claudesearch -r <session-id>"
echo ""
echo "Options:"
echo " -h Show this help"
echo " -r <id> Resume a session by ID"
echo ""
echo "Examples:"
echo " claudesearch bull quantize"
echo " claudesearch 'ADK agents'"
return 0
fi
if [[ "$1" == "-r" ]]; then
claude -r "$2"
return
fi
local files
files="$(grep -rl "$1" ~/.claude/projects/**/*.jsonl)"
shift
for kw in "$@"; do
files="$(echo "$files" | xargs grep -l "$kw")"
done
echo "$files" | while read f; do
local first_msg
first_msg=$(jq -r '
select(.type == "user") |
.message.content |
if type == "string" then . else (.[] | select(.type == "text") | .text) end
' "$f" | grep -Evm1 '^\s*<' | cut -c1-80)
[[ -z "$first_msg" ]] && continue
echo "$(basename "$f" .jsonl)"
echo " $first_msg"
done 2>/dev/null | grep -v "^first_msg="
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment