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 agent decides what the new text says. kapi handles the rest: it keeps the inline codes, refuses a write to a block that changed since it was read, and runs the check that confirms the sweep is complete. 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 findings count on the project's Map shows exactly which blocks are affected and how many.
- After: click Run on everything on the Map 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 blocks back to pending; Bring up to date re-translates just those, and the Review queue picks up anything that waits for review.
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, with its reference (ref), its revision (rev), 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"). Those calls need judgment, so an agent does them and
sedcannot. kapi applylands the change set. Each operation carries the revision it read, so a block someone changed since the read refuses the change set with its current text, and a concurrent edit can't be clobbered.kapi check --forbid "Acme Sync"proves completion: exit 0 means the sweep is done.
Make the retired name a permanent term, so a later use of it fails a check. Recording a term is your decision, so the assistant suggests it and you keep it, or you add the term operation to the change set you apply.
The same loop with you (or a script) as the writer:
kapi inspect docs/**/*.md report.docx --jsonl > blocks.jsonl
# write a replace_text or set_content operation per matching block to
# edits.json, with the block's ref and rev; keep the <x id="…"/> tags
kapi apply edits.json --dry-run # preview the whole sweep, one diff per document
kapi apply edits.json --in-place=.bak # land it, keeping backups
kapi check docs/**/*.md --forbid "Acme Sync" # prove it's done
For a plain substitution that needs no judgment, ksed -i 's/Acme Sync/Acme Flow/g' or kapi voice rewrite does it deterministically: no agent, no model. The change set's shape and what refuses an edit 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.