Refactoring
Use when restructuring code without changing behavior -- extracting functions, renaming, moving files, reducing duplication, migrating between patterns (JS to TS, CJS to ESM), or addressing code smells. Covers safe refactoring workflows for any language.
Install
/plugin marketplace add Sagargupta16/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add Sagargupta16/claude-skills --skill refactoringgit clone --depth 1 https://github.com/Sagargupta16/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/plugins/refactoring/skills/refactoring ~/.claude/skills/refactoringPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Refactoring Patterns ## Quick Reference | Task | Approach | |------|----------| | Extract function/method | Identify repeated or complex block, extract with clear name | | Rename safely | Find all references first, rename, run tests | | Move file/module | Update all imports, check for re-exports, run tests | | Reduce duplication | Extract shared logic only when used 3+ times | | Migrate JS -> TS | File by file, start with strictest config, add types gradually | | Migrate CJS -> ESM | Update require/module.exports to import/export, fix package.json | | Simplify conditionals | Replace nested if/else with early returns or guard clauses | ## Safe Refactoring Workflow 1. **Verify tests pass** before touching anything 2. **Make one change at a time** -- don't combine refactors 3. **Run tests after each change** to catch regressions immediately 4. **Commit frequently** -- each refactor step gets its own commit 5. **Never mix refactoring with behavior changes** in the same commit ## Code Smell Detection | Smell | Symptom | Refactoring | |-------|---------|-------------| | Long function | > 30 lines or does multiple things | Extract method | | Duplicate code | Same logic in 3+ places | Extract shared function | | Deep nesting | > 3 levels of if/for/try | Early returns, extract helper | | Long parameter list | > 4 parameters | Introduce parameter object | | Feature envy | Method uses another class's data more than its own | Move method |
Details
- Skill name
refactoring- Repository
- Sagargupta16/claude-skills
- Path
plugins/refactoring/skills/refactoring/SKILL.md- License
- MIT
- Repo updated
- 13 November 2026
FAQ
What does the Refactoring skill do?
Use when restructuring code without changing behavior -- extracting functions, renaming, moving files, reducing duplication, migrating between patterns (JS to TS, CJS to ESM), or addressing code smells. Covers safe refactoring workflows for any language.
How do I install the Refactoring skill?
Claude Code plugin: /plugin marketplace add Sagargupta16/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Refactoring popular?
It lives in Sagargupta16/claude-skills, which has 5 GitHub stars and 0 forks.
Related skills
Clean Code
5Sagargupta16/claude-skills
Use when the user writes new Python, or asks for review, refactor, or cleanup of Python code, names, comments/docstrings, functions, or tests. Applies Robert Martin's complete Clean Code catalog -- naming, functions, comments, DRY, boundary conditions, and tests -- to the code being changed.
Context Management
5Sagargupta16/claude-skills
Use when managing Claude Code context window during long sessions, when context feels degraded, or when deciding between /compact, /clear, /rewind, and sub-agents. Covers context rot detection, compaction timing, branching strategy, and sub-agent isolation patterns.
Debug Triage
5Sagargupta16/claude-skills
Use when triaging a pasted error, stack trace, or terminal transcript. Activates on "debug this", "fix this", "why is this broken", or when a user pastes red terminal output. Produces a tight cause-fix-test report, not a lecture.
Release Planner
9sandbaseai/workbuddy-skill
Use when planning a production release, phased rollout, migration sequence, canary, rollback, or measurable go/no-go decision.
Python Resilience
9sandbaseai/workbuddy-skill
Use when adding Python retry logic, timeouts, backoff, circuit breakers, rate limits, fallbacks, or fault-tolerant service calls.
Release Software
9sandbaseai/workbuddy-skill
Prepare, verify, publish, and monitor a release with artifacts, migrations, rollout, and rollback.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.