J K Rowling has said that the idea (for Harry Potter) “came fully formed” into her mind when she was on a four-hour delayed train trip from Manchester to London.
She was clear about what she wanted to write before she started writing it.
It is a dream for a writer to have this level of clarity before you start writing.
Here is what you can do to be clear about what you write before you start writing.
Decide on what you want to write and take long walks to let the idea develop in your mind. If the idea is something you need to research, do that before taking a walk.
Keep separate writing prep time. Make outlines during the prep time, so that you are ready to write as per a predetermined flow.
Just take a walk or work out without thinking about what you want to write. This is an excellent way to get rid of clutter from your mind, which often comes in the way of clear thinking.