Skip to main content
Glama

batch_edit

Apply multiple independent edits to one file in a single operation, with support for partial success and line-range replacements.

Instructions

Apply multiple exact edits to one file in a single call.

Use this when several independent edits belong in the same file. For one change, prefer edit. For cross-file work, call the relevant tools per file instead of trying to batch across files.

Supported entry forms:

  • [old, new] for full-file exact replacement

  • [old, new, start_line, end_line] for scoped replacement

  • [null, new, start_line, end_line] for line-range replacement

  • {"old": ..., "new": ..., "start_line": ..., "end_line": ...}

Behavior:

  • Partial success is allowed.

  • Failed edits are returned so you can retry only the misses.

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

  • Deterministic all-success batches omit full diffs unless show_diff=true or debug mode is enabled.

Args: path: File path to modify. edits: JSON array of edit entries for that file. dry_run: Preview without writing. auto_format: Run formatter after edits. show_diff: Return the diff explicitly for successful deterministic batches.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
editsYes
dry_runNo
auto_formatNo
show_diffNo

Output Schema

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

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

Describes partial success, retry behavior, and deterministic diff conditions. No annotations, so description does the job well, though it could explicitly state that the file is modified.

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?

Efficiently structured with intro, usage, supported forms, behavior, and args. No unnecessary words.

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?

Given 5 parameters, 2 required, and output schema exists, description covers all aspects: purpose, usage, parameters, behavior. Complete and actionable.

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

Parameters5/5

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

With 0% schema coverage, description explains all parameters: path, edits (with entry forms), dry_run, auto_format, show_diff. Adds significant meaning beyond schema.

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?

Clearly states 'Apply multiple exact edits to one file', specifying verb and resource. Distinguishes from sibling tools like 'edit' and cross-file work.

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?

Explicitly indicates when to use ('several independent edits in same file') and when not ('for one change prefer edit', 'cross-file work use per-file tools').

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