Skip to main content
Glama
patchloom

Patchloom

Official

apply_patch

Applies unified diffs, Codex Begin Patch envelopes, or Aider SEARCH/REPLACE blocks to modify files. Supports exact-match replacement, file deletes, and three-way merges for stale context.

Instructions

Apply a unified diff, a Codex *** Begin Patch document, or an Aider SEARCH/REPLACE / DiffFenced document. The diff parameter is the full unified diff text, a *** Begin Patch ... *** End Patch envelope (Add/Update/Delete/Move), or <<<<<<< SEARCH / ======= / >>>>>>> REPLACE blocks (path on the first line after SEARCH). SEARCH/REPLACE is unique by default (multi-match is ambiguous, no write); set replace_all=true to update every exact match. Empty-hunk +++ /dev/null (git deleted file mode, no hunks) unlinks. A hunked delete applies minus lines first; leftover bytes rewrite the file (preview --diff). Stale minus lines are ambiguous and the file is not removed; regenerate minus lines or use file.delete for path-only unlink. Use on_stale=merge for three-way merge on stale unified-diff context; allow_conflicts=true writes conflict markers. Never commit files containing conflict markers. IMPORTANT: do NOT issue concurrent patches/writes against the same files; use execute_plan for multi-op atomicity. Example: {"diff": "--- a/file.txt\n+++ b/file.txt\n@@ -1 +1 @@\n-old\n+new", "on_stale": "fail"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffYes
strictNoRoll back all writes when format/validate lifecycle steps fail.
on_staleNofail
replace_allNoSEARCH/REPLACE only: update every exact match. Default unique.
allow_conflictsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.32.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden, and it delivers. It discloses unique-match ambiguity leading to no write, empty-hunk unlink behavior, hunked-delete ordering, leftover-byte rewrites, stale-line ambiguity, three-way merge on on_stale=merge, conflict-marker writing, and the warning to never commit conflict markers. This is exceptionally transparent about edge-case behavior.

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

Conciseness4/5

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

The description is long but every sentence carries substantive information about formats, edge cases, or usage warnings. The density is justified by the tool's complexity. It could be slightly better organized with paragraph breaks, but the front-loaded purpose and example at the end keep it functional.

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?

For a write tool with multiple input formats, ambiguity handling, and conflict behavior, the description is complete. It includes an example, covers all parameter semantics, warns about concurrency, and explains how to handle stale diffs. No output schema is present, but for a mutating tool the input and behavioral coverage is sufficient.

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?

Schema description coverage is only 40%; diff, on_stale, and allow_conflicts lack schema descriptions. The description explains the diff parameter's accepted formats in detail, clarifies on_stale=merge behavior, and states that allow_conflicts=true writes conflict markers. It also clarifies replace_all semantics beyond the schema. This fully compensates for schema gaps.

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 opens with a specific verb and resource: 'Apply a unified diff, a Codex *** Begin Patch document, or an Aider SEARCH/REPLACE / DiffFenced document.' It enumerates three distinct input formats, making the tool's scope concrete and separating it from siblings like apply_fragment or replace_text.

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

Usage Guidelines4/5

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

The description provides actionable usage routing: use file.delete for path-only unlink, use execute_plan for multi-op atomicity, and avoid concurrent patches. It also explains when to set replace_all=true and on_stale=merge. It doesn't systematically compare against all sibling tools, but the guidance it does give is explicit and practical.

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