Skip to main content
Glama

execute_refactor_workflow

Run an end-to-end refactoring pipeline: plan context, audit dependencies, apply AST transformations, run tests, and roll back on failure.

Instructions

End-to-End Orchestrated Refactoring Engine: Executes the complete Task -> Context Plan -> Reflection Audit -> Dependency Preflight -> Deterministic AST Transformation -> Test Execution & Rollback pipeline. Changes are test-gated and rolled back on failure; correctness is only as strong as the supplied test command.

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": {
      "task": "<task>"
    },
    "name": "execute_refactor_workflow"
  }
}

Input Schema

NameRequiredDescriptionDefault
taskYesTask description (e.g. 'Decouple SleepInhibitor from cli.py into system.py')
dry_runNoIf true, simulates transformations without modifying disk
symbolsNoOptional list of exact symbol names to refactor
to_fileNoTarget file (optional; deduced from task/plan if omitted)
from_fileNoSource file (optional; deduced from task/plan if omitted)
share_stateNoIf true, automatically binds shared mutable globals and host module symbols across modules
project_rootNoPath to the repository root directory (default: '.').
test_commandNoTest command to run for verification gate (e.g. 'pytest tests/test_system.py')
token_budgetNoMax token budget for context planning (default: 3000)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A3.6/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and does disclose key traits: transformations are AST-based and deterministic, changes are test-gated, and failures trigger rollback. It leaves gaps around permissions, which files may be touched, and whether rollback is guaranteed complete, but the mutation/rollback contract is clearly stated.

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?

Two sentences, front-loaded with the pipeline overview and followed by the safety contract. The arrow-chain of stages is dense but informative; nothing is padded or repeated.

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 nine-parameter, high-impact mutation tool with no annotations and no output schema, the description covers the pipeline and rollback but says nothing about what is returned on success or failure (diffs, changed files, test output) or about scope limits. Adequate but incomplete for the tool's complexity.

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 all nine parameters are already documented, including dry_run, share_state, and token_budget. The description reinforces that test_command is the verification gate, but that is largely redundant with the schema's own wording, so it adds little beyond the structured data.

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?

Names a specific verb and resource — executing a full refactoring pipeline — and enumerates the concrete stages (context plan, reflection audit, dependency preflight, AST transformation, test gate, rollback). An agent can distinguish this from analysis-only siblings such as audit_code_quality or prefactor_decouple, though no sibling is named explicitly.

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?

Usage is implied: this is the end-to-end option that actually performs and verifies transformations. The note that 'correctness is only as strong as the supplied test command' hints at a prerequisite, but there is no explicit when-not guidance and no named alternative for agents who only want analysis or a dry plan.

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