Bulk rewrite with an agent
Goal: apply one editorial change everywhere (rename a product, retire a phrase, soften a tense) across files your editor can't even open (.docx, catalogs, HTML, Markdown), without risking structure. The division of labor: the agent decides what the new text says; kapi guarantees everything else: inline codes preserved, drift-guarded writes, and a check gate that proves the sweep is done. No second model is involved in the write.
- Desktop
- Agent (Claude)
- CLI
The sweep itself is agent- or CLI-driven; Desktop is where you verify it:
- Before: bind the rule that motivates the sweep (a forbidden term, a required phrasing) in the project's voice profile, so the Checks view shows exactly which blocks are affected and how many.
- After: re-run the Checks view to confirm the count is zero, and spot-check the edited files in the preview: structure, styles, and placeholders intact.
For translated content, an edited source drops affected units back to pending; Bring up to date re-translates just those, and the Review queue picks up anything that parks.
State the change once, over the whole set:
We renamed "Acme Sync" to "Acme Flow". Update every mention across
docs/andsrc/locales/en/(including the.docxone-pagers) and keep the formatting.
The assistant runs the loop at scale:
kapi inspect --jsonlover the set: one record per block, withid,content_hash, and the text (inline codes as<x id="…"/>placeholders).- It rewrites only the blocks that mention the term, judgment calls included ("Acme Sync's engine" → "the Acme Flow engine"), which is why this is an agent job rather than a
sedjob. kapi applylands the change-set; any block whose hash drifted since the read is left unchanged and reported, so a concurrent edit can't be clobbered.kapi check --forbid "Acme Sync"proves completion: exit 0 means the sweep is done.
Make the retired term a permanent voice vocabulary rule in the same change-set, and the old name can never quietly return.
The same loop with you (or a script) as the writer:
kapi inspect docs/**/*.md report.docx --jsonl > blocks.jsonl
# rewrite the matching blocks' "text" into edits.jsonl (content entries)
# carrying each block's id + content_hash; keep the <x id="…"/> tags
kapi apply edits.jsonl --diff # preview the whole sweep as one diff
kapi apply edits.jsonl --in-place=.bak # land it, keeping backups
kapi check docs/**/*.md --forbid "Acme Sync" # prove it's done
For pure vocabulary substitution with zero judgment involved, kapi voice rewrite does it deterministically from a profile: no agent, no model. The change-set shape and the round-trip guards are in Edit content.
Next
- Edit content: the inspect → edit → apply loop and its guards, in depth.
- Content governance for AI: the standing rules that keep future output clean.
- Use with Claude: wiring the assistant that runs this loop.