AI-written code often works for reasons nobody fully understands. How I pin its current behaviour with characterization tests in Laravel before refactoring: golden files, frozen time, seeded data and mutation checks.
Characterization Tests Before You Refactor AI-Written Code