workflow-checkpoint-refactor
Multi-phase refactoring with checkpoint files that survive context limits. Use when refactoring spans 10+ files, needs phased rollout, or risks running out of context mid-session.
What this skill does
# /workflow:checkpoint-refactor
Multi-phase refactoring with persistent state that survives context limits and session boundaries.
## When to Use This Skill
| Use this skill when... | Use direct refactoring instead when... |
|------------------------|---------------------------------------|
| Refactoring spans 10+ files | Changing 1-5 files |
| Work will exceed context limits | Small, focused change |
| Need to resume across sessions | Single-session task |
| Multiple dependent phases | Independent file changes |
| Team coordination on large refactor | Solo quick fix |
## Context
- Repo root: !`git rev-parse --show-toplevel`
- Plan file exists: !`find . -maxdepth 1 -name REFACTOR_PLAN.md`
- Git status: !`git status --porcelain`
- Recent commits: !`git log --oneline --max-count=5`
## Parameters
- **`--init`**: Create a new refactoring plan interactively
- **`--continue`**: Resume from the last completed phase
- **`--status`**: Show current plan progress
- **`--phase=N`**: Execute a specific phase
## Plan File Format
The plan file (`REFACTOR_PLAN.md`) serves as persistent state:
```markdown
# Refactor Plan: {description}
Created: {date}
Last updated: {date}
Base commit: {hash}
## Overview
{What is being refactored and why}
## Phase 1: {phase name}
- **Status**: done | in-progress | pending | needs-review
- **Files**: file1.ts, file2.ts, file3.ts
- **Description**: {what this phase does}
- **Acceptance criteria**: {how to verify success}
- **Result**: {summary of changes made, filled in after completion}
## Phase 2: {phase name}
- **Status**: pending
- **Files**: file4.ts, file5.ts
- **Description**: {what this phase does}
- **Acceptance criteria**: {how to verify success}
- **Result**: {empty until completed}
...
```
## Execution
Execute this multi-phase refactoring workflow:
### Step 1: Initialize refactoring plan (--init mode)
If `--init` flag provided:
1. Analyze scope: Read files to be refactored, understand dependencies
2. Define phases where each:
- Touches 3-7 files (bounded scope)
- Has clear acceptance criteria (tests, type check)
- Can be committed independently
- Builds on previous phases
3. Write plan file: Create `REFACTOR_PLAN.md` at repo root
4. Record base commit: `git log --format='%H' -1`
**Phase ordering**: Shared utilities/types first, leaf components last, tests alongside implementation.
### Step 2: Resume existing refactor (--continue mode)
If `--continue` flag provided:
1. Read `REFACTOR_PLAN.md`
2. Find next pending phase (status `pending` or `needs-review`)
3. Verify all prior phases are `done`
4. Execute phase (go to Step 4)
### Step 3: Check progress (--status mode)
If `--status` flag provided:
1. Read `REFACTOR_PLAN.md`
2. Parse plan and display status table with phases, descriptions, statuses, file counts
3. Exit
### Step 4: Execute target phase (--phase=N or selected via Step 2)
For each phase:
1. Read context from plan file (current phase's details)
2. Read only the files listed for this phase
3. Implement changes according to phase description
4. Validate with appropriate tool (tsc, ty check, cargo check, or npm/pytest test)
5. If validation fails:
- Fix errors if straightforward
- If complex, mark phase as `needs-review` with error details
- Commit partial work with `WIP:` prefix
6. If validation passes:
- Update plan file: set status to `done`, write result summary
- Commit: `git add -u && git commit -m "refactor phase N: {description}"`
7. If more phases remain, proceed to next phase or suggest `--continue`
### Step 5: Sub-agent delegation (for large phases)
For phases with 7+ files, delegate to Task sub-agent with:
- File list to modify
- Phase description and acceptance criteria
- Instructions: run validation, update plan file, stage/commit changes
- If validation fails: mark phase as `needs-review` with error details
## Recovery Patterns
| Situation | Action |
|-----------|--------|
| Context limit hit mid-phase | Start new session, run `--continue` |
| Phase marked needs-review | Read plan for details, fix issues, run `--phase=N` |
| Tests broken after a phase | Revert phase commit, investigate, re-execute |
| Plan needs adjustment | Edit REFACTOR_PLAN.md directly, update phases |
| Base branch moved | Rebase onto new base, re-validate completed phases |
## Agentic Optimizations
| Context | Command |
|---------|---------|
| Check plan exists | `test -f REFACTOR_PLAN.md && echo "exists"` |
| Quick typecheck | `npx tsc --noEmit --pretty 2>&1 \| head -20` |
| Quick test | `npm test -- --bail=1 2>&1 \| tail -20` |
| Phase commit | `git commit -m "refactor phase N: description"` |
| Verify working state | `npx tsc --noEmit && npm test -- --bail=1` |
| Show plan phases | `grep "^## Phase" REFACTOR_PLAN.md` |
| Show phase status | `grep -A1 "^## Phase" REFACTOR_PLAN.md \| grep Status` |
## Quick Reference
| Operation | Command |
|-----------|---------|
| Init new refactor | `/workflow:checkpoint-refactor --init` |
| Check progress | `/workflow:checkpoint-refactor --status` |
| Resume work | `/workflow:checkpoint-refactor --continue` |
| Run specific phase | `/workflow:checkpoint-refactor --phase=3` |
| Manual plan edit | Edit `REFACTOR_PLAN.md` directly |
## Related Skills
- [code-review-checklist](../../../code-quality-plugin/skills/code-review-checklist/SKILL.md) - Review refactored code
- [refactoring-patterns](../../../code-quality-plugin/skills/refactoring-patterns/SKILL.md) - Refactoring techniques
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.