refactoring

Refactor code incrementally with one-change, test, and commit cycles.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/ArcadeAI/dexa --skill refactoring-arcadeai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/ArcadeAI/dexa/tree/main/.claude/skills/safeword-refactoring
Command: npx skills add https://github.com/ArcadeAI/dexa --skill refactoring-arcadeai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Systematic refactoring with small-step discipline. Use when the user says 'refactor', 'clean up', 'restructure', 'extract', 'rename', or mentions code smells. Enforces one change → test → commit cycle. For structural improvements, not style/formatting (use /lint). Not for adding features or fixing bugs.

Core Features & Use Cases

  • One Change at a Time: Each refactor is isolated and verified.
  • TDD with Refactor: Every change is followed by tests and a commit.
  • Identify and Address Smells: Duplicated code, long functions, deep nesting, etc.

Quick Start

Identify a smell, perform a single, small refactor, run tests, then commit. Do not batch changes.

Frequently Asked Questions about refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code without breaking functionality?

Refactoring improves code structure through small, isolated changes verified by tests after each step. Apply one change at a time, run your test suite, commit with a clear message, then move to the next change. This cycle ensures behavior stays intact while you eliminate duplication, shorten functions, reduce nesting, and remove code smells.

What's the difference between refactoring and code cleanup?

Refactoring restructures code to improve internal design without changing external behavior; it includes extracting methods, renaming variables, and reorganizing logic. Code cleanup addresses style and formatting. This Skill focuses on refactoring—structural improvements detected through code smells—not formatting or linting.

When should I refactor instead of rewriting code?

Refactor when code works but has structural issues: duplicated logic, overly long functions, excessive nesting, or unclear naming. Refactoring preserves proven behavior through mandatory tests after each change, making it safer than rewrites. Rewriting is riskier and better reserved for code too broken to test incrementally.

Can I refactor and add features at the same time?

No. Refactoring should isolate structural improvements from new functionality. Mixing them makes it harder to identify which changes caused test failures and complicates commit history. Separate feature work into its own commits, then refactor in dedicated passes using the one-change-test-commit cycle.

How do I know what code smells to look for?

Common code smells include duplicated code blocks, functions longer than one screen, deeply nested conditionals, cryptic variable names, and classes doing too much. This Skill identifies and prioritizes smells, then guides you through extracting methods, renaming, and reorganizing one piece at a time with tests confirming each step.