Skip to content
Development
Command

/refactor

Perform a systematic refactoring of the specified code area.

From plugin
rohitg00-claude-code-toolkit
2.8k199 skills138 agents199 commands
$ npx -y skills add rohitg00/awesome-claude-code-toolkit --agent claude-code

Command definition

refactor.md

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.
Read more
@rohitg00
Ships withrohitg00-claude-code-toolkit

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.

2.8k40 skills138 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
2.8k
Star history of rohitg00/awesome-claude-code-toolkit on GitHub, a chart by star-history.com

Other commands on rohitg00-claude-code-toolkit.

More commands from other plugins.

build
Auto-invoked

build

Command

Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.

@addyosmani@addyosmaniInstall Command