Also in the agile way, write your test(s) first!
Then all software is a continual cycle of
- Red - the code fails the test
- Green - the code passes the test
- Refactor - code improvements that are intention-preserving.
defects, new features, changes. It all follows the same pattern.