One Rust binary replaces the rg + fd + ast-grep + cat + sed chain. Every step shares one index and one coordinate system, results are always fresh, and edits from two agents never silently overwrite each other.
curl -fsSL https://raw.githubusercontent.com/CREE1116/lancet/main/install.sh | shThe index only decides which files not to open. Search, read and edit agree on every line number. Every write is a compare-and-swap.
lancet index
$ lancet rg -w retries src src/net.rs:2: let retries = 3; src/net.rs:3: retries
$ lancet read src/net.rs --json rev e70d5a898f122a62 1 | pub fn retry_limit() -> u32 { 2 | let retries = 3; 3 | retries 4 | }
$ lancet edit src/net.rs \ --find 'let retries = 3;' \ --with 'let retries = 5;' \ --rev e70d5a898f122a62 --apply - let retries = 3; + let retries = 5; applied: lines 2-2, rev 1486bdffbc06c68f
lancet edit --rev0 / 800updates lost; losers got conflict and retriedA trigram index picks candidate files; every candidate is checked by the same evaluator a full scan uses. Files edited since indexing are found by mtime/size/ctime/inode and scanned live. No daemon to run.
lancet rg takes ripgrep's flags and prints ripgrep's output, checked byte for byte on 8 codebases. It reads .gitignore, .rgignore, globs and --type the same way.
lancet ast '$X.unwrap()' --rewrite '$X?' in 24 Tree-sitter languages, with $$$ARGS and statement metavariables. A rewrite is a dry-run diff until --apply.
read --symbol, line ranges, PDF pages and spreadsheet cells, all under a token budget. On the same lookups it used 5–30× less context than reading whole files.
edit, patch and AST rewrites write through one locked compare-and-swap. A stale --rev gets conflict and writes nothing. Symlinks, hard links and file mode are kept, and edits that add syntax errors are refused.
PDF, DOCX, PPTX, XLSX, HWP, EPUB, ZIP and TAR are extracted in-process, with caps against decompression bombs. A hit on line 42 of a .docx is line 42 in read too.
Speedup over ripgrep on rare-literal queries. auto checks freshness on every query (the default); trust answers from the index alone (--trust-index). Every text result was compared byte for byte with ripgrep's.
| Codebase | Files | Index build · size | auto vs rg | trust vs rg | AST vs ast-grep |
|---|
Where lancet doesn't win: regexes with no literal text (the index can't narrow them, so it runs at ripgrep's speed or up to 1.4× slower) and AST patterns with no literal text (0.6–1.0× ast-grep's speed). Benchmarks & competitor tradeoffs → · Full tables →
Each row was reproduced with the real tools by bench/failure_modes.py.
| Chain | What happened | lancet |
|---|---|---|
rg -n → two sed -i edits | The second edit hit the wrong line; both exited 0 | edit --edits uses the original line numbers |
| 4 agents: read → change → write back | 600 of 800 updates lost, silently | edit --rev: 0 of 800 lost |
patch -p1 with one stale hunk | One file changed, one rejected: half-applied | patch: nothing written, conflict |
sed rename | Also rewrote comments and strings (0.3–11.7% of occurrences) | refs / ast only touch code |
rga → pandoc on a .docx | 0 of 40 lines read held the hit | 40 of 40: search and read share one extraction |
| zoekt right after editing 20 files | New text found in 0, deleted text still found in 20 | auto mode: 20 and 0 |
sed -i / perl -pi | Broke hard links and symlinks, lost mode 0640 | Same file: links, mode and owner kept |
# optional: build the index once (it updates itself afterwards)
lancet index .
lancet fd --tree --dirs --max-depth 2 .
lancet refs --rank '*Service' --kind class src
lancet rg -w spin_lock src
lancet read src/search.rs --symbol execute_one
lancet ast '$X.unwrap()' src --lang rs --rewrite '$X?'
lancet edit src/net.rs --find 'retries = 3' \
--with 'retries = 5' --rev <REV> --apply
lancet rename src/net.rs:12 old_var new_var --rev <REV> --apply
git diff | lancet patch --apply
# 1. Register built-in MCP server (Claude Code) claude mcp add --transport stdio lancet -- lancet mcp --root . # Cursor / Codex / Antigravity: see docs/guides/agents-mcp.html # 2. Install official skill (SKILL.md + references/) # Copy skills/lancet/ to ~/.claude/skills/, ~/.codex/skills/, # ~/.gemini/config/skills/, or .agents/skills/ # 3. Optional 1-liner in AGENTS.md / CLAUDE.md: Use lancet (lancet_* MCP or CLI) instead of rg/fd/ast-grep/cat/sed; follow the lancet skill for read --rev -> edit --apply.