Agent skill · software engineering · aiskillstore

refactor

Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

Why this skill is useful

Provides specific patterns and examples for refactoring code that improve maintainability and readability, which the AI may not generate on its own.

What it needs

About 10k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

Refactor Overview Improve code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch. When to Use Use this skill when: Code is hard to understand or maintain Functions/classes are too large Code smells need addressing Adding features is difficult due to code structure User asks "clean up this code", "refactor this", "improve this" --- Refactoring Principles The Golden Rules 1. Behavior is preserved - Refactoring doesn't change what the code does, only how 2. Small steps - Make tiny changes, test after each 3. Version control is your friend - Commit before and after each safe state 4. Tests are essential - Without tests, you're not refactoring, you're editing 5. One thing at a time - Don't mix refactoring with feature changes When NOT to Refactor --- Common Code Smells & Fixes 1. Long Method/Function 2. Duplicated Code 3. Large Class/Module 4. Long Parameter List 5. Feature Envy 6. Primitive Obsession 7. Magic Numbers/Strings 8. Nested Conditionals 9. Dead Code 10. Inappropriate Intimacy --- Extract Method Refactoring Before and After --- Introducing Type Safety From Untyped to Typed --- Design Patterns for Refactoring Strategy Pattern Chain of Responsibility --- Refactoring Steps Safe Refactoring Process --- Refactoring Checklist Code Quality [ ] Functions are small (< 50 lines) [ ] Functions do one thing [ ] No duplicated code [ ] Descriptive names (variables, functions, classes) [ ] No magic numbers/strings [ ] Dead code removed Structure [ ] Related code is together [ ] Clear module boundaries [ ] Dependencies flow in one direction [ ] No circular dependencies Type Safety [ ] Types defined for all public APIs [ ] No any types without justification [ ] Nullable types explicitly marked Testing [ ] Refactored code is tested [ ] Tests cover edge cases [ ] All tests pass --- Common Refactoring Operations Operation Description --------------------- …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/refactor

View the source on GitHub

Browse the @skills marketplace