Search past coding agent sessions for context and decisions
ctx is a local CLI that indexes past coding agent sessions into SQLite so agents can search prior context, not restart.
Why it matters
Enable current and future coding agents to search and retrieve context from past agent sessions-including decisions, failed attempts, commands, and discussions-so they don't repeat work or lose institutional knowledge stored in local agent history logs.
Outcomes
What it gets done
Index local agent session transcripts from 30+ tools into a fast SQLite database
Search prior sessions by natural language query or touched file paths
Retrieve ranked, cited snippets from past conversations with 50× better token efficiency than raw logs
Show full session or event context with IDs for agents to inspect original decisions
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ctxrs-ctx | bash Overview
Ctx
ctx is a local CLI that indexes past coding agent sessions into SQLite so agents can search prior decisions, commands, and failed attempts. Use it when an agent needs prior context on a repo - a failed migration, a rejected approach - rather than re-deriving it or grepping raw transcripts.
What it does
ctx is an open-source CLI that indexes your past coding agent sessions - decisions, constraints, rejected approaches, bug investigations, commands, patches, and notes - into a local SQLite database, then gives current and future agents a way to search that history instead of starting from zero. It discovers supported local provider history files, imports the real persisted records, and normalizes them into session, event, and touched-file metadata optimized for retrieval; the project reports its structured, cited search returns meaningful history using roughly 50x fewer tokens than raw transcript search (917 tokens versus 45,734 for one measured query).
When to use - and when NOT to
Use it when an agent needs to recover prior context on a repo - a failed migration, a rejected approach, or which command already broke - rather than re-deriving it from scratch or grepping raw transcripts. It is local and private by default: ctx does not send prompts, transcripts, or indexed history to a cloud service, does not call model APIs, requires no API keys, and does not write into your source repositories - though it preserves transcript text as-is rather than redacting local paths or secret-shaped strings, so review copied output before sharing it outside the machine. It is a different tool from agent-memory systems, which save compact facts, summaries, vectors, or graph nodes, and from codebase-graph tools, which map the current repo's files and symbols - ctx specifically searches the prior sessions that explain what happened while the repo was changed.
Inputs and outputs
Input: your existing local agent history files, or a search query in normal language, by file, or by multiple terms. Output: ranked, cited matches (session and event IDs) that let an agent pull the exact snippet or reconstruct the original session.
# Index all of your existing local agent sessions
ctx setup
# Your agent can search prior work with normal language
ctx search "failed migration"
# Search sessions/events that touched a file
ctx search --file crates/foo/src/lib.rs
# Or search multiple terms
ctx search --term "failed migration" --term rollback --term "cursor rename"
# Advanced: inspect exact local index data with read-only SQL
ctx sql "SELECT provider, COUNT(*) AS sessions FROM ctx_sessions GROUP BY provider"
# Print the matching part of the old transcript
ctx show event <ctx-event-id> --window 3
# Or print a compact transcript of the original session
ctx show session <ctx-session-id>
Install with curl -fsSL https://ctx.rs/install | sh (macOS/Linux/FreeBSD) or irm https://ctx.rs/install.ps1 | iex (Windows PowerShell); official installer-managed binaries can self-upgrade via ctx upgrade check, while source builds and package-manager installs stay unmanaged.
Integrations
Written in Rust with a local SQLite index for fast, scriptable, service-free search, and supports importing history from a long list of agent harnesses including Claude Code, Codex, Cursor, GitHub Copilot CLI, OpenCode, Gemini CLI/Antigravity, Windsurf, Zed, Goose, and dozens more (run ctx sources --format json to see which are importable on your machine). SDKs are available for TypeScript, Python, Rust, Go, JVM, Swift, and .NET, and a custom history-source-plugin path exists for agent formats ctx doesn't support natively.
Who it's for
Anyone running coding agents across long-lived projects who wants those agents to find prior decisions, commands, and failed attempts instead of repeating them - and agent-tooling builders wiring ctx's search into their own harness via its SDKs.
Source README
ctx is an open-source CLI for fast local search across your past coding agent sessions.
Coding agents usually start from zero. They can inspect the current repo, but they often cannot recover the discussions, decisions, failed attempts, commands, and test results from earlier work.
Those sessions are full of useful context:
- decisions, constraints, intent, and rejected approaches from you
- bug investigations, refactors, file paths, commands, patches, and notes from previous agents
ctx indexes those logs into SQLite on your machine, then gives current and future agents a CLI for finding the prior discussion, command, or failed attempt before they repeat it.
Install and set up ctx
macOS, Linux, and FreeBSD:
curl -fsSL https://ctx.rs/install | sh
Windows PowerShell:
irm https://ctx.rs/install.ps1 | iex
or prompt your agent:
Please install and set up ctx CLI (see github.com/ctxrs/ctx)
50x more token-efficient than raw transcript search
By structuring agent history into sessions, events, metadata, and indexed fields, then returning ranked cited matches, agents can access meaningful history with far fewer tokens than raw search. Results vary by query and corpus, but raw search is often so token-heavy that it can be effectively the same as not having usable history.
How it works
Your past agent sessions are stored in local provider history files. ctx discovers supported sources, imports the real persisted records, and stores normalized session, event, and touched-file metadata in a local SQLite database optimized for retrieval.
ctx is written in Rust and stores a local SQLite index, so searches are fast, scriptable, and do not require a background service.
The index is local and private by default. Transcript text is preserved rather than hiding local paths or secret-shaped strings, so review copied output before sharing it outside the machine.
# Index all of your existing local agent sessions
ctx setup
# Your agent can search prior work with normal language
ctx search "failed migration"
# Search sessions/events that touched a file
ctx search --file crates/foo/src/lib.rs
# Or search multiple terms
ctx search --term "failed migration" --term rollback --term "cursor rename"
# Advanced: inspect exact local index data with read-only SQL
ctx sql "SELECT provider, COUNT(*) AS sessions FROM ctx_sessions GROUP BY provider"
# Results include matching sessions, snippets, and ctx IDs
# evt_01h... ses_01h... codex "migration expected the old cursor name" ...
# Print the matching part of the old transcript
ctx show event <ctx-event-id> --window 3
# Or print a compact transcript of the original session
ctx show session <ctx-session-id>
Those IDs let your current agent recover as much context from previous sessions as it needs.
ctx does not send your prompts, transcripts, or indexed history to a cloud service, call model APIs, require API keys, or write into your source repositories.
The installed binary also includes local docs and man-page generation:
ctx docs search "upgrade"
ctx docs show cli-reference
ctx docs man --print ctx
Official installer-managed binaries support signed self-upgrades:
ctx upgrade status
ctx upgrade check
Source builds and package-manager installs remain unmanaged and do not self-upgrade.
For the full pipeline, see How ctx works. For a quick first run, see Quickstart.
Supported agent histories
Support means ctx can discover or read that harness's persisted local history and import it into the local search index. Use ctx sources --format json on your machine to see which sources are currently importable.
| Agent harness | Support |
|---|---|
| Claude Code | Supported |
| Codex | Supported |
| Cursor | Supported |
| Pi | Supported |
| GitHub Copilot CLI | Supported |
| OpenCode | Supported |
| Gemini CLI / Antigravity | Supported |
| Factory AI Droid | Supported |
| OpenClaw | Supported |
| Hermes Agent | Supported |
| AstrBot | Supported |
| NanoClaw | Supported |
| Shelley | Supported |
| Auggie / Augment | Supported |
| Cline / Roo Code | Supported |
| CodeBuddy | Supported |
| Continue | Supported |
| Crush | Supported |
| Deep Agents | Supported |
| Firebender | Supported |
| ForgeCode | Supported |
| Goose | Supported |
| Junie | Supported |
| Kilo Code | Supported |
| Kimi Code CLI | Supported |
| Kiro CLI | Supported |
| Lingma | Supported |
| MiMo Code | Supported |
| Mistral Vibe | Supported |
| Mux | Supported |
| OpenHands | Supported |
| Qoder | Supported |
| Qwen Code | Supported |
| Rovo Dev | Supported |
| Tabnine CLI | Supported |
| Trae / Trae CN | Supported |
| Warp | Supported |
| Windsurf | Supported |
| Zed | Supported |
How ctx compares
Agent memory tools usually save compact facts, summaries, vectors, or graph nodes. Those can help with stable preferences, but they are weak evidence when the next agent needs to know where a decision came from, what command failed, or what was rejected in the original conversation.
Graphify-style tools answer a different question. They map the current repository: files, symbols, imports, folders, and relationships. ctx searches the prior agent sessions that explain what happened while people and agents changed that repository.
ctx keeps retrieval tied to sessions and events, so another agent can inspect the source before using it. Read more about agent memory, Graphify-style codebase graphs, and grep or log search.
Explore the docs
| Page | What it covers |
|---|---|
| Install | Install ctx, initialize local storage, and index discovered local history. |
| Quickstart | Search local history, inspect an event, open the session, and use JSON output. |
| Install the ctx skill | Install the agent-history search skill with the open skills installer. |
| Package managers and unmanaged installs | Install from GitHub Releases, mise, Homebrew, or source builds. |
| Agent plugin installs | Install the ctx skill through Codex, Claude Code, Cursor, or a raw skill folder. |
| SDKs | Use ctx agent history search from TypeScript, Python, Rust, Go, JVM, Swift, or .NET code. |
| Custom history plugins | Build an advanced local adapter for agent formats ctx does not support natively. |
| Cursor | Import Cursor agent transcripts and ask Cursor to cite retrieved local history before editing. |
| How it works | Understand discovery, import, SQLite storage, search refresh, and cited retrieval. |
| Supported agents | See which agent histories ctx can discover, import, and search today. |
| CLI reference | Review setup, status, sources, import, show, locate, search, SQL, MCP, and doctor. |
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.