Ripgrep-style search plus safe, transactional, AST-aware rewrites with built-in undo. Designed first for LLM coding agents, useful for humans.
Binary: gw
cargo install grepwrite(Homebrew formula in progress. Prebuilt binaries: planned.)
Locate matches via ripgrep, or via ast-grep with --in function|class|imports|comments.
$ gw find TODO src/
src/lib.rs
1:4: // TODO: rename foo to bar
src/main.rs
2:8: // TODO: wire up cli
Preview by default; --apply writes atomically with a git snapshot.
$ gw rewrite 'foo' 'bar' src/ -o diff # preview
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-// TODO: rename foo to bar
-pub fn foo() -> u32 {
+// TODO: rename bar to bar
+pub fn bar() -> u32 {
42
}
...
$ gw rewrite 'foo' 'bar' src/ --apply # write
...
applied (snapshot: 2026-05-31T19-52-42-9ceabf)
Restores files exactly, refusing to clobber edits you made on top.
$ gw undo
undone: 2026-05-31T19-52-42-9ceabf (2 files restored)
Lists snapshots, newest first.
$ gw snapshots
2026-05-31T19-52-42-9ceabf 2026-05-31T19:52:42Z 3 edits -
compact (default — rg-style for find, unified diff for rewrite), caveman (LLM-token-minimal path:line per match), json (stable schema v1), diff (unified, rewrite only).
gw wraps two excellent existing tools — ripgrep for regex search and ast-grep for structural search — and adds the missing piece: a safe, transactional rewrite layer with built-in undo.
ripgrep deliberately stops at preview: rg -r prints what it would write without writing. The conventional workaround is to chain rg with sed -i and a read-after-write check, which works but is brittle in scripts and especially hostile to LLM coding agents — three tools, three failure modes, tokens spent reconciling each step.
gw collapses that chain into one binary: locate, plan, dry-run by default, and atomic per-file writes wrapped in a git-ref snapshot when you commit to --apply. The locate layer is unchanged — it's just ripgrep and ast-grep underneath — so search semantics are exactly what you already know.
- Contributing & build instructions — build, test, lint, debug, credits.
- Smoke testing in Docker — ephemeral fixtures for manual exploration.
- Release procedure — versioning policy and release recipes.
MIT. See LICENSE.