About 30 years ago, there was this wonderful book, called
Writing Solid Code[0]. Reading it, was a watershed, in my personal development.
It has many techniques described, that have since become Canon, and a number that have not aged so well.
One that is probably impractical, these days, is Step Through Your Code. He recommends stepping through every line of your code in a symbolic debugger, making sure that the code flow is what you expect, and the app state is appropriate.
Every now and then, I can do it. Often, when I’m already there, for something else. It really does work.
[0] https://writingsolidcode.com/