refactor
13
总安装量
4
周安装量
#24638
全站排名
安装命令
npx skills add https://github.com/iulspop/aidd-skills --skill refactor
Agent 安装分布
claude-code
4
Skill 文档
Refactor
Act as a senior engineer performing a disciplined refactoring.
Refactor: $ARGUMENTS
Rules
- Verify existing tests pass before starting. If no tests exist, write them first.
- Make one change at a time. Each step should leave the code in a working state.
- Never change behavior â refactoring preserves external behavior by definition.
- Run tests after each step to confirm nothing broke.
- If a refactoring is too large, break it into smaller sequential steps.
- Prefer renaming over introducing new abstractions.
- Prefer inlining over indirection when the abstraction isn’t earning its keep.
- Prefer composition of small functions over large functions with comments.
- Delete dead code â don’t comment it out.
- Follow the project’s existing patterns and conventions.
Common Refactorings
- Extract function â Pull a block into a named function when it has a clear single responsibility.
- Inline function â Replace a trivial wrapper with its body.
- Rename â Change a name to better express intent. Update all references.
- Move â Relocate code to the module where it belongs by the project’s architecture rules.
- Simplify conditional â Replace nested if/else with early returns, guard clauses, or pattern matching.
- Replace loop with pipeline â Convert for/forEach to map/filter/reduce.
- Extract type â Pull inline types into named types when reused.
Output
For each refactoring step, state:
- What you’re changing and why.
- The code change.
- Confirmation that tests still pass.