Skip to main content
Glama

refactor_code

Refactor code based on an instruction while preserving external behavior. Provide code or file path to receive refactored output with a summary of changes.

Instructions

Refactor code according to an instruction, preserving external behavior.

Provide exactly one of code or file_path. Returns the full refactored code plus a summary of changes; this tool does not write files itself -- use batch_refactor if you want changes applied to disk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNo
thinkNo
file_pathNo
instructionYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses that the tool returns full refactored code plus a summary, does not write files, and preserves external behavior. However, it does not mention handling of invalid inputs or permissions for file_path.

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?

Two concise sentences that front-load the purpose, then provide usage rules and an alternative tool. No wasted words.

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

Completeness4/5

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

Given no annotations and output schema present, the description covers purpose, usage, behavior, and return type adequately. However, the undocumented 'think' parameter is a gap for completeness.

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 0%, so description must compensate. It explains that 'code' and 'file_path' are mutually exclusive and describes 'instruction', but does not document the 'think' parameter. Partial coverage but misses one parameter.

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

Purpose5/5

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

The description clearly states the tool refactors code based on an instruction while preserving external behavior. It distinguishes itself from sibling tools like batch_refactor by noting that it does not write files.

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

Usage Guidelines5/5

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

Explicitly states to provide exactly one of 'code' or 'file_path', and provides an alternative tool (batch_refactor) for applying changes to disk. This gives clear context on when to use this tool vs alternatives.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/darthzen/ollama-code-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server