Reflex
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**Instant local code search — CLI, scripts, and AI agents**
Reflex is a local-first, full-text code search engine. Use it from the command line, pipe it into scripts, or connect it to AI coding assistants (Claude Code, Cursor, and any MCP-compatible tool) for instant symbol lookup, dependency analysis, and codebase exploration — fully offline, fully deterministic, no cloud required.
---
Quick start
1. Install
2. Index and search
3. (Optional) Connect to an AI agent via MCP
With Claude Code:
"alwaysLoad": true makes Claude Code load Reflex's tool schemas at session start, so the
agent can call Reflex at once instead of first spending a turn on ToolSearch. The plain
claude mcp add --scope user reflex -- rfx mcp also works, without it.
For other MCP clients, register a stdio server with command rfx and args ["mcp"].
Your AI assistant can now call search_code, find_references, get_dependencies, and more.
> See Claude Code + Reflex MCP Quickstart for MCP setup, key tools, and troubleshooting.
---
Why Reflex vs. built-in search tools
| Capability | grep / ripgrep | Built-in AI search | Sourcegraph | **Reflex** |
|---|---|---|---|---|
| Full-text search | ✅ | ✅ | ✅ | ✅ |
| Symbol-aware filtering | ❌ | Partial | ✅ | ✅ |
| Dependency analysis | ❌ | ❌ | Partial | ✅ |
| Deterministic results | ✅ | ❌ | ✅ | ✅ |
| Local-first / offline | ✅ | ❌ | ❌ | ✅ |
| MCP server built-in | ❌ | — | ❌ | ✅ |
| JSON output for agents | Manual | ✅ | ✅ | ✅ |
Measured efficiency (A/B vs. built-in AI search)
The A/B harness in benches/efficacy/ runs Claude Code on the same
code-search tasks with Reflex (via MCP) and with its built-in Grep/Glob, paired per task,
on pinned checkouts of Reflex, ripgrep and tokio. Measured on Reflex 2.0.3, 2026-09-28,
8 trials per task and arm. Ratios are Reflex ÷ built-in, so **> 1.0 means Reflex costs more**.
| Tasks | Model | Tokens (95% CI) | Cost | Turns (median) | Accuracy |
|---|---|---|---|---|---|
| 9 find-all-usages | Opus 5.5 | **1.66** [1.05, 1.69] | 1.27× | 2 → 3 | equal (both near-perfect) |
| 9 find-all-usages | Sonnet 5 | **1.65** [1.06, 2.25] | 2.07× | 2 → 4 | Reflex more complete on 6 of 9 tasks |
| 13 comprehension / cross-module | Opus 5.5 | **1.26** [1.07, 1.30] | 1.10× | 6 → 6 (B more in 55 of 104 pairs, fewer in 27) | equal recall |
**What drives the cost.** It is round-trips, not payload. Claude Code defers MCP tool
schemas, so the first Reflex call costs an extra ToolSearch turn; Sonnet 5 also added
check_index_status calls. Trials where the agent ignored Reflex cost the same as the
control (1.04–1.07×); trials that used it cost 1.55–1.68×. Columnar results already save
about 20% of bytes per call, which the extra turns outweigh.
**Honest reading.** Reflex does not save tokens over built-in search in these agent runs.
Its value is capability: symbol-aware search, dependency analysis, find_references in one
call, exact counts without loading content, and more complete answers from weaker models on
large result sets. Full method, per-task tables and limits: .context/EFFICACY-2.0.3.md.
---
Performance
Measured on a Kubernetes checkout (27,448 indexed files, 245 MB of text) on a 16-core machine with an NVMe disk, release build:
| | before 2.0.0 | 2.0.0 |
|---|---:|---:|
| rfx index from scratch | 532 s | **7.7 s** |
| Background symbol pass | 44.9 s | **3.4 s** |
| Symbol cache on disk | 256 MB | 29 MB |
| Peak memory while indexing | 1.37 GB | 1.05 GB |
The index files are byte-identical before and after, so query results and latency did not change with the indexing rewrite. On the Linux kernel, the symbol pass that used to stall part-way now completes in seconds.