/refactor
Perform a systematic refactoring of the specified code area.
$ npx -y skills add rohitg00/awesome-claude-code-toolkit --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/refactor
Context preview
What this command does when you run it.
Perform a systematic refactoring of the specified code area.
Command definition
refactor.mdPerform a systematic refactoring of the specified code area.
Steps
1. Identify Code Smells
Read the target code and identify issues:
- **Long functions** (>40 lines): break into smaller functions with descriptive names.
- **Deep nesting** (>3 levels): use early returns, guard clauses, or extract functions.
- **Duplicate logic**: extract shared functions or use parameterization.
- **God objects/modules**: split into focused, single-responsibility units.
- **Primitive obsession**: introduce domain types or value objects.
- **Feature envy**: move logic to the class/module that owns the data.
- **Unclear naming**: rename variables, functions, and files to reveal intent.
2. Verify Test Coverage
- Run existing tests to establish the green baseline.
- If coverage is insufficient, write characterization tests that capture current behavior before changing anything.
- Every refactored path must have a test that would catch a regression.
3. Plan Changes
- List each refactoring step in order.
- Each step should be a single, atomic change (one rename, one extract, one move).
- Order steps to minimize risk: rename before restructure, restructure before optimize.
4. Execute
- Apply one refactoring at a time.
- Run tests after each step to confirm behavior is preserved.
- Commit after each successful step if the changes are significant.
5. Verify
- Run the full test suite.
- Check that type checking passes.
- Compare behavior before and after (same inputs produce same outputs).
Rules
- Refactoring changes structure, not behavior. If behavior changes, that is a feature or a fix.
- Never refactor and add features in the same step.
- If tests are missing, add them before refactoring, not after.
- Keep diffs reviewable: prefer multiple small commits over one massive change.
- If a refactoring reveals a bug, note it and fix it in a separate commit.
Read more
Perform a systematic refactoring of the specified code area.
Steps
1. Identify Code Smells
Read the target code and identify issues:
- **Long functions** (>40 lines): break into smaller functions with descriptive names.
- **Deep nesting** (>3 levels): use early returns, guard clauses, or extract functions.
- **Duplicate logic**: extract shared functions or use parameterization.
- **God objects/modules**: split into focused, single-responsibility units.
- **Primitive obsession**: introduce domain types or value objects.
- **Feature envy**: move logic to the class/module that owns the data.
- **Unclear naming**: rename variables, functions, and files to reveal intent.
2. Verify Test Coverage
- Run existing tests to establish the green baseline.
- If coverage is insufficient, write characterization tests that capture current behavior before changing anything.
- Every refactored path must have a test that would catch a regression.
3. Plan Changes
- List each refactoring step in order.
- Each step should be a single, atomic change (one rename, one extract, one move).
- Order steps to minimize risk: rename before restructure, restructure before optimize.
4. Execute
- Apply one refactoring at a time.
- Run tests after each step to confirm behavior is preserved.
- Commit after each successful step if the changes are significant.
5. Verify
- Run the full test suite.
- Check that type checking passes.
- Compare behavior before and after (same inputs produce same outputs).
Rules
- Refactoring changes structure, not behavior. If behavior changes, that is a feature or a fix.
- Never refactor and add features in the same step.
- If tests are missing, add them before refactoring, not after.
- Keep diffs reviewable: prefer multiple small commits over one massive change.
- If a refactoring reveals a bug, note it and fix it in a separate commit.
The most comprehensive toolkit for Claude Code -- 135 agents, 35 curated skills (+400,000 via SkillKit), 42 commands, 176+ plugins, 20 hooks, 15 rules, 7 templates, 15 MCP configs, 26 companion apps, 53 ecosystem entries, and more.
Repo: rohitg00/awesome-claude-code-toolkit
Other commands on rohitg00-claude-code-toolkit.
- /adr
Write an Architecture Decision Record documenting a significant technical decision.
Open command - /design-review
Conduct a structured design review of a module, feature, or system component.
Open command - /diagram
Generate Mermaid diagrams from codebase analysis or description.
Open command - /migrate
Plan and execute a framework or library migration incrementally.
Open command - /plan
Create a structured implementation plan for the requested feature or change.
Open command - /ci-pipeline
Generate a CI pipeline configuration for GitHub Actions.
Open command

