refactor
Original:🇺🇸 English
Translated
This skill should be used when the user asks to refactor specific files or directories, simplify recently changed code, clean up dead code in a limited scope, or invokes `/refactor` with paths or semantic queries.
1installs
Sourcefradser/dotclaude
Added on
NPX Install
npx skill4agent add fradser/dotclaude refactorTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Refactor Command
Execute automated refactoring for $ARGUMENTS using agent.
refactor:code-simplifierPre-operation Checks
Goal: Ensure scope resolution is deterministic before launching the agent.
Actions:
- Run and continue even if false when explicit paths are provided
git rev-parse --is-inside-work-tree - Normalize arguments by trimming whitespace and preserving quoted path segments
- Treat an empty argument list as "recent changes" mode
Phase 1: Determine Target Scope
Goal: Identify files to refactor based on arguments or session context.
Actions:
- If arguments provided: verify as file/directory paths using Glob
- If paths exist: use them directly as refactoring scope
- If paths don't exist: treat arguments as semantic query, search codebase with Grep
- If no arguments: run to find recently modified code files
git diff --name-only - If no recent changes found: inform user and exit without refactoring
See for search strategies and edge cases.
references/scope-determination.mdPhase 2: Launch Refactoring Agent
Goal: Execute agent with aggressive mode enabled.
refactor:code-simplifierActions:
- Launch agent with target scope and aggressive mode flag
refactor:code-simplifier - Pass scope determination method (paths, semantic query, or session context)
- Agent auto-loads skill and applies language-specific patterns
refactor:best-practices
See for detailed Task parameters.
references/agent-configuration.mdPhase 3: Summary
Goal: Report comprehensive summary of changes.
Actions:
- Report total files refactored and changes categorized by improvement type
- List best practices applied and legacy code removed
- Suggest tests to run and provide rollback command tailored to actual scope (for example: )
git restore --worktree --staged <files>
See for detailed summary format.
references/output-requirements.mdRequirements
- Execute immediately without user confirmation
- Refactor ALL matching files when semantic search returns multiple results
- Direct users to for project-wide scope
/refactor-project - Preserve behavior and public interfaces unless user explicitly requests a behavior change