Skip to main content
The 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

No lock is taken, no write happens, but you still get the diff.
The first exact match wins; if the same substring appears multiple times, include enough surrounding context to disambiguate (or pass line as a hint).
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.

File Tool Workspace Confinement

How multiedit honours PRAISONAI_WORKSPACE

Protected Paths

How multiedit refuses to edit sensitive files (.env, credentials)