Before you write them properly.
Take every idea you have, every detail of your story (or whatever it is you're writing), and put it on paper, even if it's only in note form. Lay everything out, link things up if you need to remind yourself how they interact. If you have to, use mind-mapping software - there are many great programmes available free online and, if you want something that isn't cloud-based and easier to personalise, there are plenty that you can buy and download.
Only start once you've got everything spread out before you. It might seem like it kills some of the magic of writing, but planning is imperative. Not knowing where your story is going is the one thing that is guaranteed to ruin your writing from the start.