Skip to main content
Glama
patchloom

Patchloom

Official

ast_replace

Replace text only inside a named symbol's body using AST scoping, leaving all other code unchanged. For atomic multi-file edits, use execute_plan instead.

Instructions

Replace text only within a specific symbol's body using AST scoping. Precise: only changes code inside the named symbol, leaving everything else untouched. IMPORTANT: do NOT issue concurrent writes against the same file or directory tree; use execute_plan for multi-op atomicity. Example: {"path": "src/lib.rs", "symbol": "parse_config", "old": "unwrap()", "new": "expect("parse failed")"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
newYesReplacement text. Alias `to` accepted because agents often emit that name (LLM prior).
oldYesText or regex pattern to find. Alias `from` accepted because agents often emit that name (LLM prior).
langNoLanguage hint.
pathYesFile containing the symbol (relative to working directory).
regexNoTreat `old` as a regex pattern.
symbolYesSymbol name to scope the replacement to.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.32.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the burden and it discloses meaningful behavior: the replacement is scoped to the symbol body and leaves all other code untouched. It also warns about concurrency safety. It does not mention error cases (e.g., symbol not found) or return/result format, but the core side-effect profile is clearly conveyed.

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?

Three purposeful sentences plus a compact example. The main behavior is front-loaded, the critical concurrency warning is prominent, and every sentence contributes either scope, safety, or usage guidance.

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?

Provides the core behavior, an example, and a concurrency rule, but leaves ambiguity about whether all matching occurrences inside the symbol are replaced or only the first, what happens if the symbol or old text is not found, and what output the tool returns. For a mutation tool with no output schema and no annotations, these are meaningful gaps.

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 the baseline is 3. The description adds a concrete usage example that demonstrates path, symbol, old, and new, giving agents a clear pattern for emitting values. It reinforces the meaning of the symbol parameter as the AST scope boundary.

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?

States a specific verb ('Replace'), resource ('text within a specific symbol's body'), and method ('AST scoping'). It explicitly differentiates itself from broad text editing by claiming only the named symbol's body is changed, which distinguishes it from sibling tools like replace_text or batch_replace.

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?

Clearly establishes when to use it: when a precise, symbol-scoped replacement is needed and everything else must remain untouched. It also provides an atomicity guideline ('use execute_plan for multi-op atomicity') and warns against concurrent writes, but it does not explicitly name non-scoped alternatives or state when to prefer them.

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