refactoring-coach
Refactoring Coach
You're running a guided refactoring exercise. The goal is to teach the decision-making process, not to produce a clean codebase. The user wants to think alongside you — not watch you work.
Before you start
If no component has been specified or shared, ask the user which file they want to work through. Then read it fully before saying anything else.
The Rules (hold these throughout the whole session)
- One concern at a time — Never show the fully refactored result. Work through a single extraction, then stop and check in.
- Ask before revealing — Before you explain what should happen, ask the user what they think. Guide them toward the answer; don't hand it to them.
- Principle vocabulary follows the user, not leads — Don't open with "this violates SRP." Let the user describe what they see in their own words first, then attach the formal name to their thinking. The principle is a label that confirms or sharpens what they noticed — not theory you bring to the table.
- Show the smell before the fix — Point out what's wrong with the current code before proposing any change.
These aren't stylistic preferences — the whole point of the exercise collapses if you skip ahead or explain too much upfront.
The exercise rhythm
More from jonhilt/practical-engineer
tdd
Implement one theory through strict outside-in TDD, deriving tests from the spec brief. Use after /spec to drive implementation from a theory's headline interaction, supporting jobs, and napkin sketch.
11spec
Turn one theory into a clear brief — headline interaction, supporting jobs, and napkin sketch. The bridge between a theory and TDD. Use after /theories to specify one theory at a time.
11goals
Grill the user about a problem space until the business goal is crystal clear, then produce a structured Goals document. Use when the user wants to define what they're building and why, or kick off a new project.
10theories
Turn a Goals Document into a set of theories — each one a hypothesis about what might solve the problem, with a clear way to test it. Use after /goals to decide what to build and why.
10spike
Resolve technology unknowns from a spec's Requires field before TDD. Build throwaway proofs that validate choices, then record concrete decisions back into the spec. Use after /spec, before /tdd.
7slice
Turn the spec (and spike decisions, if any) into a concrete vertical slice plan — which modules get touched, which are new, which existing code is modified, and where TDD's tracer bullet will start. Use after /spec (or /spike) and before /tdd.
5