Skip to main content
Glama
patchloom

Patchloom

Official

ast_extract_to_file

Destructive

Extract a symbol (module, function, struct) from a source file into a target file, optionally replacing it and updating imports for safe refactors.

Instructions

Extract a symbol (module, function, struct) to a separate file. For modules with unwrap=true, content is un-indented. Example: {"source": "src/lib.rs", "symbol": "tests", "target": "src/lib_tests.rs", "replacement": "mod tests;", "prepend": "use super::*;"}

Input Schema

NameRequiredDescriptionDefault
langNoLanguage hint.
forceNoOverwrite target if it exists.
sourceYesSource file containing the symbol.
symbolYesName of the symbol to extract.
targetYesDestination file path.
unwrapNoIf true (default), remove wrapper and un-indent for modules.
prependNoContent to prepend to the target file.
replacementNoText to leave in place of the extracted block.
update_importsNoRewrite consumer `use`/import statements of the extracted symbol.
new_module_pathNoModule path consumers should import from (required with `update_imports`).
old_module_pathNoModule path consumers currently import from (required with `update_imports`).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.32.0

TDQS

B3.2/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, so the agent knows this mutates files. The description adds that modules with unwrap=true get un-indented content, which is useful behavioral context. However, it doesn't explain what gets destroyed (e.g., the source file's original block is replaced by 'replacement' text), the overwrite semantics (covered by the 'force' parameter schema), or the required preconditions for update_imports beyond what the schema already says.

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 two sentences and an example: the first states the purpose, the second highlights a specific behavioral detail (unwrap), and the example shows parameter usage. It's front-loaded and free of waste, though the example could be seen as slightly verbose.

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?

For a destructive tool with 11 parameters, no output schema, and 100% schema coverage, the description provides the core purpose and a usage example. It omits important behavioral context like the result of extraction (what happens to the original location), dependency implications (e.g., update_imports behavior), and error conditions. Adequate but with clear gaps.

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 11 parameters thoroughly. The description adds an example that illustrates how some parameters work together, but doesn't provide additional semantic meaning beyond what the schema provides. Baseline 3 is correct when schema does the heavy lifting.

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+resource: extract a symbol (module, function, struct) to a separate file. This is clearly distinct from siblings like ast_move or ast_split, which handle different refactoring operations. However, it doesn't explicitly contrast itself with the closest alternatives, so it stops short of a 5.

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

Usage Guidelines2/5

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

The description offers no guidance on when to use this tool versus alternatives like ast_move or move_file. The example provides a concrete usage scenario but doesn't articulate when or when not to choose this operation.

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