If there is a secret, this is it: the way to come up with good ideas is to come up with bad ideas because there’s really no way of knowing if an idea is good or bad until you have a chance to think about it.
When an idea sticks with you for long and persists till you put it on paper, then you know it’s a good idea. Maybe not writing everything down is a helpful process itself, because time and memory will filter out the bad ones. I remember writing my first novel and I was so overwhelmed with brainstorming that I would lay to bed and couldn’t sleep since I was bombarded with ideas all night long. I have never experienced something like that since then. And I had this great idea about my character. I didn’t write it down and then I forgot it, but when I engaged with the process of writing my character, the idea popped out of nowhere and I remembered and then I was 100% sure that idea was pure gold.