Skip to main content
Glama
patchloom

Patchloom

Official

ast_replace

Destructive

Replace text only within a named code symbol's body using AST scoping; changes stay confined to that symbol, leaving other code untouched.

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. Example: {"path": "src/lib.rs", "symbol": "parse_config", "old": "unwrap()", "new": "expect("parse failed")"}

Input 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

A3.9/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true / readOnlyHint=false, so the safety profile is known, but the description adds real value by bounding the blast radius: 'only changes code inside the named symbol, leaving everything else untouched.' It still omits failure behavior (e.g., symbol not found, no match) and regex semantics, which keeps it from a 5.

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?

Front-loaded with the purpose, then the scoping guarantee and a compilable example. The second sentence slightly restates the first ('only within symbol's body' vs. 'only changes code inside the named symbol'), so it is efficient but not perfectly tight.

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

Completeness4/5

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

For a 6-param destructive tool with no output schema, the description covers scope and usage form well and annotations carry the safety profile. It leaves gaps around error/no-match behavior and how the regex flag interacts with symbol scoping.

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 every parameter including aliases. The example usefully shows path/symbol/old/new used together, but the description adds no extra semantics (e.g., regex + symbol interaction) beyond the schema, making the baseline 3 appropriate.

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) with a precise scope (text only within a named symbol's body, via AST scoping) that distinguishes it from generic siblings like replace_text and from ast_replace_symbol. The example makes the operation concrete and actionable.

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

Usage Guidelines3/5

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

The description implies when to use it (scoped, symbol-local replacement vs. whole-file replacement), but never names an alternative tool or states a when-not condition. An agent must infer that replace_text is the unscoped counterpart rather than being told.

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