chat-history
Skill12 starsChanged 5 months agoMITView on GitHub
Search, inspect, and export Claude Code, Cursor, and Codex conversation history. Use when the user asks about past conversations, wants to find a previous session, needs to search chat history, wants a summary of what they worked on, or asks to resume a session. Also use when the user says "what did I work on", "find that conversation where I...", "show me my recent sessions", or "search my history for...".
- Installs packages
3 other projects use a version of this.
Adopted by
Most recently taken up by
- wzz6423/read-chat-historytheir own version, first seen Sep 26, 2026
- mblode/agent-skillstheir own version, first seen Sep 11, 2026
- tyrchen/claude-skillstheir own version, first seen Nov 10, 2025
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- mblode/agent-skills★ 142same name
- tyrchen/claude-skills★ 45same name
- wzz6423/read-chat-history★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Search, inspect, and export Claude Code, Cursor, and Codex conversation history.
- Distinctive: line 38
Search leaves out the conversation you are running in (Claude Code, Codex and Cursor's agent tell it which one), since it would match its …
- Very specific: line 40
When candidates are close, inspect them together (inspect a b c --brief) before picking — don't answer from the top score alone, and don't …
- Very specific: line 49
Don't dump raw JSON or full transcripts at the user — summarize, cite the session ID and date (or title + directory for cursor-ide).
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
chat-history
Search, inspect, and export Claude Code, Cursor, and Codex conversation history. The short alias ch works identically. If the command is not found: cargo install chat-history.
When to use
- User asks about past conversations or sessions
- User wants to find something they discussed before
- User needs a summary of recent work / accomplishments
- User wants to resume or export a previous session
Process
Keyword question ("find that conversation where I..."):
chat-history search "<query>" --compact— one line per conversation: short id, date, source, directory,#ordinalof the best match (-for a title or first-prompt match), title, then— Role: excerptand(also #a #b)for its other matches. Role isYou(the person),AssistantorTool(command output or file contents). BM25 searches metadata and transcripts together. Use--jsoninstead only when a script parses the results: each hit then carriessession_id,score,snippet,role,ordinal,timestamp,tools,files, andadditional_matcheswith the same message fields.- Shortlist by title and excerpt (see "Choosing the best hit").
- Read the hit in context, not the whole transcript:
chat-history view <id> --plain --around <ordinal>(2 messages each side;-C Nto widen,--max-chars 1500to cap long messages), or--aroundone of thealsoordinals. A title/prompt match has no ordinal — useinspectfor those.view --jsongives the same selection as data for scripts. - To find something inside one session, use
chat-history view <id> --plain --grep "<regex>" --max-chars 600 --head 12instead of pipingviewthroughgrep/sed/head. To read just the conversation, add--role user,assistant(tool output is most of a transcript);--role userlists what the person asked. chat-history inspect <id> <id> <id> --briefon the top 2–3 candidates to confirm before answering: one call, a few lines each (what was asked, the latest substantive result, files it read or edited — the project's first). Drop--brieffor one session's full detail. Fullview/exportonly if the user needs the whole conversation.
Temporal question ("what did I work on yesterday?") — list, don't search:
chat-history --from yesterday --to yesterday— every row shows a short session ID;-sgroups by day for multi-day overviews.--from Xalone means X through today. Always pair with--towhen the user means a specific day.- Short IDs work everywhere a session ID is accepted (
inspect,view,export,find);-vadds full IDs and file paths.resumeworks forclaude/codexrows and for Cursor Agent CLI chats; Cursor rows whose id has no~/.cursor/chatsstore (whatever their tag) print the title andDIR:— tell the user to open that folder in Cursor and pick the chat in the sidebar.
chat-history inspect <id>…for accomplishments (how each turn ended), tools, files touched;--briefto compare several sessions.
Choosing the best hit
- Results are ranked by lexical relevance (BM25 by default), not intent.
--jsonscores are not confidence values or comparable across queries. Use the order only to shortlist; decide from excerpts andinspect. - BM25 groups matches by conversation:
--limitcounts conversations, the excerpt follows the strongest matching passage, and(also #a #b)names up to two more matching messages — read them withview --aroundbefore inspecting the session (--jsonincludes their excerpts underadditional_matches). Use--group-by messageif individual matching messages are needed;--scope similardefaults to message rows. - Search leaves out the conversation you are running in (Claude Code, Codex and Cursor's agent tell it which one), since it would match its own query. Searching for its full UUID still finds it.
- Tool output (
role: tool) ranks below conversation text with the same words; chat-history's own output is never indexed. - When candidates are close,
inspectthem together (inspect a b c --brief) before picking — don't answer from the top score alone, and don't loop over ids in the shell.
Common mistakes
searchandviewaccept--json; the session list andinspectreject it.- The subcommands are
search,inspect,view,export,resume,find,install-skill,completions, and the optionalcursor-hookreceiver. Do not guess others; runchat-history --helpwhen unsure.cursor-hookis for configured Cursor hooks, not normal history queries. - Cursor CLI rows labeled
[metadata only](in--compacttoo) supportfind,resume, and title search when Cursor recorded a title (print-mode chats usually have none); their internalstore.dbcannot be viewed or exported as a transcript. Do not claim that metadata-only search covers message content. - Cursor message timestamps may be unavailable.
search --timeframeexcludes unknown message times and untimed first-prompt previews. Titles use session activity times. Use session--from/--tofilters for activity-date questions. File modification times are not message timestamps. - A stderr line starting
Note:about the cache directory not being writable means the sandbox blocked~/.chat-history; results are still complete and later searches stay fast. Mention it only if the user asks why; the README section "Running inside agent sandboxes" has the one-line setting per tool. - Don't dump raw JSON or full transcripts at the user — summarize, cite the session ID and date (or title + directory for
cursor-ide). cursor-iderows (and--jsonitems with"also_ide": true) resume only when the Agent CLI has a~/.cursor/chatsstore for the id; otherwiseresumeprints a sidebar hint instead of launching the Agent CLI. Runresumeand follow its output rather than assuming.- Some Cursor sessions have thin metadata (
(no summary),duration: 0min, raw first-message titles). Ifinspectis thin, fall back tochat-history view <id> --plain --tail 6(or--grep) rather than the whole transcript. - Don't pipe
viewthroughgrep -A40 | headorsed -n 'A,Bp': use--around,--grep,--head/--tail(with--grepthese count matches, each kept whole with its context) and--max-chars. Messages are numbered[#N]in those modes (-nnumbers a full view);[-K chars] …/… [+K chars]mark cut text,…on its own line marks skipped messages.
Commands
# List sessions
chat-history # newest first; short IDs on every row (-v for full IDs + paths)
chat-history --from yesterday --to yesterday -s # a specific day, grouped
chat-history --from "3 days ago" # natural-language dates
chat-history --source claude # claude | cursor | cursor-agent | cursor-ide | codex
chat-history -L # current workspace only
chat-history --branch feature-xyz -k "auth" -v # branch / keyword filters
# Search (--compact from agents; --json for scripts)
chat-history search "auth error" --compact
chat-history search "fix" --scope errors --compact # only messages with error patterns
chat-history search <full-uuid> # direct session lookup (with --timeframe: only if active in the window)
chat-history search "q" --compact --limit 30 # default limit is 15
chat-history search "q" --json # structured, for scripts
# Inspect / View / Export / Resume / Find
chat-history inspect --last # accomplishments, tools, model, tokens, files
chat-history inspect <partial-uuid>
chat-history inspect a1b2c3d4 e5f6a7b8 --brief # several sessions, a few lines each: asked, outcome, files
chat-history view <id> --plain --around 42 # message #42 (a hit's ordinal) ± 2 messages; -C N to change
chat-history view <id> --plain --grep "cloudflare|dns" --max-chars 600 --head 12 # matching messages, excerpt centred on the match
chat-history view <id> --plain --tail 6 # last 6 messages (--head N for the first N)
chat-history view <id> --plain --role user # only what the person said (user | assistant | tool, comma-separated)
chat-history view <id> --plain # whole transcript, pipe-friendly (--tools for tool names; -n numbers messages)
chat-history view <id> --json --around 42 # the same selections as data: ordinal, role, timestamp, content, tools
chat-history export <id> -o session.md
chat-history resume <id> # Claude Code, Codex, or any Cursor chat with a CLI store
chat-history find <id> # print transcript file path for scripting
chat-history completions zsh # shell completions (bash/zsh/fish/elvish/powershell)--scopevalues:all(default),errors(messages with error patterns or the word "error"),similar(user messages only — similar past queries),tools(messages with tool calls),files(messages referencing files). Every scope, includingall, searches full transcripts.- Shared filters on every subcommand:
--from/--to,--source,--project,--branch,-k,--sidechains(include hidden subagent sessions).
Interpreting output
- Display tags:
claude= Claude Code,cursor-ide= Cursor IDE sidebar (SQLite; IDE Agent also writes jsonl with the same id — still listed once ascursor-ide),cursor-agent= Agent CLI / jsonl-only,codex= Codex;★ N.N= relevance score.--source cursor/cursor-agent= Agent transcripts plus CLI chat metadata and hook-registered paths;--source cursor-ide= SQLite. - Header line has
DIR:(spawn directory). Title is on the next line. Pass the short ID tofindfor any row and toinspect/view/exportfor rows with a transcript ([metadata only]rows refuse those three), and toresumeforclaude/codexrows and any Cursor row whose id has a~/.cursor/chatsstore. Cursor rows without one are found in the sidebar by title +DIR:. COPIES: Nmeans the same Cursor Agent session id exists in more than one project folder;inspect/resume/findpick one copy (cwd match, else newest) and print the others.- Accepted dates:
YYYY-MM-DD,today,yesterday,"3 days ago","last week","last month".
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

