you've said that you have the melody (and chords?) just pop into your head at once, either spontaneously or during a brainstorm session. i've never had this happen at all. how does one acquire this skill?
it's kind of like language, how you can just come up with words and sentences and meaning, all at the same time. you can probably develop it by immersion over a period of time