Skip to main content
Glama

batch_edit

Apply multiple exact edits to one file atomically. Returns partial success details for any failed edits, allowing retry without reapplying all changes.

Instructions

Apply many exact edits to one file in a single atomic call.

Preferred over repeated edit calls on the same file: one response, applied atomically, faster on large files. Partial success is allowed — any failed edits are returned with their reason so you can retry just the misses (status is edited when all apply, partial when some fail, no_changes when none do). For edits across different files, call the tool once per file.

edits is a JSON array; each entry is one of:

  • [old, new] — exact find/replace.

  • [old, new, start_line, end_line] — find/replace confined to a range.

  • [null, new, start_line, end_line] — replace that line range wholesale.

  • {"old": ..., "new": ..., "start_line": ..., "end_line": ...} — object form.

Prefer line-range entries when you already have line numbers from read.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to modify (absolute, or relative to root).
editsYesJSON array of edit entries, in any of the forms above.
dry_runNoPreview without writing.
show_diffNoReturn the full diff even on a deterministic all-success batch.
auto_formatNoRun the formatter after all edits.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffNo
pathNo
failedNo
paramsNo
statusNo
failuresNo
outcomesNo
succeededNo
truncatedNo
diff_stateNo
diff_statsNo
from_cacheNo
content_hashNo
diff_omittedNo
tokens_savedNo
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses atomicity, partial success (statuses: edited, partial, no_changes), and various edit formats. No annotations provided, so description carries full burden and does so comprehensively. No contradiction with annotations (none exist).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured: starts with purpose, then usage advice, then behavior, then parameter details, then closing preference. Every sentence adds value; no repetition or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all essential aspects: atomicity, partial success, edit formats, when to use, and when not. With an output schema present, the description need not detail return values. Fully adequate for a complex tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds significant value by detailing the edit entry formats (array and object forms, including line-range options), which are not fully captured in the schema's description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Apply many exact edits to one file in a single atomic call,' specifying a specific verb, resource, and scope. It distinguishes from sibling tools like 'edit' by noting it is preferred for multiple edits on the same file.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance on when to use this tool over repeated 'edit' calls, with rationale (atomic, faster, one response). Also specifies when to call the tool per file (different files) and explains partial success handling.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CoderDayton/semantic-cache-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server