skills sourced live from GitHub · all skills listed are free · each skill is provided under its author's license.
home / Coding / Refactor Skill by @github
The skill is the skills/refactor folder inside that repository. Copy it into the folder your agent loads skills from; check your agent's documentation for where that is.
Guidance on behaviour-preserving cleanup: extracting functions, renaming, breaking up large functions and removing code smells.
States the golden rules, when not to refactor and walks through common smells with before-and-after examples. Frames refactoring as gradual change guarded by tests, not rewrites.
The original SKILL.md is organised into these sections:
Written and maintained by @github. It is published under the MIT license, which allows reuse with attribution. See the author profile. SkillDirectory does not claim authorship: this page adds our own review and links back to the original, and the skill's text belongs to its author.
# 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 ``` …
Excerpt only, quoted from the author's repository. Open the repository for the complete file.