Skip to main content
Glama

code_patch

Preview and apply reversible patches to code, markdown, or config files; create new files or edit text you already read using a read reference or file locator.

Instructions

Edit any text file (code, md, config) — a reversible alternative to Edit/Write: patch text you already read (pass its read_ref), or create:true + content + locator.file_path. dry_run default: preview; false applies.

Input Schema

NameRequiredDescriptionDefault
patchNoFor patch {old_string, new_string}; old_string exact, unique.
createNoNew file: content + locator.file_path.
safetyNoValidation gate: {profile: standard|strict|fast, block_on_validation_error: boolean}.
contentNoFor replace_symbol.
dry_runNotrue = preview; false = apply.
locatorNoAnchor {file_path, name}/{symbol_id}.
task_idYesTask id.
boundaryNoreplace_symbol: full (default, includes signature) or body (body only).
read_refNoPreferred; supplies base_version.
edit_modeNopatch default; replace_symbol: content.
request_idNoIdempotency key.
workspace_dirYesProject root (abs).
preserve_decoratorsNoreplace_symbol: keep decorators (default true).
allow_unsafe_no_baseNoForce write without a prior file-level read (default false; gate).
expected_state_revisionNoOptimistic guard.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.28

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the behavioral burden and usefully discloses reversibility, `dry_run` preview default, and read-before-write via `read_ref`. However, for a 15-parameter mutation tool it omits validation-gate behavior, unsafe-write override, idempotency, and what happens when `dry_run:false` applies changes.

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?

The description is dense and front-loaded: purpose, modes, and the important `dry_run` default are all stated without wasted words. Every sentence earns its place.

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

Completeness3/5

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

The schema fully covers parameters, and the description gives the core workflow for patch/create and preview/apply. But with no annotations and no output schema, it should say more about validation behavior, idempotency, and return/result semantics for a complex mutation tool.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters. The description adds some context for `read_ref`, `create`, `content`, and `dry_run`, but leaves many parameters such as `safety`, `boundary`, `preserve_decorators`, and `expected_state_revision` to the schema.

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

Purpose4/5

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

States a specific verb, 'Edit', and a clear resource, 'any text file (code, md, config)', plus two operation modes. It positions itself as a reversible alternative to Edit/Write, but does not explicitly differentiate from sibling `edit_transaction`.

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?

Explains when to use patch mode with `read_ref` for text already read, and when to use `create:true` with `content` and `locator.file_path`. It also states the `dry_run` default behavior, though it gives no explicit when-not guidance or sibling comparison.

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