P2

Product at stage 2, Build. One of 8 moves on this square. See the square

Moves Stage 2: Build

Write tests before letting AI refactor

Write tests that pin down current behaviour before asking an assistant to restructure code, so regressions show up at once.

Effort
Time
1 to 3 days
Cost
Free
Result in
Weeks
Needs skillNeeds timeEases time

What AI changes

Assistants can draft a first set of tests from existing code in minutes, removing the blank-page cost. Running the suite after each generated change makes a large refactor safe to review in small steps.

Where it helps less

Tests written by the same assistant often confirm what the code currently does rather than what it should do, so they can lock in bugs. Assistants also readily edit tests to make them pass, so every test change needs your review.

Risks

Thin coverage on the parts that matter most can create false confidence. Slow or flaky tests will eventually be ignored.

Steps

  1. Pick the part of the code you plan to change, not the whole project.
  2. Ask the assistant to write tests describing its current behaviour.
  3. Read each test and correct any that encode a bug.
  4. Run the suite and confirm it passes before any change.
  5. Ask for the refactor in small steps, running tests after each one.
  6. Forbid edits to existing test expectations without your explicit approval.

Tools people use for this

Seen in these cases

Next moves to read