| name | refactor |
| description | Refactor the current codebase for simplicity, readability, and consistency while preserving all functionality. |
Description
Refactor the codebase.
Scope
- User-provided scope takes priority (e.g., specific files, modules, or components)
- If none provided: uncommitted changes
- If no uncommitted changes: whole codebase
General rules
- Ask if anything is unclear - do not guess
- All phases are mandatory - do not skip without user approval
- Track non-trivial steps with tasks
Skill-specific rules
- Never change functionality โ stop and ask if behavior would change
- Do not invent issues โ if clean, move on
Phase 1: Preparation
- Read the code: Read the target code to understand its structure, functionality, and style
- Compile: Compile the code to identify any errors or warnings
- Static analysis: Run linters to identify potential issues
Phase 2: Execution
Apply refactoring passes in order:
- Dead code: Eliminate unused functions, variables, constants, and types
- Duplicate code: Eliminate duplication; look for code-reuse opportunities
- Simplicity: Simplify complex or overly nested logic
- Consistency: Ensure consistent error handling, UI, coding style, and naming
- Modernization: Use modern language features and idioms where appropriate
- Code smells: Fix long functions, large classes, magic numbers, etc.
- Best practices: Apply relevant best practices for the language and domain
- Comments: Remove unnecessary or obvious comments
- Whitespace: Clean up unnecessary blank lines and trailing whitespace
Phase 3: Verification
- Static analysis: Run linters to ensure no new issues were introduced
- Compile: Compile the code to ensure it still builds
- Tests: Run all tests to ensure they still pass