Catalog
github/refactor-plan

github

refactor-plan

Create a concrete plan before starting a multi-file refactor. Use when the user asks to plan, sequence, scope, or safely execute a refactor across multiple files; always investigate first, output the plan, and wait for confirmation before making code changes.

global
New~561
v1.0Saved Jun 26, 2026

Refactor Plan

Create a detailed plan before making any code changes.

Instructions

  1. Do not edit files while preparing the plan.
  2. Search the codebase to understand the current state. Read enough implementation, tests, configuration, and docs to make the plan specific to the repository.
  3. Identify affected files, ownership boundaries, dependencies, and likely hidden coupling.
  4. Plan changes in a safe sequence. Prefer contracts and types first, then implementations, then callers, then tests, then cleanup.
  5. Include verification steps between phases and a final validation command.
  6. Include rollback or recovery steps for the riskiest phases.
  7. Output the complete plan using the format below.
  8. Stop after the plan and ask for confirmation before implementing. If the user already asked you to implement, still produce the plan first and wait for confirmation unless they explicitly said to continue without review after the plan.

If the request is too ambiguous to plan safely, ask concise clarifying questions instead of editing files.

Output Format

## Refactor Plan: [title]

### Current State
[Brief description of how things work now]

### Target State
[Brief description of how things will work after]

### Affected Files
| File | Change Type | Dependencies |
|------|-------------|--------------|
| path | modify/create/delete | blocks X, blocked by Y |

### Execution Plan

#### Phase 1: Types and Interfaces
- [ ] Step 1.1: [action] in `file.ts`
- [ ] Verify: [how to check it worked]

#### Phase 2: Implementation
- [ ] Step 2.1: [action] in `file.ts`
- [ ] Verify: [how to check]

#### Phase 3: Tests
- [ ] Step 3.1: Update tests in `file.test.ts`
- [ ] Verify: Run `npm test`

#### Phase 4: Cleanup
- [ ] Remove deprecated code
- [ ] Update documentation

### Rollback Plan
If something fails:
1. [Step to undo]
2. [Step to undo]

### Risks
- [Potential issue and mitigation]

After the plan, ask: "Shall I proceed with Phase 1?"

Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

88/100

Grade

A

Excellent

Safety

92

Quality

85

Clarity

89

Completeness

82

Summary

This skill guides an AI agent to create a structured, multi-phase refactoring plan before making code changes. It emphasizes investigating the codebase first, identifying dependencies and risks, sequencing changes safely (types → implementation → tests → cleanup), and waiting for user confirmation before execution. The skill prioritizes safety through explicit rollback steps and intermediate verification checkpoints.

Detected Capabilities

codebase analysisfile readingdependency mappingplan generationstructured documentation output

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

plan refactorrefactoring sequencemulti-file refactordependency mappingrefactor scope

Use Cases

  • Plan a large-scale API redesign across multiple services before implementing
  • Sequence a database schema migration with dependent client code changes
  • Refactor a shared utility library used by multiple projects with clear phase ordering
  • Move code across modules while documenting ownership boundaries and breaking changes
  • Safely extract a feature into a new package with explicit dependency mapping

Quality Notes

  • Excellent safety-first design: explicit instruction to 'stop after the plan and ask for confirmation' prevents accidental code changes
  • Well-structured output format with checklist-based phases, verification steps, and rollback procedures reduce refactoring risk
  • Clear scope boundaries: reads codebase to understand state but never modifies during planning phase
  • Prioritizes dependency analysis and sequence safety (contracts/types before implementation before callers)
  • Includes intermediate verification steps and final validation, improving quality of refactoring outcomes
  • Rollback and recovery steps explicitly documented per instruction #6, supporting safe execution
  • Minor: could benefit from guidance on detecting circular dependencies or documenting reverse dependencies, but format supports this
Model: claude-haiku-4-5-20251001Analyzed: Jun 26, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Add github/refactor-plan to your library

Command Palette

Search for a command to run...