Last week I had one of those dreaming-about-writing-code sort of nights, where I half woke up and was thinking about the stuff I'd been dreaming about and couldn't go back to sleep. I tossed and turned until I grabbed my phone, opened my notes app, jotted down some of the idea, then closed it. That alone let my mind say "ok, now I won't forget it" and I was finally able to go back to sleep.
Some people go full-on Zettelkasten, which is awesome and I'm happy for them. Turns out I really don't need all the organization. I just need somewhere to offload my thoughts where I know I can find them later, and just the process of writing them down usually gets me 99% of the benefit of having such a system.