multiedit tool applies many find-and-replace edits to one file in a single atomic, lock-safe operation.
Quick Start
1
Simple Usage
Apply several edits to one file in a single call:
2
Dry Run
Preview the diff without touching disk or taking the lock:
3
Inside an Agent
Give the tool to an agent so it can edit files on request:
How It Works
The tool locks the file, reads a snapshot, applies every edit in memory, then writes the result to a temp file, fsyncs it, and atomically replaces the original.Safety Guarantees
Configuration Options
Return dict:
Common Patterns
Batch a rename across a file
Target a specific line
Best Practices
Use dry_run=True for previews
Use dry_run=True for previews
No lock is taken, no write happens, but you still get the diff.
Keep old distinctive
Keep old distinctive
The first exact match wins; if the same substring appears multiple times, include enough surrounding context to disambiguate (or pass
line as a hint).Windows: cross-process safety is best-effort
Windows: cross-process safety is best-effort
fcntl is unavailable on Windows, so the lock context is a no-op there. Do not run multiple concurrent multiedit() calls on the same file on Windows.Related
File Tool Workspace Confinement
How
multiedit honours PRAISONAI_WORKSPACEProtected Paths
How
multiedit refuses to edit sensitive files (.env, credentials)
