Refactor planning
Skill ahtishamshahzad/agent_dev_flow/.ai/skills/refactor-planning
Use to plan a behavior-preserving structural improvement — audit the target, ensure test coverage exists, plan small reversible steps, and verify behavior is unchanged. Any intended behavior change is a feature, not a refactor.From its SKILL.md
npx -y skills add ahtishamshahzad/agent_dev_flow --skill refactor-planningAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.5 KB, 696 tokens by cl100k_base, as published. Nobody here has run it
Refactor Planning
Purpose
Plan a refactor that improves structure or quality without changing external behavior, in small reversible steps backed by tests. Produces a refactor work item in ../../work-items/refactors/.
When to Use
- Request classified as refactor, or cleanup enabling later work.
- Not when behavior should change (that's
feature-planning) or when fixing a defect (bug-investigation).
Inputs
- The target code and its current tests.
- The improvement goal (readability, decoupling, performance-neutral cleanup).
Discovery Questions
- What is the concrete improvement goal, and how is "better" judged?
- Does adequate test coverage exist to prove behavior is preserved?
- What is the blast radius; who depends on this code?
- Can it be done in small, independently verifiable steps?
Responsibilities
- Audit the target and its dependents.
- Confirm/establish test coverage before touching risky areas.
- Plan small, reversible, behavior-preserving steps.
- Define verification that behavior is unchanged at each step.
- Record the refactor work item.
Required Workflow
- Read the target + dependents + tests.
- If coverage is inadequate, plan to add characterization tests first.
- Break the refactor into small reversible steps.
- Define per-step verification (tests green, behavior identical).
- Record the work item (steps, risk, verification).
Decision Rules
- Behavior-preserving by definition — any behavior change reclassifies as a feature.
- Add tests before refactoring under-covered risky code.
- Prefer many small steps over a big-bang rewrite.
- If risk is high and value low, recommend deferring.
Rules
- Do not change observable behavior.
- Keep each step independently verifiable and revertible.
- Preserve public contracts unless the plan explicitly versions them.
Anti-Patterns
- Big-bang rewrite with no rollback path.
- Refactoring untested, risky code without adding tests first.
- Slipping behavior changes into a "refactor."
Validation Checklist
- Improvement goal explicit.
- Coverage confirmed or characterization tests planned.
- Steps small and reversible.
- Per-step verification defined.
- Behavior-preservation guaranteed by tests.
Definition of Done
A recorded refactor work item with a clear goal, sufficient test coverage (or a plan to add it), small reversible steps, and per-step verification proving behavior is unchanged.
Related Skills
existing-project-audit, testing-strategy, task-planning, code-review, performance-review (if perf-motivated), project-orchestrator.
Related Knowledge
../../knowledge/ (module contracts, invariants).
Related References
../../references/<topic>/ for patterns if needed.
Context Loading Guidance
- Requires: target code, dependents, current tests, the goal.
- Does not require: unrelated modules, the full reference tree, unrelated skills.
- May load:
testing-strategy(coverage),performance-review(if perf-driven). - Stop when: steps + verification are recorded.
Token Efficiency Guidance
Scope reading to the target and its direct dependents. Capture steps tersely; rely on tests as the verification record rather than prose.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.