This is something that is different for everybody, it seems. Admittedly, I am a novice, and others like
@WelperHelper99 will be able to give much better advice.
But what works well for me is having a beginning, an end, motivations for the main characters (wants/needs), and then breaking it into four quarters, i.e. W happens in the first quarter, then X happens in the second leading to the mid point, Y leads up to the climax, where Z happens. It's fractal in nature, so if I am uncertain about something, I can just break one of those quarters down into four quarters to flesh it out.
My brain doesn't like detailed outlines, but some people will write every scene they have planned on an index card. Others will write out a list of key moments, like frames on a story board. I think the bare minimum is knowing your beginning, middle, and end. You can often tell when a writer has shit out a first draft without knowing their ending at the start.
For a mystery novel specifically, I've seen advice to map it out. Create tables and timelines that state where characters are at what exact times, because consistency is important. I've never sat down to try and write one, though.
late edit: there isn't anything inherently wrong with discovery writing the way patrick does, just don't consider your first draft a finished product that only needs minor tweaks. Plotting and outlining are just tools to get unstuck and tell better stories.