Back to Skills

refactor

verified

Refactor code with clear before/after explanation. Verifies changes with tests before completion.

View on GitHub

Marketplace

potenlab-marketplace

potenlab/marketplace-potenlab

Plugin

pl

Repository

potenlab/marketplace-potenlab

skills/refactor/SKILL.md

Last Verified

January 25, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/potenlab/marketplace-potenlab/blob/main/skills/refactor/SKILL.md -a claude-code --skill refactor

Installation paths:

Claude
.claude/skills/refactor/
Powered by add-skill CLI

Instructions

# Code Refactor

Refactor the specified code while maintaining functionality.

## Target

Refactor: $ARGUMENTS

If no target specified, ask the user which file to refactor and what improvement they want.

## Workflow

Follow these steps in order:

### Step 1: Analyze
- Read the target file(s)
- Understand current structure and functionality
- Identify the refactoring opportunity

### Step 2: Plan
Explain what you will change:
- What code will be modified
- Why this change improves the code
- Any risks or considerations

Ask for confirmation before proceeding if the changes are substantial.

### Step 3: Refactor
- Make the code changes
- Keep changes focused and minimal
- Only modify files explicitly in scope

### Step 4: Verify
Run the project's test suite:
```bash
# Try common test commands in order
npm test || yarn test || pnpm test || pytest || go test ./... || cargo test
```

**CRITICAL:** If tests fail:
1. Analyze the failure
2. Fix the issue
3. Re-run tests
4. Repeat until tests pass

Do NOT report completion until tests pass.

### Step 5: Report

Provide the refactoring summary:

## Refactoring Complete

### Changes Made

#### File: [filename]

**Before:**
```[language]
[original code - relevant section only]
```

**After:**
```[language]
[refactored code - same section]
```

**Why:** [Explanation of the improvement]

### Test Results
- Tests run: [number]
- Tests passed: [number]
- Tests failed: [number]

### Summary
[Brief description of what was improved: performance, readability, maintainability, etc.]

## Scope Rules
- Only modify files explicitly specified or directly required for the refactor
- If refactoring requires changes to other files, explain and ask for permission
- Keep changes minimal and focused on the stated goal

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
1744 chars