Spend 90% of your time solving real problems until it becomes a drag. Then refactor for a month, rinse and repeat.
That percentage will drop every cycle, until you're spending 10% of your time solving real problems and 90% of your time doing maintenance.
Or, keep it simple and write it once and have it run 10 years. I have stuff like that.
That's the winning strategy if you can pull it off. I'm always impressed at how clojure's code base has evolved.