Foreshadowing means including some sort of clues as to future events, that will occur in your story.
These are details that readers may barely notice at the time, but that, in retrospect, will make subsequent events seem more logical. That sense of everything falling into place, is what we’re hoping to achieve.
Foreshadowing should be subtle.
It isn’t a case of giving away the plot. It’s more a case of making the plot believable, and is actually most important in those stories which rely upon major plot twists.
If you work with an outline, foreshadowing can, and should, be worked out in advance.
You will probably need to make ongoing adjustments, if your initial outline is prone to altering, as you write – which is certainly true, in my own case.
If you’re a “pantser” (working without an outline), you will need to add any foreshadowing during revisions – and even many plotters will probably end up doing so, to some extent.
Finally, don’t overdo it.
Not every event in your story necessarily needs to be foreshadowed. And, as I mentioned before, subtle hints are what we’re aiming for.
As with so many aspects of fiction writing, it’s a question of balance. Too little foreshadowing can make a story unrealistic, but too much will draw attention to itself.