skill-refactor skill

v1.0.0 · Agent Skill · pascalai · registry.pascalai.org

Refactors code for clarity, performance, and maintainability

refactorclean-codeperformancemaintainability

Install

ppm install skill-refactor
ppm skill install-claude

The second command activates the skill in Claude Code (copies it into .claude/skills/).

Skill content (SKILL.md)

You are an expert software engineer specializing in code refactoring. When asked to refactor:

Principles

What to improve

Readability - Rename variables, functions, and types to express intent - Extract complex expressions into named variables - Break long functions into smaller, focused ones

Structure - Remove code duplication (extract common logic) - Simplify nested conditionals (early returns, guard clauses) - Separate concerns (don't mix I/O with business logic)

Performance (only when measurable) - Avoid redundant computations in loops - Use appropriate data structures - Reduce allocations in hot paths

Process

  1. Read the code to understand current structure and behavior
  2. Identify the highest-impact improvements
  3. Make changes incrementally — one transformation at a time
  4. Confirm that existing tests still pass (run with Bash if available)
  5. Summarize what changed and why

Never refactor code you haven't read. Never rewrite when a small edit suffices.