Skip to main content
Glama
patchloom

Patchloom

Official

ast_extract_to_file

Extract a module, function, or struct into its own file and leave a replacement declaration in the original. Rewrites imports to point to the new module path, keeping dependent code working.

Instructions

Extract a symbol (module, function, struct) to a separate file. For modules with unwrap=true, content is un-indented. IMPORTANT: do NOT issue concurrent extracts/writes against the same files; use execute_plan for multi-op atomicity. Example: {"source": "src/lib.rs", "symbol": "tests", "target": "src/lib_tests.rs", "replacement": "mod tests;", "prepend": "use super::*;"}

Input Schema

TableJSON 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

A4/5.0
Behavior4/5

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

Annotations are absent, so the description carries the behavioral disclosure burden. It reveals the un-indenting behavior for modules with unwrap=true, warns about concurrent write hazards, and illustrates a realistic invocation with the example. It does not mention side effects like source-file modification or force-overwrite behavior, but the most operationally critical traits are covered.

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 tight: one purpose sentence, one behavior note, one important warning, and one illustrative example. There is no filler, and the highest-priority warning is clearly marked. The example earns its place by clarifying the parameter relationships.

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?

Given 11 parameters, no annotations, and no output schema, the description is helpful but not fully complete. It explains core behavior and concurrency constraints, but does not clarify return values, whether the source file is modified in place, or how update_imports and force interact in real usage. The example mitigates some gaps, but not all.

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 goes slightly beyond the schema by supplying a complete example that shows how source, symbol, target, replacement, and prepend relate in practice. This helps an agent understand typical usage patterns more concretely than property descriptions alone.

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?

The description clearly states the action: 'Extract a symbol (module, function, struct) to a separate file.' This is specific about the verb, resource, and scope. It does not explicitly differentiate itself from sibling tools like ast_move or ast_split, but the phrase 'to a separate file' narrows the intent sufficiently.

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 gives an explicit usage caution: 'do NOT issue concurrent extracts/writes against the same files; use execute_plan for multi-op atomicity.' This provides a concrete when-not-to-use and points to the correct alternative for atomic multi-op workflows. It does not compare against all sibling extraction/move tools, but the guidance is actionable.

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