Skip to main content
skill CX Codex

refactor · vstorm-co — Claude Code skill: what it does, how to install

The refactor skill guides code changes that improve structure while preserving external behavior. Use it to break up long functions, remove duplication, or make naming consistent.

MIT ★ 1,125 updated 2026-10-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add vstorm-co/pydantic-deepagents --skill refactor -a claude-code
Open on GitHub

What refactor does

The skill starts by examining related code and running the tests already in the project. It then lays out a plan and makes changes in small steps, checking tests along the way. That keeps each refactoring tied to a verification step.

Typical changes include splitting long functions, moving repeated code into a helper, replacing magic numbers with named constants, and simplifying nested conditions. It also covers grouping related functions into modules and addressing circular dependencies through dependency inversion.

External behavior must stay the same, with tests passing before and after the changes. When tests are missing, write them first. Keep feature work separate from refactoring, and limit each commit to one refactoring type.

What it helps with

  • split a long function into focused pieces
  • move repeated code into a shared helper
  • replace magic numbers with named constants
  • simplify nested conditionals
  • group related functions into modules

Example prompts for the agent

  • Refactor this long function into smaller parts while keeping its behavior unchanged and checking the tests.
  • Find repeated code in the related files and move it into a shared helper.
  • Make the function names consistent without adding features or changing behavior.

How to install refactor

1Skills CLI (Vercel)

npx skills add vstorm-co/pydantic-deepagents --skill refactor -a claude-code

2Manually: put the files in place

~/.claude/skills/refactor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/refactor/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about refactor

How do I install refactor in Claude Code?

Run npx skills add vstorm-co/pydantic-deepagents --skill refactor -a claude-code. The skill file is located at ~/.claude/skills/refactor/SKILL.md.

What does the refactor skill do?

It guides structural code changes while preserving external behavior, with a plan and test checks as changes are made.

What if the project has no tests yet?

Write tests before refactoring. Keep feature changes out of the same change.

Source text

SKILL.md · MIT
---
name: refactor
description: "Refactor code to improve structure and maintainability"
tags: [code-quality, refactoring]
version: "1.0.0"
---

# Refactor

Improve code structure without changing external behavior.

## Process

1. **Understand** — Read all related code, run existing tests
2. **Plan** — Identify what to change and why
3. **Execute** — Make changes incrementally
4. **Verify** — Run tests after each change

## Common Refactoring Patterns

### Extract
- Long function → smaller focused functions
- Repeated code → shared helper
- Magic numbers → named constants

### Simplify
- Deep nesting → early returns / guard clauses
- Complex conditionals → descriptive functions
- Large classes → smaller focused classes

### Rename
- Unclear names → descriptive names
- Inconsistent naming → consistent conventions

### Reorganize
- Related functions scattered → grouped in modules
- Circular dependencies → dependency inversion

## Rules

- Never change behavior — tests must pass before and after
- One refactoring type per commit
- If tests don't exist, write them first
- Don't refactor and add features in the same change

© vstorm-co · MIT · vstorm-co/pydantic-deepagents

Similar skills

All skills for Code review and refactoring →

refactor by other authors comes first.

refactor official github The refactor skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. CX Codex +1 22,321installs refactor parcadei refactor is a Claude Code skill that guides code changes through analysis, planning, implementation, review, and test validation. It activates for refactoring requests that should preserve existing behavior. CX Codex +1 625installs refactor smallnest refactor restructures code safely based on Martin Fowler's catalog without altering external behavior. Fixes code smells through small, verifiable steps. CX Codex +1 538installs refactor boshu2 refactor — a Claude Code skill for restructuring code without changing observable behavior. Runs on requests to clean up, extract functions, remove dead code, or simplify logic. CX Codex +1 123installs refactor pproenca A skill with 43 refactoring rules drawn from Martin Fowler's catalog and Clean Code. Useful when you want the agent to restructure code by a fixed set of rules instead of guessing. CX Codex +1 661installs oma-refactor First Fluke oma-refactor — a skill for Claude Code and Codex restructures existing code while preserving observable behavior. Executes targeted technical debt cleanup through small test-gated transformations. CX Codex +1 ★ 1,472repo stars refactor-expert alirezarezvani The refactor-expert subagent reviews code structure and plans incremental refactoring. Use it to find duplication, architectural issues, and gaps in test coverage. CX Codex ★ 788repo stars safe-refactor JuliusBrussee safe-refactor restructures code while preserving existing behavior, enforcing verification boundaries before structural edits. CX Codex +1 130,700installs refactor-code davila7 refactor-code — a slash command that walks Claude through 17 refactoring steps, from analysis and tests to performance checks and review prep. CX Codex +1 4,890installs refactor-project FradSer refactor-project — a skill for Claude Code, Codex, Cursor and other agents that runs automated refactoring across every file in the project at once. Cuts duplication, normalises patterns, and strips legacy code in a single pass. CX Codex +1 122installs 07-refactor AI-Driven Dev 07-refactor rewrites code along one of four axes: performance, security, cleanup, architecture. It scans on its own or takes a finished audit report as the to-do list. CX Codex +1 ★ 571repo stars

From the same set14

The whole set →
git-workflow git-workflow standardizes Git operations for Claude Code, covering commit messages, feature branches, PRs, and rebase conflict handling. CX Codex +1 ★ 1,125repo stars code-review code-review is a Claude Code skill that checks code for bugs, security issues, style, and performance problems. Ask for a review to run it. CX Codex +1 ★ 1,125repo stars test-writer test-writer generates structured test suites for existing code matching your active testing framework. CX Codex +1 ★ 1,125repo stars skill-creator skill-creator is a Claude Code skill that turns a recurring task from a conversation into reusable instructions for an AI agent. It captures workflows for future sessions. CX Codex +1 ★ 1,125repo stars environment-discovery The environment-discovery skill trains Claude Code to systematically explore unfamiliar environments before making changes. It checks file structure, data formats, available tools, and existing code—saving debugging time. CX Codex +1 ★ 1,125repo stars report-writing report-writing provides guidelines for structuring analytical reports, drafting stand-alone executive summaries, and citing sources. CX Codex +1 ★ 1,125repo stars build-and-compile The build-and-compile skill helps Claude Code choose build commands from a project's files and troubleshoot compiler or dependency errors. Use it when a build fails or the project setup is unclear. CX Codex +1 ★ 1,125repo stars research-methodology research-methodology — a skill with methodology for structured research: three-phase search, source reliability ranking, and note-taking with confidence levels for each finding. CX Codex +1 ★ 1,125repo stars

Project sponsors

Companies that keep this analytics open