refactor
Analyzes code for refactoring opportunities including code smells, decomposition, and modernization. Guides through a structured investigation with expert validation.
Instructions
Analyzes code for refactoring opportunities with systematic investigation. Use for code smell detection, decomposition planning, modernization, and maintainability improvements. Guides through structured analysis with expert validation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| step | Yes | The refactoring plan. Step 1: State strategy. Later steps: Report findings. CRITICAL: Examine code for smells, and opportunities for decomposition, modernization, and organization. Use 'relevant_files' for code. FORBIDDEN: Large code snippets. | |
| model | Yes | Currently in auto model selection mode. CRITICAL: When the user names a model, you MUST use that exact name unless the server rejects it. If no model is provided, you may use the `listmodels` tool to review options and select an appropriate match. Top models: gemini-2.5-pro (score 100, 1.0M ctx, thinking, code-gen); gemini-3-pro-preview (score 100, 1.0M ctx, thinking, code-gen); gemini-2.5-flash (score 61, 1.0M ctx, thinking); gemini-2.0-flash (score 56, 1.0M ctx, thinking); gemini-2.0-flash-lite (score 42, 1.0M ctx). | |
| images | No | Optional list of absolute paths to architecture diagrams, UI mockups, design documents, or visual references that help with refactoring context. Only include if they materially assist understanding or assessment. | |
| findings | Yes | Summary of discoveries from this step, including code smells and opportunities for decomposition, modernization, or organization. Document both strengths and weaknesses. In later steps, confirm or update past findings. | |
| confidence | No | Your confidence in refactoring analysis: exploring (starting), incomplete (significant work remaining), partial (some opportunities found, more analysis needed), complete (comprehensive analysis finished, all major opportunities identified). WARNING: Use 'complete' ONLY when fully analyzed and can provide recommendations without expert help. 'complete' PREVENTS expert validation. Use 'partial' for large files or uncertain analysis. | incomplete |
| hypothesis | No | Current theory about issue/goal based on work | |
| focus_areas | No | Specific areas to focus on (e.g., 'performance', 'readability', 'maintainability', 'security') | |
| step_number | Yes | The index of the current step in the refactoring investigation sequence, beginning at 1. Each step should build upon or revise the previous one. | |
| temperature | No | 0 = deterministic · 1 = creative. | |
| total_steps | Yes | Your current estimate for how many steps will be needed to complete the refactoring investigation. Adjust as new opportunities emerge. | |
| issues_found | No | Refactoring opportunities as dictionaries with 'severity' (critical/high/medium/low), 'type' (codesmells/decompose/modernize/organization), and 'description'. Include all improvement opportunities found. | |
| files_checked | No | List all files examined (absolute paths). Include even ruled-out files to track exploration path. | |
| refactor_type | No | Type of refactoring analysis to perform (codesmells, decompose, modernize, organization) | codesmells |
| thinking_mode | No | Reasoning depth: minimal, low, medium, high, or max. | |
| relevant_files | No | Subset of files_checked with code requiring refactoring (absolute paths). Include files with code smells, decomposition needs, or improvement opportunities. | |
| continuation_id | No | Unique thread continuation ID for multi-turn conversations. Works across different tools. ALWAYS reuse the last continuation_id you were given—this preserves full conversation context, files, and findings so the agent can resume seamlessly. | |
| relevant_context | No | Methods/functions identified as involved in the issue | |
| next_step_required | Yes | Set to true if you plan to continue the investigation with another step. False means you believe the refactoring analysis is complete and ready for expert validation. | |
| use_assistant_model | No | Use assistant model for expert analysis after workflow steps. False skips expert analysis, relies solely on your personal investigation. Defaults to True for comprehensive validation. | |
| style_guide_examples | No | Optional existing code files to use as style/pattern reference (must be FULL absolute paths to real files / folders - DO NOT SHORTEN). These files represent the target coding style and patterns for the project. |