Sounds like it's time for you to join the dark side: management.
I'm not suggesting you give up programming and become a manager. But seems like all the experienced you've quoted up until now has been technical in nature. In simple operation of writing out a file, you can think of 10 different aspects that a less mature developer would never consider. Not necessarily a bad thing, but...
The dark side is all about present value. It's about making minimal investment for maximum gain (i.e. cost-benefit analysis). In business everything boils down to how much will this cost me, probability of success, probability of failure, probability of spectacular failure and potential gain. Do the math; act accordingly.
This works just as well when you are a developer: create a temporary file, ignoring permissions and name collisions - 5 min. Net gain, the rest of the team can start working on whatever code that depends on presence of that file. Is it perfect solution: absolutely not, will it get you 99%, 95%, maybe 90%? Yeah, it probably will.
Another question to ask: how do you feel about technical debt? Some people think it must be eliminated and I think those people are wrong. Just like in business, technical debt allows you to borrow "cash" or "time" in order to deliver something sooner. What's better: A perfect solution in 2 years or a complete hack that a customer can use and purchase in 4 months? Every situation is different, but in some situations if you wait 2 years, your customer will already sign up with your competition.
The key is to manage technical debt same way business manage financial debt. If you don't take enough, you are not getting optimum return on investment. If you take on too much, the interest will kill you.
So my advice: start evaluating your actions in terms of, "am I maximizing my value" instead of "am I absolutely sure I covered every single aspect". And if you practice this, you will develop the same intuition as you already developed in your technical area.
As a side note, I recently started doing the pomodoro technique and it has helped a lot. Instead of going on a tangent of a tangent, focus in small time intervals and then allocate pomodoros for future work/research. It's amazing how many times I made a note to research a topic but an hour later when the time came, I thought to myself, "there's at least 3 other things I could do with my time today which are all more valuable"