If you're diagnosing a problem in yourself, it's better to take a step back and consider your behaviour from a distant point of view.
Imagine you have a problem with leaving behind dishes after you eat. Every time you see those dishes, you make a mental note that you'll have to clean them soon. You beat yourself up for it slightly, and hope that this helps you change.
It doesn't, because you're not improving the routine. Your time would be better spent in this scenario if you were to think of ways to make cleaning happen automatically as you go throughout your day: make cleaning dishes your hobby, habitually do it after eating, or always clean something whenever you pass by. This would instead ensure you spend your effort and willpower once, and then your dishes will clean themselves almost automatically for the rest of your life.
Almost everything in your life is a result of a routine. Any changes you make to your routines can have the potential to yield benefits for the rest of your life.
Coding is also a routine. Instead of making a note that you should refactor or write cleaner code, you should make it a regular part of the process to fix things you find. That means that almost automatically, your projects will have cleaner code.