Skip to main content
Glama
rodhayl
by rodhayl

refactor_helper

Provides naming suggestions and extraction hints for selected code to improve readability and maintainability.

Instructions

Naming suggestions and extraction hints for selected code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction: suggest_names (better variable/function names), extract_function (suggest function extraction)
codeYesCode snippet to process
languageNoProgramming language (optional)
styleNoFor suggest_names: naming convention (default: auto)
selectionNoFor extract_function: specific code portion to extract (optional)

Implementation Reference

  • The 'refactor_helper' tool is implemented within the 'CodeAssistanceTools' class, specifically using LLM wrappers for 'suggestNames' (lines 520-576) and 'extractFunction' (lines 582-651). Both functions call 'this.llmWrapper.callToolLlm' with the identifier 'refactor_helper'.
      /**
       * Suggest better names for code identifiers
       */
      async suggestNames(
        code: string,
        options?: {
          language?: string;
          focusIdentifiers?: string[];
          style?: 'camelCase' | 'snake_case' | 'PascalCase';
        }
      ): Promise<SuggestNamesResult> {
        const language = options?.language ?? 'code';
        const style = options?.style ?? 'camelCase';
    
        const prompt = `You are an expert at naming things in code. Analyze this ${language} code and suggest better, more descriptive names for variables, functions, and classes.
    
    Naming style: ${style}
    ${options?.focusIdentifiers ? `Focus on these identifiers: ${options.focusIdentifiers.join(', ')}` : 'Analyze all identifiers that could be improved'}
    
    Provide your response as JSON:
    {
      "suggestions": [
        {
          "original": "Current name",
          "suggested": ["Better name 1", "Better name 2"],
          "reasoning": "Why these names are better",
          "type": "variable|function|class|parameter"
        }
      ]
    }`;
    
        try {
          const responseText = await this.llmWrapper.callToolLlm(
            'refactor_helper',
            [
              { role: 'system', content: prompt },
              { role: 'user', content: `\`\`\`${language}\n${code}\n\`\`\`` },
            ],
            { type: 'suggest_names', language, style }
          );
    
          const parsed = this.parseJsonResponse(responseText, {
            suggestions: [],
          });
    
          return {
            success: true,
            suggestions: parsed.suggestions || [],
          };
        } catch (error) {
          return {
            success: false,
            suggestions: [],
            error: error instanceof Error ? error.message : 'Unknown error',
          };
        }
      }
Behavior2/5

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

No annotations provided, so description carries full burden. While 'suggestions' and 'hints' imply read-only behavior, the description does not explicitly state that this tool does not modify files, does not describe the return format (text suggestions vs structured data), or disclose performance characteristics for large code inputs.

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?

Single 7-word sentence with no repetition or tautology. Front-loaded with key verbs ('Naming suggestions', 'extraction hints'). However, brevity contributes to under-specification given the tool's dual-mode complexity.

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?

With 100% schema coverage and no output schema, the description adequately names the capabilities but insufficiently explains the relationship between action types and conditional parameters (style/selection). Lacks guidance on interpreting results or handling the optional language parameter.

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%, establishing baseline 3. Description loosely maps 'Naming suggestions' to suggest_names action and 'extraction hints' to extract_function, but adds no syntax details, parameter dependencies (e.g., style only applies to suggest_names), or formatting guidance beyond the schema.

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?

Clear verb+resource structure: provides 'naming suggestions' and 'extraction hints' for code. Specifies two distinct capabilities (suggest_names and extract_function actions). However, fails to differentiate from sibling 'suggest_refactoring' which sounds functionally similar.

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 on when to use this tool versus siblings like 'suggest_refactoring' or 'code_helper'. No explanation of when to choose suggest_names vs extract_function actions, or how the optional selection parameter relates to extraction.

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/rodhayl/mcpLocalHelper'

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