# Refactor

> Refactor is an open-source agent skill for developer tools. Plans complexity-driven refactors that keep existing tests green. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/zerotechdebt/ffflow/tree/main/plugin/skills/refactor
- **Repository:** https://github.com/zerotechdebt/ffflow
- **GitHub stars:** 6
- **License:** Apache-2.0
- **Skill name:** refactor
- **Collection:** https://github.com/zerotechdebt/ffflow
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill guides an agent through refactoring code that is hard to maintain. Instead of editing ad hoc, it relies on the project's coverage, complexity and duplication tooling to choose targets, then checks that the test suite passes before any change is made.

The workflow turns each chosen target into a planning task scoped to one file or module, with an explicit note that behavior stays the same and existing tests must pass unmodified. Tasks are meant to feed a larger plan pipeline, and the skill lists common patterns such as extracting functions, using guard clauses, extracting constants and separating I/O from domain logic.

It expects a project that uses the ffflow tooling, including a just check-all recipe and an optional .ffflow/config.yaml for stack and thresholds. An optional directory argument narrows the scan; otherwise the whole project is considered.

## When your agent uses it

> Coverage/complexity-driven refactoring. Identify targets, refactor under green tests. Generates plan tasks rather than ad-hoc edits.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/zerotechdebt/ffflow/tree/HEAD/plugin/skills/refactor)
- [License: Apache-2.0](https://github.com/zerotechdebt/ffflow/tree/HEAD/plugin/skills/refactor)

## Features

- **Target selection from metrics:** Uses complexity, coverage and duplication findings to decide which code is worth refactoring.
- **Green-test gate:** Requires the test suite to pass before refactoring starts and between steps.
- **Refactor plan tasks:** Drafts one task per target with behavioral scope, implementation scope, out-of-scope items and acceptance criteria.
- **Common refactor patterns:** Lists techniques such as extract function, guard clauses, extract constants and extract fixture.
- **Inline or planned mode:** Covers small in-PR cleanups during other work as well as standalone refactor plans.

## Good for

- Find the most complex functions in a module and plan how to split them
- Clean up a file without changing its behavior, keeping existing tests unchanged
- Turn refactor findings from an audit into tasks ready for a pull request
- Extract I/O from domain logic in a service layer
- Collapse repeated test cases into parameterized tests

## Install

### Claude Code

This skill ships in the `fff` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add zerotechdebt/ffflow
/plugin install fff@ffflow
```

Or copy only this skill to `~/.claude/skills/refactor`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/refactor &&
cp -R "$tmp/plugin/skills/refactor" ~/.claude/skills/refactor &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/refactor` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/refactor` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/refactor &&
cp -R "$tmp/plugin/skills/refactor" ~/.agents/skills/refactor &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/refactor` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/refactor` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/refactor &&
cp -R "$tmp/plugin/skills/refactor" ~/.cursor/skills/refactor &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/refactor` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/zerotechdebt/ffflow.git --path plugin/skills/refactor
```

Or copy the folder to `~/.gemini/skills/refactor` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/refactor`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/refactor &&
cp -R "$tmp/plugin/skills/refactor" ~/.copilot/skills/refactor &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/refactor` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/zerotechdebt/ffflow.git
```

Then copy `ffflow/plugin/skills/refactor` into your agent's skills folder as `refactor`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Refactor change code on its own?

It generates refactor plan tasks and describes the steps to take. Changes are made through the wider ffflow workflow, with tests required to stay green.

### What must be in place before using Refactor?

The skill expects a working test suite, reachable through the just check-all command, and it advises writing tests first for code that has no coverage.

### Can Refactor change behavior?

No. The skill states that changes to observable behavior are features and should go through a separate planning step.

### Which AI clients does Refactor support?

It is published as a Claude Code plugin skill in the ffflow marketplace.

### How do I install Refactor in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/refactor to use it in all your projects, or to .claude/skills/refactor in one project. Or install the fff plugin, which includes it: /plugin marketplace add zerotechdebt/ffflow, then /plugin install fff@ffflow.

### Does Refactor run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Refactor?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Refactor?

The closest alternatives to Refactor are Refactoring guide, Refactor plan, Refactor, Refactor and TDD loop.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Refactoring guide](https://ai-powered.com/skills/refactoring-guide): Refactoring guide is an open-source agent skill for developer tools.
- [Refactor plan](https://ai-powered.com/skills/refactor-plan): Refactor plan is an open-source agent skill for developer tools.
- [Refactor](https://ai-powered.com/skills/refactor-duthaho): Refactor is an open-source agent skill for developer tools.
- [Refactor](https://ai-powered.com/skills/refactor): Refactor is an open-source agent skill for developer tools.
- [TDD loop](https://ai-powered.com/skills/tdd-loop-zerotechdebt): TDD loop is an open-source agent skill for developer tools.
- [Refactor](https://ai-powered.com/skills/refactor-kzytateishi): Refactor is an open-source agent skill for developer tools.
- [Refactor seams](https://ai-powered.com/skills/refactor-seams): Refactor seams is an open-source agent skill for developer tools.
- [Mt build](https://ai-powered.com/skills/mt-build): Mt build is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/refactor-zerotechdebt
