**TL;DR:** `fedit` is a small Go CLI that does line-addressable file edits (show / insert / delete / replace / replaceall / map / find / insertafter / insertbefore / write). It also ships an **MCP server** so Claude/Cursor/etc. can call the same ops as tools instead of regenerating whole files. MIT, single binary, no deps. Repo: https://github.com/amalexico/fedit
---
### Why this exists
Like a lot of you, I've been letting LLMs touch my configs — Terraform modules, Helm values, nginx blocks, GitHub Actions workflows, Ansible playbooks. The failure mode is always the same:
- I ask for a 3-line change in a 400-line file.
- The model rewrites the whole file.
- Two unrelated keys get reordered, a comment vanishes, an indent flips from 2→4 spaces somewhere on line 217, and a heredoc gets "helpfully" reformatted.
- `terraform plan` now wants to recreate half my infra. Cool.
The root cause: text generation is non-deterministic and whole-file rewrites have no surgical primitives. So I gave the model surgical primitives.
### What fedit does
Ten operations, all addressable by line number **or** by content match:
```
show Display lines (whole file or range)
insert Insert after line N
delete Delete line N or range
replace Replace line range
replaceall Global find-and-replace
write Overwrite file
map Structural overview (functions/classes/blocks)
find Find lines matching substring
insertafter Insert after a matching line ← preferred
insertbefore Insert before a matching line ← preferred
```
`map` understands 17 languages: Go, HTML, SQL, Python, JS, TS, CSS, Rust, Java, C#, YAML, TOML, Markdown, Ruby, PHP, Dockerfile, Makefile. So an agent can ask "where's the `resource "aws_s3_bucket"` block?" and get an answer without reading the whole file into context.
Every mutation supports `-v` which prints a `=== STATS ===` block (op, file, match, line delta, elapsed) so the agent can verify its own edit landed.
### Demo (4-op workflow)

Recorded with vhs — `demo.tape` is in the repo if you want to reproduce it.
### MCP server mode
`fedit mcp` starts a JSON-RPC 2.0 server on stdin/stdout exposing all 10 ops as MCP tools (`fedit_show`, `fedit_insertafter`, `fedit_replaceall`, etc.). Drop it in your Claude Desktop / Cursor / Continue config and the model edits files through tool calls instead of regenerating them.
There's also a `SKILL.md` (Anthropic Agent Skills format) in the repo so Claude picks up the usage conventions automatically.
### Benchmark
I ran the same 7 editing tasks (T1–T7: insert middleware, delete dead handler, rename across file, swap a YAML key, etc.) across **Claude, ChatGPT, and Gemini**, comparing free-form whole-file edits vs. fedit-mediated edits. Full table is in the README. Short version: free-form rewrites silently corrupted unrelated lines on 4–6 of 7 tasks depending on the model; fedit-mediated edits were byte-exact on all 7 across all three.
Not claiming this is rigorous science — it's a reproducible smoke test. Tape is in the repo, run it yourself.
### Install
```bash
go install github.com/amalexico/fedit@latest
```
Single binary, no runtime deps, MIT license.
### What I'd love feedback on
Op set — anything missing for your IaC / config workflows? (someone in r/golang asked for `swap-lines`, considering it)
The `map` language list — what should I add? Thinking HCL/Terraform next, given the audience here.
MCP tool schemas — if you've wired this kind of thing into an agent before, am I exposing the right surface area?
---
*Disclosure: I used LLM assistance writing parts of fedit and this post. The benchmark, tape, and code are mine and reproducible from the repo.*