Claude Code History
Purpose
Query the user's Claude Code terminal session history to:
- See what projects were worked on recently
- Summarize specific sessions
- Provide context for picking up where he left off
- Search across terminal conversations
Note: This is read-only and on-demand. We don't auto-sync or store this data.
Data Location
Claude Code stores data at /hosthome/.claude/:
| Path | Contains |
|---|---|
history.jsonl |
User messages with timestamps, projects, session IDs |
projects/<project-path>/ |
Full conversation logs per session |
todos/ |
Task lists from sessions |
Common Queries
List Recent Sessions
# Get recent messages with projects and timestamps
tail -50 /hosthome/.claude/history.jsonl | \
jq -r '[.timestamp, .project, .display[:80]] | @tsv' | \
column -t -s $'\t'
Find Sessions for a Project
# List sessions for a specific project (e.g., myproject)
ls -lt /hosthome/.claude/projects/-home-user-Workspace-myproject/ 2>/dev/null | head -10
# Or search history for project mentions
grep -i "myproject" /hosthome/.claude/history.jsonl | \
jq -r '[(.timestamp/1000 | strftime("%Y-%m-%d %H:%M")), .display[:60]] | @tsv' | \
tail -20
Read a Session's Conversation
# Session files are JSONL with message objects
# Find the most recent session file for a project
LATEST=$(ls -t /hosthome/.claude/projects/-home-user-Workspace-myproject/*.jsonl 2>/dev/null | head -1)
# Extract user messages from that session
cat "$LATEST" | jq -r 'select(.type == "human") | .message.content' | head -50
Search Across All Sessions
# Search for a topic across all session history
grep -r "API design" /hosthome/.claude/projects/ 2>/dev/null | head -20
How to Use This
"What was I working on in Claude Code?"
- Read recent history:
tail -30 /hosthome/.claude/history.jsonl - Parse out projects and messages
- Summarize the recent activity
"Summarize my last session on [project]"
- Find the project directory:
ls /hosthome/.claude/projects/ | grep -i <project> - Get the latest session:
ls -t <project-dir>/*.jsonl | head -1 - Read the conversation
- Generate a summary
"Continue where I left off on [project]"
- Find the latest session for that project
- Read the last ~20 messages
- Summarize the state and any pending work
- Provide context for the new session
Important Notes
- Read-only - Never modify Claude Code's data
- On-demand - Only query when asked, don't background sync
- Summarize, don't dump - Generate useful summaries, not raw logs
- Privacy-aware - This is the user's terminal history, treat it appropriately
- Session-specific - Each .jsonl file is one conversation session
Example Workflow
User: "What was I working on in Claude Code recently?"
PCP:
# Get last 20 distinct project/message pairs
tail -100 /hosthome/.claude/history.jsonl | \
jq -r '[(.timestamp/1000 | strftime("%m-%d %H:%M")), .project, .display[:50]] | @tsv' | \
sort -u | tail -20
Then summarize: "In the last few hours, you worked on:
- myproject: Positioning and workspace setup
- personal-site: Thesis-related content
- pcp: [this conversation]"