Skip to content
Back to skills

Refactor

ASecurity

> Restructure code for clarity and maintainability without changing behavior.

  • 229 stars
  • 0 votes
  • 1 copy
  • 11 views
  • Added June 6, 2026
code-qualitybashrefactoring

Security analysis

A100/100

Scanned June 6, 2026

npx -y skills add Miosa-osa/canopy --skill refactor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/miosa-osa-refactor/badge)](https://www.skillsdirectory.com/skills/miosa-osa-refactor)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# /refactor

> Restructure code for clarity and maintainability without changing behavior.

## Usage
```
/refactor <target> [--strategy <strategy>] [--safe]
```

## What It Does
Analyzes the target code, identifies improvement opportunities, plans a safe refactoring sequence, executes it, and verifies no behavior changes. Runs tests before and after every transformation.

## Implementation
1. **Analyze** -- read the target code, identify code smells (long functions, deep nesting, duplication, poor naming, high coupling).
2. **Plan** -- propose refactoring strategy: extract function, rename, decompose, inline, introduce pattern.
3. **Baseline** -- run tests to establish green state. If tests fail, stop.
4. **Execute** -- apply refactorings one at a time. Run tests after each.
5. **Verify** -- confirm all tests still pass, behavior unchanged.
6. **Report** -- diff summary, complexity reduction metrics, before/after.

Strategies: `extract`, `rename`, `decompose`, `simplify`, `decouple`, `auto` (detect best).

## Examples
```bash
# Auto-detect and refactor
/refactor lib/optimal_engine/intake.ex

# Extract functions from a long module
/refactor lib/app.ex --strategy extract

# Safe mode: smaller steps, test after every change
/refactor lib/complex_module.ex --safe
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…