Retrieved article excerpt
Open article · Retrieved 2026-11-01T16:27:12.147225+00:00
[sweet-search — local code search for AI coding agents](https://github.com/mrsladoje/sweet-search/blob/main/assets/sweet-search-banner-pixelated.svg)
## **🍬 Local code search for AI coding agents 🍬**
Six fast, purpose-built tools made for *Claude Code*, *Codex* & friends 👀
Every coding agent today reaches for grep + Read by reflex. *sweet-search* challenges the narrative 😎
[npm](https://www.npmjs.com/package/sweet-search)
[GitHub stars](https://github.com/mrsladoje/sweet-search/stargazers)
[license](https://github.com/mrsladoje/sweet-search/blob/main/LICENSE)
[node](https://github.com/mrsladoje/sweet-search/blob/main/package.json)
[platforms](https://github.com/mrsladoje/sweet-search#compatibility)
[inference](https://github.com/mrsladoje/sweet-search#the-index)
[video](https://www.youtube.com/watch?v=lJzgXRQprs4)
---
## ✨ Highlights
| | |
| --- | --- |
| 💰 **5–33% cheaper agent runs** on 200 real engineering tasks · 5 harness + model setups · same solve count (481 vs 481) | ⚡ **Saves your time** faster retrieval than classic grep-and-read · up to 34% less model time per code question |
| 🔄 **Index once, then forget it** one command, GPU-accelerated · updates itself as you edit, uncommitted changes included | 🔒 **100% local** no API keys · no cloud · no Docker · your code never leaves your machine |
---
## 📚 Table of Contents
| | | | |
| --- | --- | --- | --- |
| **GET STARTED** [🚀 Quickstart](https://github.com/mrsladoje/sweet-search#-quickstart) three commands to a searchable repo [🖥️ Compatibility](https://github.com/mrsladoje/sweet-search#compatibility) OS · harnesses · languages · hardware [⭐ A star pls? 🥺🙏](https://github.com/mrsladoje/sweet-search#found-it-useful) it really helps | **THE ARCHITECTURE** [🧰 The Six Tools](https://github.com/mrsladoje/sweet-search#-the-six-tools) search · grep · find · semantic · trace · read [🧠 The System Prompt](https://github.com/mrsladoje/sweet-search#-the-system-prompt) tuned for search and task completion | **INDEXING** [🗂️ The Index](https://github.com/mrsladoje/sweet-search#the-index) candle · fused kernels · cAST chunking [🔄 Incremental Indexing](https://github.com/mrsladoje/sweet-search#-incremental-indexing) reconcile daemon tracks your working tree | **THE RECEIPTS** [📊 Benchmarks](https://github.com/mrsladoje/sweet-search#-benchmarks) agent cost savings · engine speed · full-corpus MRR [🧭 The Competition](https://github.com/mrsladoje/sweet-search#-the-competition) honest wins & trade-offs vs peers [🙏 Prior Art & Acknowledgements](https://github.com/mrsladoje/sweet-search#-prior-art--acknowledgements) the shoulders we stand on |
## 🚀 Quickstart
- **Requires:** Node.js 22+
```
npm install -g sweet-search
cd your-repo
sweet-search init # one-time: wires up Claude Code
# Codex: --codex · opencode: --opencode
# several: --claude --codex --opencode
sweet-search index # builds the index — GPU-accelerated where available
sweet-search "where do we validate JWT tokens?"
```
That's it. From then on, the index updates itself as you work.
To uninstall 😢:
```
sweet-search uninstall # this repo only
sweet-search uninstall --all # everything: all repos, models, and the CLI
```
**Setup options & details**
```
sweet-search init --wizard # interactive: shows your hardware, recommends a model tier
sweet-search init --skip-models # download the models at the first index, not now (CI)
sweet-search init --li-model edge # compact late-interaction model for constrained machines
sweet-search init --codex # Codex only (per-project config, nothing under .claude/)
sweet-search init --codex --opencode # Codex and opencode
sweet-search init --claude --codex # Claude Code and Codex
sweet-search init --agents # Claude Code plus AGENTS.md for other AGENTS.md-reading tools
sweet-search init --no-claude --agents # streamlined AGENTS-only configuration
sweet-search uninstall --dry-run # preview cleanup for the current repo
```
- **Footprint** — models live in `~/.cache/sweet-search/models/` and run on-device only:
- CPU-only: a few hundred MB (INT8)
- GPU: +~1.2 GB (FP32), skipped where it wouldn't help
- M3+ Mac: optional +~3.2 GB CoreML cascade for the Neural Engine
- **Which agents** — pick with flags:
- `init` alone → Claude Code
- `--codex` / `--opencode` → only those; add `--claude` to keep Claude Code too
- `--agents` / `--gemini` / `--cursor` → also write `AGENTS.md` / `GEMINI.md` / a Cursor rule
- Indexing, `.sweet-search/` and `--mcp` are the same for every choice.
- **Claude Code** — your `CLAUDE.md` stays untouched; everything goes in `.claude/`:
- `agents/sweet-search.md`: the main agent, selected in `settings.json`. Claude Code's own prompt without its grep-first advice, plus our guide.
- `agents/general-purpose.md`, `agents/Plan.md`: replace the built-in subagents; Explore is denied.
- `rules/sweet-search.md`: a short reminder, gitignored (it names your local memory folder).
- the `/sweet-index` skill.
- Start a new session after init.
- Already chose another main agent? init keeps it, puts the full guide in `rules/` plus the `sweet-search` output style, and warns.
- **Codex** — our guide and tested base instructions in `.codex/config.toml`:
- Codex ignores `.codex/` until you trust the project; init tells you how.
- **opencode** — our guide, tested prompt and a tool-description plugin in `.opencode/`:
- An existing `opencode.json` / `.jsonc` is edited in place, comments kept.
- **Prewarm hook** (Claude Code, Codex): starts the search daemon when a session starts. Search works without it.
- **Search daemon:** the first search starts it. Manage it with `sweet-search daemon start|status|stop|restart`.
- **What gets indexed:** `.gitignore` is respected; `node_modules`, build dirs, minified files and files over 1 MB are skipped; add extra rules in `.sweet-search-ignore`. `ss-grep` also covers tracked vendored code, licenses and data files.
### MCP and other integrations
The CLI is the default contact surface. To also register the MCP server, run
`sweet-search init --mcp`, or add it to `.mcp.json` yourself:
```
{
"mcpServers": {
"sweet-search": {
"command": "sweet-search-mcp",
"args": []
}
}
}
```
- **MCP server:** 8 tools (`search`, `trace`, `read`, `read-semantic`, `index`, `health`, `repo-map`, `vocab-prewarm`), 2 resources, 2 prompts. All search tools are declared read-only and idempotent.
- **Repo maps for sub-agents:** the `repo-map` tool returns a PageRank-ranked symbol overview that fits any token budget, for briefing a delegated agent.
- **Vocabulary prewarm:** the index mines your repo's real identifiers and detects code communities (Leiden), and the daemon keeps both current as the code changes. They pre-warm all three search modes, so the first semantic query of a session is already cache-warm.
- **Committed files stay portable:** init never writes machine-specific absolute paths into committed settings files. All instruction injection is marker-delimited and reversible.
### Init flags
| Flag | Behavior |
| --- | --- |
| `--skip-models` | Download no models now; the first `sweet-search index` downloads them. Search always needs the models. |
| `--li-model standard|edge|none` | Select the late-interaction model tier or disable it. |
| `--search-reranking auto|on|off` | Control search-time late-interaction reranking. |
| `--wizard` | Choose model and reranking settings interactively. |
| `--verify-deep` | Load modules and verify checksums after setup. |
| `--force` | Re-download models even when cached. |
| `--build-coreml-cascade` | Build the optional CoreML cascade locally on eligible Apple silicon. |
| `--skip-coreml-cascade` | Skip fetching or building the CoreML cascade. |
| `--skip-dedup` | Skip near-duplicate-detection readiness checks. |
| `--skip-cuda` | Disable the CUDA backend even when available. |
| `--skip-prewarm-hook` | Do not register the Claude/Codex session-start prewarm hook. |
| `--agents` | Also write the verbatim guide to `AGENTS.md` (not needed for Codex or opencode). |
| `--codex` | Set up Codex only, in `.codex/`: guide, our base instructions, and the prewarm hook with its feature flag. |
| `--opencode` | Set up opencode only, in `.opencode/`: guide, our prompt, tool-description plugin, grep and explore off. |
| `--claude` | Include Claude Code together with `--codex` / `--opencode`. |
| `--no-lean-harness` | Keep Claude Code's own system prompt and subagents; install only the rules file and output style. |
| `--no-opencode-cache-key` | Skip the opencode cache-key plugin that lets new sessions reuse the cached prompt. |
| `--codex-enable-global-hooks` | Advanced opt-in: also enable hooks in the user-level Codex config. |
| `--no-claude` | Write nothing under `.claude/`; combine with `--agents` for AGENTS-only setup (`--codex` / `--opencode` already imply it unless `--claude` is set). |
| `--gemini` | Also write `GEMINI.md` (sharing `AGENTS.md` when enabled). |
| `--cursor` | Also write `.cursor/rules/sweet-search.mdc`. |
| `--symlink-instruction-files` | Explicitly use the default `GEMINI.md` symlink behavior. |
| `--no-symlink-instruction-files` | Use a regular `GEMINI.md` import instead of a symlink. |
| `--no-agent-instructions` | Skip all agent policy and Claude output-style installation. |
| `--mcp` | Also register the project MCP server; the CLI remains the default contact surface. |
| `--no-cli` | With `--mcp`, give agents the MCP-specific guide and remove the CLI-specific Claude output style. |
| `--enforce-tools` | Optional strict Claude mode: deny native Grep and hint native Read. |
| `--verbose`, `-v` | Print additional setup diagnostics. |
| `--help`, `-h` | Show the complete CLI help. |
### Uninstall flags and cleanup
| Flag | Behavior |
| --- | --- |
| `--all` | Remove sweet-search from this machine: every repo where `init` ran, the shared model cache, and the npm package. |
| `--dry-run` | Preview all detected removals. |
| `--force` | Skip the confirmation prompt. |
| `--help`, `-h` | Show uninstall help. |
`sweet-search uninstall` removes Sweet Search's rule, main agent and subagent
files with their settings entries, output style, AGENTS/GEMINI/Cursor instruction blocks, project hooks and skill,
MCP registration, enforcement/reminder artifacts, and `.sweet-search/` from the
current repo. The shared model cache stays for your other repos. It
preserves user-authored content. Generic Codex `[features] hooks = true` flags
are left in place because other tools may share them, and an otherwise-empty
settings file may remain as `{}`.
## 🖥️ Compatibility
| | |
| --- | --- |
| **💻 Platforms** | ✅ First-class: macOS (Apple Silicon, Intel) · Linux x64/arm64 (glibc) · Windows via WSL2 ☑️ Supported: musl/Alpine · other CPUs (slower) Node ≥ 22 everywhere What makes first-class fasterThe npm package ships a **Rust engine, compiled ahead of time** for your OS and CPU. It runs every hot path: - 🧠 **Embedding inference**: Metal, CUDA, CoreML - 🧭 **Vector search**: binary HNSW + rescoring - 🧮 **MaxSim rerank**: 9–21× faster than WASM, 80–200× faster than JS - 🔎 **`ss-grep`**: regex engine and sparse n-gram index - 🔤 **Tokenizer**, near-duplicate detection, SQLite extension - 🚀 **The `sweet-search` CLI** itself 🐢 **Supported platforms** use a WASM/JS fallback: it runs anywhere, but slower. 📦 **Zero setup**: `npm install` picks the right binary. 🪟 **Native Windows**: not yet. Use WSL2. |
| **🤖 Harnesses** | ✅ **Claude Code** · **Codex** · **opencode** *(tuned and benchmarked)* ☑️ Cursor · any MCP client · any agent with a shell *(also works)* |
| **🗣️ Languages** | JavaScript · TypeScript · Python · Go · Rust · Java · C · C++ · C# · Ruby · PHP · Kotlin · Swift · Scala · Dart · Elixir · Erlang · Haskell · Clojure · F# · OCaml · ReScript · Elm · Julia · R · Perl · Lua · Groovy · Objectiv