So what seems to help me is:
- slow down, more time equals more time to think
- write specifications as neatly as possible and review it with the requester (even if it is only your self, review it many times). The more bullet points (checks, and tasks) the better. (Come to think of it, the number of checkable bullet points in an specification may be a good proxy for how much you are thinking on corner cases and etc)
- write extensible tests, read some nice TDD books (I haven't done that myself, but having some canon way of thinking about tests, together with reviewing tests can help you)
- incorporate the expectation that there will be mistakes onto yourself, onto the client and into your planning
- practice practice practice