sessiongrep: A Local-First Memory Layer for CLI Agents
Turn Claude Code and Codex transcripts into something humans and agents can search, using SQLite + FTS5.
Nisarg Patel
Member of Technical Staff
May 27, 2026

If you use Claude Code, Codex, or Cursor daily: you know that agents perform best when they have maximum context. The prompt that finally worked and the migration path you ruled out are buried inside provider-specific JSONL files with opaque names that are hard to retrieve and read.
We built sessiongrep to fix that: a small, fast Rust CLI that turns your scattered local session history into something you — and your agent — can actually search.
I joined Brain.co and, like any new hire, there was a lot to learn. The pace at which Brain.co works is insane.
I was working out of three different code repositories, and using Claude Code and Codex equally. Some workflows were better on Codex, and others on Claude Code, so I was switching between coding agents and repos and it was hard to track where context was.
Codex and Claude Code treat subdirectories as its own workspace. If you start a session from some repo, in some subdirectory, that's a separate session altogether. Where was that Redis migration? What folder did I start the session in? Was I using Cursor? Codex?
And half the time I ran the resume command, the only thing I saw was /exit, because that's what I exit with, and Claude Code shows you the last command…
We built sessiongrep to fix that: a small, fast Rust CLI that turns your scattered local session history into something you and your agent can actually search.
sessiongrep Architecture
sessiongrep runs locally and no data ever leaves the original machine; this reduces compliance and risk issues. Text search and metadata storage is powered by simple and boring tech like SQLite and FTS5. The tool ships 2 small rust binaries that have fast startup and execution: sessiongrep and sessiongrep-mcp.

Session Sources
Custom adapters are needed to handle the different agent formats. The Claude adapter walks ~/.claude/projects/**/*.jsonl. The Codex adapter walks ~/.codex/sessions/**/*.jsonl and hydrates records with metadata from session_index.jsonl and state_5.sqlite. The Cursor adapter walks ~/.cursor/projects/** and then flattens thread transcripts.
Core Engine
Files are first transformed into a common Session structure by the Normalizer. Claude and Cursor subagent transcripts are excluded to avoid duplicate data. Then, metadata is stored in regular tables in a WAL-mode SQLite database. After that, fields like title, summary, preview_text, and transcript_text are indexed in a FTS5 virtual table. Search is candidate retrieval against the FTS5 table and then fuzzy matching and metadata-based ranking across title, summary, cwd, repo, preview, and transcript.
Read commands (list, search, and show) trigger a reindex for files where mtime and size have changed, which takes mere milliseconds. On a local test corpus of 149 sessions across Claude Code and Codex CLI a full full index rebuilt took 59 ms and returned a query in 18 ms.

Interfaces
CLI: controlled by the sessiongrep and exposes search, list, show, resume, export, doctor, and paths. sessiongrep resume <id> resolves the session and executes an agent specific commands like: claude --resume <id> or codex resume <id> (Cursor transcripts are indexed and searchable, but resume isn't currently supported there).
TUI: sessiongrep tui exposes a TUI built on ratatui that gives live search, a preview pane, and one-key resume.
MCP: sessiongrep-mcp exposes the session index to agents via four tools:
search_sessions: Keyword searchget_session: Full transcript by IDlist_sessions: Recent sessionsget_resume_command: Returns CLI command to resume a session
# Installation is one line:
claude mcp add --scope user --transport stdio sessiongrep -- sessiongrep-mcp
# or
codex mcp add sessiongrep -- sessiongrep-mcpAfter installation, your coding agent will automatically invoke the MCP on queries like “help me find session about Datadog metrics and pull in the part where we got the agent emits histograms”. In the background, agents can search (search_sessions), and pull relevant context (get_session).
✨ One unintended benefit was how session retrieval enabled cross-model review. For example, it’s easy to ask Claude to review a plan drafted by GPT: “find session about Azure identity rollout, review the plan like a skeptical staff engineer; call out weak assumptions, sequence risks, missed production questions”
There’s a handful of potential improvements we may add to sessiongrep in the future. We want to build out sessiongrep deliberately in a way where it stays boring and seamless.
- Related sessions: surface sessions similar to the current active one.
- MCP tools:
diff_sessions,summarize_session, andtimeline_for_repowould let agents reason across session history. - Adapters: add support for Aider, Cline, Pi or whatever the next popular agent harness is.
- Encrypted sync: for teams that explicitly want shared session context.
- Proactive index updates. A “watch” mode where new sessions become searchable immediately.
sessiongrep is open-sourced under the Apache-2.0 license. Code, issues, and PRs welcome: github.com/braincompany/sessiongrep.
Agent sessions can contain prompt injections and affect your coding agent behavior. They may also contain secrets, tokens or private keys if you pasted them in or the agent looked at them. Do not share your sessiongrep index to any device you don’t trust or check it into a code repo.



