Have the first scene(s) in your head and the last one(s)
Weather you write a script or not is a personal preference, I don't. If you do don't write it all out like some screenplay.
No matter what happens, however meticulously you plan things, no matter how much of a determination to stick to a plan/script, it will change as soon as you start seeing images. Remember you are making a visual novel, not a novel with pictures.
Personally, I have a story in my head i want to tell, I know how it starts, I know how it ends, how I get there I leave up to the whatever gods you want. Chapter by chapter, I know how it is going pan out of course, I just don't script it per say except for notes, and then forget to look at the notes.
Generally though -
Images first, say 10, to match what you want to tell, a visual novel is worthless without them.
Write the story to match the images (either from your script or on the fly), make more images as you go, changed the storyline (not the story) when an image dictates, and it will.
Coding comes last, there are always more dialog and images than code, and code needs one or both of them to be of any use anyway.