Search and analyze Claude Code session history. Use when user asks to find past conversations, recall what was done, search for patterns in history, or analyze previous sessions.
/plugin marketplace add shikihane/polydev/plugin install poly-retrace@polydev-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
This is NOT optional. If there's even a 10% chance the user is asking about past work, USE RETRACE. </CRITICAL>
Search and analyze your Claude Code conversation history using FTS5 full-text search.
~/.claude/projects/<project>/retrace-index.dbretrace_common.py for common utilitiesYou MUST use retrace when:
| User Says | Action |
|---|---|
| "我们之前怎么处理 X 的?" | Search for X, analyze results |
| "找一下关于 Y 的讨论" | Search for Y with filters |
| "上次那个 bug 是怎么修的?" | Search "bug fix" + analyze |
| "有没有类似的实现?" | Search pattern + analyze |
| "回顾一下之前的方案" | Search + context retrieval |
| "回溯这个会话" / "这次聊了什么" | Use retrace-chronicle.py on session |
Before searching, ensure the index is built:
RETRACE_SCRIPTS="<plugin-path>/scripts"
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-index.py" --auto
If index doesn't exist: Run retrace-index.py --auto first. Never tell user "no history available" without checking.
# List all sessions in a project
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" --list-sessions --project polydev
# JSON output
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" --list-sessions --project polydev --json
# Basic search
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" "error handling" --project polydev
# Search within a specific session
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" "bug" \
--session <session-id> \
--level detail
# Get statistics only (minimal tokens)
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" "token" --level stats --project polydev
# Get context around a message
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" --context <id> --before 5 --after 5
# Search + analyze (auto-chunks if data > 100KB)
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-analyze.py" "error" --prompt "classify error types" --project polydev
# JSON output
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-analyze.py" "query" --prompt "summarize" --json
Extract key events from a single session with timestamps in TOON format.
# By session UUID (requires --project to locate file)
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-chronicle.py" --session <uuid> --project polydev
# By direct file path
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-chronicle.py" --file ~/.claude/projects/<project-dir>/<uuid>.jsonl
# JSON output
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-chronicle.py" --file <path> --json
Workflow: First use --list-sessions to find session UUID, then use chronicle on specific session.
Chronicle extracts (TOON format: time,type,content):
code: Code snippets, functions, fixescmd: Bash/git/npm commands executedfile: File operations (created/modified/deleted)error: Error messages and root causesdecision: Technical choices mademistake: Wrong assumptions, bugs foundOutput example:
@events[time,type,content]
2026-01-06T12:27:48,error,Windows PowerShell runs .sh scripts as file association
2026-01-06T12:30:10,fix,Modified config to use absolute path
2026-01-06T14:10:21,cmd,`git checkout -b feature/auth`
| Level | Output | Token Cost | Use Case |
|---|---|---|---|
stats | Counts, distributions | ~50 | Quick overview |
list | ID, timestamp, preview | ~500 | Browse results |
detail | Full preview, file location | ~2000 | Examine matches |
full | Complete message content | Variable | Deep inspection |
Default workflow: stats → list → detail → full (wide to narrow)
| Filter | Example | Description |
|---|---|---|
--type | tool_result, user, assistant | Message type |
--role | user, assistant | Speaker role |
--tool | Bash, Edit, Read | Tool used |
--project | polydev | Project name (partial match) |
--session | <uuid> | Filter by session ID |
--since | 2025-01-01 | Start date |
--until | 2025-01-07 | End date |
| Script | Purpose |
|---|---|
retrace-index.py | Build/update FTS5 index per project |
retrace-search.py | Search with layered output + session listing |
retrace-analyze.py | Query-based AI analysis |
retrace-chronicle.py | Single session history extraction (TOON format) |
retrace_common.py | Shared utilities |
# Build/update index for all projects
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-index.py" --auto
# Index specific project
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-index.py" --auto --project polydev
# Rebuild from scratch (no incremental)
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-index.py" --auto --no-incremental
# View statistics
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-index.py" --stats
If you catch yourself thinking:
| Thought | Reality |
|---|---|
| "I don't know what we did before" | Search retrace first |
| "Let me guess the approach" | Search similar implementations first |
| "User probably doesn't remember" | YOU can search for them |
| "I'll implement from scratch" | Check if similar work exists first |
| "This seems familiar" | IT IS - search for it |
All of these mean: Use retrace first.
All scripts support --json flag for machine-readable output.
# JSON output for further processing
$PYTHON_CMD "$RETRACE_SCRIPTS/retrace-search.py" "query" --json | jq '.[] | .id'
~/.claude/projects/<project>/retrace-index.db~/.claude/projects/<encoded-path>/