# code-refactoring

This skill turns a refactoring request into a behavior-aware plan with clear guardrails, reviewable slices, and a defined next step.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 546 installs · ★ 51
- Author: akillness
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/akillness/jeo-skills/tree/HEAD/.agent-skills/code-refactoring/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/code-refactoring

## What it does

code-refactoring helps turn a cleanup request into a focused refactoring brief. It covers a narrow local change, a fragile legacy area, a repeated migration or codemod, and a risky diff that needs to be reshaped before review.

The skill asks the agent to choose one mode, state the behavior that must remain intact, and select a verification path. That path can use tests, type checks, linting, snapshots, captured examples, or a manual smoke check. Work is then split into small slices such as renames, extraction, duplicate removal, mechanical migration, and follow-up verification. Its available tools are `Read`, `Grep`, `Glob`, `Bash`, and `Write`.

A symbol inventory belongs with `codebase-search`; this skill routes that request away instead of forcing a refactoring plan.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add akillness/jeo-skills --skill code-refactoring -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/code-refactoring/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/code-refactoring/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add akillness/jeo-skills --skill code-refactoring -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/code-refactoring/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add akillness/jeo-skills --skill code-refactoring -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/code-refactoring/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install akillness/jeo-skills code-refactoring
```

2. **Manually: put the files in place**
- File: `.github/skills/code-refactoring/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add akillness/jeo-skills --skill code-refactoring -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/akillness/jeo-skills --path .agent-skills/code-refactoring
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/code-refactoring/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add akillness/jeo-skills --skill code-refactoring -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/akillness/jeo-skills/tree/HEAD/.agent-skills/code-refactoring/SKILL.md

## When to use it
- untangle a crowded function, component, service, or module
- capture legacy behavior before changing its structure
- plan a repeated API or naming migration
- reshape a mixed cleanup and semantic-change diff
- define checks for a behavior-preserving refactor

## Example prompts
- Create a refactoring brief for this tangled function and state which behavior must stay unchanged.
- Plan a freeze-first cleanup for this legacy module, including a guardrail and small reviewable slices.
- Design a migration brief for this repeated API change with source and target patterns, exceptions, and rollback.

## Similar
- [improve-codebase-architecture](https://affpapa.org/en/nevibecode/skills/improve-codebase-architecture.md) — skill · 1163035 installs
- [tdd](https://affpapa.org/en/nevibecode/skills/tdd.md) — skill · 1141062 installs
- [triage](https://affpapa.org/en/nevibecode/skills/triage.md) — skill · 990453 installs
- [codebase-design](https://affpapa.org/en/nevibecode/skills/codebase-design.md) — skill · 850344 installs
- [code-review](https://affpapa.org/en/nevibecode/skills/code-review.md) — skill · 789521 installs
- [implement](https://affpapa.org/en/nevibecode/skills/implement.md) — skill · 774700 installs

From the same set: [akillness/jeo-skills](https://affpapa.org/en/nevibecode/by/akillness/jeo-skills.md) — 46 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
