AgentEdit CLI
Use agentedit for safe, targeted file changes. Prefer it over broad patch parsing when the caller can describe edits as explicit replacements, inserts, line-range updates, appends, or writes.
Invoke the Tool
Prefer the installed binary when it exists:
agentedit -spec edits.yaml
If working inside this repository or the binary is not installed, run:
go run ./cmd/agentedit -- -spec edits.yaml
Choose Actions
- Use
replacefor one exact old-to-new substitution. - Use
replacewithreplace_all: trueonly when every match should change. - Use
insert_beforeorinsert_afterwith one exactanchor. - Use
replace_linesfor deterministic line-range rewrites. - Use
appendto add content at the end of a file. - Use
writefor full-file replacement or creation.
Apply Good Defaults
- Keep
-fail-on-noop=trueso missed matches fail loudly. - Use
-dry-runfirst when the edit target may have drifted. - Prefer narrow anchors and exact old strings to avoid ambiguity.
- Set
create: trueonly when the task really intends to create a file.
Example Spec
edits:
- path: README.md
action: replace
old: "Small Go CLIs"
new: "Small, deterministic Go CLIs"
- path: config.toml
action: insert_after
anchor: "[server]\n"
new: "port = 8080\n"
Run it:
go run ./cmd/agentedit -- -spec edits.yaml -dry-run -format text