Skip to main content
Glama

refactor-code

Refactor code to improve structure, readability, or performance; specify code, a refactoring goal, and language.

Instructions

Refactors code to improve its structure, readability, or performance

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": {
      "code": "<code>"
    },
    "name": "refactor-code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe code to refactor
goalNoThe goal of the refactoring (e.g., 'improve readability', 'optimize performance', 'reduce complexity')
modelNoOptional model to use (e.g., 'qwen-turbo'). If not specified, uses the default model (qwen-plus).
languageNoProgramming language of the code (e.g., 'python', 'javascript', 'java', 'cpp'). If not specified, Qwen will try to detect it.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.1

TDQS

C2.5/5.0
Behavior2/5

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

With no annotations, the description carries the full burden and mostly fails: it does not say whether the refactored code is returned as text or written to disk, whether original behavior is guaranteed to be preserved, or that a model call is involved (the model parameter implies LLM latency/cost that is never mentioned). Only the implicit notion of transformation is conveyed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is a single short sentence with no wasted words, but the brevity comes at the cost of substance rather than being efficiently front-loaded. There is no structure to speak of beyond one clause.

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

Completeness2/5

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

There is no output schema and no annotations, so the description was the only place to explain what comes back from a refactor (new code snippet? diff? applied changes?) and whether behavior is preserved. Those essentials are missing, leaving the agent unable to predict results from a 4-parameter tool.

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 each of the four parameters (code, goal, model, language) is already documented with examples in the schema. The description adds nothing beyond that, which is acceptable but not additive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a verb and resource ("Refactors code") and lists three goals, so the purpose is recognizable. However, it never distinguishes itself from nearby siblings such as review-code, explain-code, or generate-code, and the phrasing largely restates the tool name rather than specifying what the output is.

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 guidance is given on when to pick this over review-code (which presumably also looks at code quality) or explain-code. There are no exclusions, prerequisites, or stated conditions that would let an agent route correctly among these siblings.

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