A well-maintained, well-pruned test suite.
Writing tests forces you to clarify -- to yourself and to others -- precisely what this piece of software is and is not going to handle.