The first version can become the specification
For some projects, the first version of the software is a way to discover the requirements. Build it quickly, try multiple approaches, and see whether it creates value. At that stage, the lessons matter more than the shape of the code.
When the idea is ready to ship, distill what you built and what you learned into a specification another agent can use. Rebuilding from that clearer specification can be better than preserving and gradually refactoring the exploratory version.