Skip to main content
Glama

prefactor_decouple

Moves classes or functions between files, relocates required imports, adds backward-compatible aliases, and verifies tests.

Instructions

Deterministic Code Splitting: Surgical AST codemod that moves classes or functions from one file to another in 50ms, resolves and moves required imports, adds backward-compatibility aliases, and verifies tests.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "symbol": "<symbol>",
      "from_file": "<from_file>",
      "to_file": "<to_file>"
    },
    "name": "prefactor_decouple"
  }
}

Input Schema

NameRequiredDescriptionDefault
symbolYesSingle symbol name or list of symbol names to decouple
dry_runNoIf true, simulates the AST split and returns the diff without modifying files
to_fileYesTarget module to move symbol into (e.g. 'system.py')
from_fileYesSource file to extract symbol from (e.g. 'cli.py')
run_testsNoOptional test command to run for verification gate (e.g. 'pytest tests/test_inhibitor_and_server.py')
share_stateNoIf true, automatically binds shared mutable globals and host module symbols across modules
project_rootNoProject root directory (default: '.').

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

B3.2/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full burden. It does disclose meaningful side effects — import rewriting, backward-compatibility aliases, and a test gate — but says nothing about what happens on test failure (rollback?), whether the source file is deleted when emptied, or what the returned diff/report contains.

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?

A single dense sentence that front-loads the operation type and lists effects in execution order (move, resolve imports, add aliases, verify tests). No filler, though the dropped verb in "verifies tests" is slightly ambiguous about who runs it.

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 mutation tool with no annotations and no output schema, the description covers the main transformations but omits failure handling, reversibility, and the shape of the result. An agent can decide to call it but cannot predict what a failing test gate returns or whether edits are reverted.

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 every parameter is already documented in the schema. The description only indirectly touches run_tests ("verifies tests") and does not add meaning to dry_run or share_state beyond what the schema states, so the baseline applies.

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 and resource: an AST codemod that moves classes or functions from one file to another, plus import resolution, alias creation, and test verification. This is clearly narrower than the sibling refactoring/workflow tools, though it never explicitly contrasts itself with them.

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?

No when-to-use or when-not-to-use guidance is given, and no alternative is named despite siblings like execute_refactor_workflow that could overlap. The presence of dry_run and run_tests implies a safe-preview-then-verify workflow, but the description never states that sequence.

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