From refactor-pilot
Use this skill whenever the user wants to generate tests before refactoring, create a test plan, add safety net tests, lock down behavior with tests, or generate test code for existing modules. Triggers include: "generate tests", "create test plan", "add tests before refactoring", "write tests for this", "I need safety net tests", "test this module", "lock down behavior", or any request to add tests in preparation for code changes. Also use when the user asks to "prepare for refactoring" and needs the testing phase. Do NOT use for running tests or verifying test results — use verify-changes for that.
How this skill is triggered — by the user, by Claude, or both
Slash command
/refactor-pilot:generate-testsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are performing Phase 2 (Prepare & Create Safety Nets) of the Refactor Pilot Framework.
You are performing Phase 2 (Prepare & Create Safety Nets) of the Refactor Pilot Framework. Your job is to generate tests that lock down current behavior and build a refactoring plan.
Does refactor-notes/ exist with Phase 1 outputs?
├── NO → Suggest running analyze-codebase first
└── YES → Continue
Does refactor-notes/00-requirements.md exist?
├── NO → Start with Step 1 (Define Requirements)
└── YES → Skip to Step 2
Does the project have existing tests?
├── YES → Run coverage analysis, focus on gaps
└── NO → Generate safety net tests for everything in scope
What testing framework does the project use?
├── Jest/Vitest → Use describe/it/expect patterns
├── pytest → Use test_ functions with assert
├── Go testing → Use Test* functions with t.Error
└── None configured → Recommend one based on stack
Phase 1 analysis should be complete. If refactor-notes/ does not exist, suggest running
the analyze-codebase skill first.
If refactor-notes/00-requirements.md doesn't exist, help the user define:
Save as refactor-notes/00-requirements.md.
For the target module or file, produce a test plan covering:
Format as a nested list with priority levels (Critical / Important / Nice to have).
Present the test plan to the user for review before generating code.
After the user approves the plan, generate test files:
Detect the testing framework from the project:
jest.config.*, vitest.config.*, pytest.ini, conftest.py, etc.package.json or pyproject.toml for test dependenciesGenerate tests that:
DO NOT:
Run the generated tests against the current (un-refactored) code. Fix any failures. Tests MUST pass before proceeding.
Based on test coverage results, refine the refactoring scope:
Update refactor-notes/00-requirements.md with refined scope.
Generate a detailed refactoring plan with:
refactor-notes/03c-pattern-opportunities.md exists,
incorporate HIGH-priority patterns into the plan; see skills/design-patterns/ for guides)Present the refactor plan to the user for approval.
Save all artifacts:
refactor-notes/00-requirements.md (if created)refactor-notes/05-test-plan.mdrefactor-notes/06-refactor-plan.mdnpx claudepluginhub guilhermevozniak/refactor-pilot-framework --plugin refactor-pilotReviews test code for conformance to the test-designing-guide and test-writing-guide, producing a refinement plan.
Safely refactors code with test coverage: writes tests first if absent, plans changes, applies small testable steps, verifies tests/lint/typecheck pass without behavior changes.
Safely refactors code test-first: verifies/writes tests, one structural change at a time, preserves behavior. Use for 'refactor this', 'clean this up', reorganization.