Skip to content

Search

aichat search provides super-fast full-text search across all your Claude Code and Codex CLI sessions, powered by a Rust/Tantivy search engine. It offers a pleasant TUI for interactive browsing and a --json mode for agent consumption.

Session chains get long. You might have 50+ sessions in a lineage, each with thousands of lines. Grepping through JSONL files does not scale. aichat-search uses Tantivy (the engine behind Quickwit) to index sessions on first run, then returns results in milliseconds. The index updates incrementally on every aichat command.

The search engine is a separate Rust binary. Pick one method:

Terminal window
# Homebrew (macOS / Linux)
brew install pchalasani/tap/aichat-search
# Cargo (any platform with Rust toolchain)
cargo install aichat-search

aichat-search demo

Launch the TUI with an optional pre-filled query:

Terminal window
# Open TUI, type query interactively
aichat search
# Pre-fill a query
aichat search "langroid agent"

Inside the TUI you can refine the query, scroll results, and select a session to perform actions such as resume, export, or view.

FlagDescription
-g, --globalSearch all projects (not just current directory)
--dir PATHFilter to a specific directory (overrides -g)
--branch NAMEFilter to a specific git branch
-n, --num-results NLimit number of results
--agent claude|codex|allFilter by agent type
--after DATESessions modified after date
--before DATESessions modified before date
--min-lines NOnly sessions with at least N lines
--no-originalExclude original sessions
--no-trimmedExclude trimmed sessions
--no-rolloverExclude rollover sessions
--sub-agentInclude sub-agent sessions (hidden by default)
--exec-runsInclude headless codex exec runs (hidden by default)
--liveShow only currently running sessions
--by-timeSort by last-modified (default: relevance)
--jsonJSONL output for agents

Date formats: YYYYMMDD, YYYY-MM-DD, MM/DD/YY, MM/DD/YYYY. Optional time suffix: T16:45:23, T16:45, T16.

Most sessions on a machine that runs coding agents were never a conversation you had — they are workers other agents spawned. Search hides two such kinds by default:

  • Sub-agent sessions. Claude names these agent-*.jsonl; Codex records the spawn in the session’s own metadata.
  • Headless codex exec runs. Every codex exec invocation, whichever way it was started. Most are workers spawned by orchestrating agents, scripts and review loops — but a codex exec you run yourself is hidden too, so reach for --exec-runs when a session you started that way is missing. Interactive codex sessions are unaffected.

On a machine driving agents hard these can outnumber real sessions by ten to one, so leaving them in makes search close to useless.

Nothing is deleted, and nothing is left out of the index — it is only filtered out of the results, so you can ask for it at any time:

Terminal window
aichat search "query" --sub-agent # add sub-agents
aichat search "query" --exec-runs # add headless runs

In the TUI, open the filter menu with Ctrl-F and toggle (s) for sub-agents or (h) for headless runs; :s and :h do the same from command mode. When shown, these sessions are marked (s) and (h) in the session list.

The search engine indexes JSONL session files from:

  • ~/.claude/projects/ — Claude Code sessions
  • ~/.codex/ — Codex CLI sessions

Custom locations can be set with --claude-home and --codex-home flags, or the CLAUDE_CONFIG_DIR and CODEX_HOME environment variables.

Sub-agent and headless sessions are indexed like any other; they are hidden from results, not skipped.

The index rebuilds itself when the indexing logic changes — after an upgrade that stores new information about each session, the first run takes about a minute for a large history, then returns to incremental updates.

Terminal window
# Global search, recent sessions only
aichat search -g --after 01/15/26
# Filter to a specific project directory
aichat search --dir ~/Git/myproject
# Only Claude sessions with at least 50 lines
aichat search --agent claude --min-lines 50
# JSONL output sorted by time
aichat search --json --by-time "refactor"