And this is one of the reasons writing things down has been such a useful tool, and starting with a spec is something I now do religiously after spending the first half of my life just diving in haphazardly (and often not getting very far).
Those ultra productive days are often enough to get a pretty decent spec written; something I can flesh out in far greater detail than I could with a productive coding day. Those down days are now bolstered by the thinking of a version of myself that was firing on all cylinders, and solved many of the problems I probably don’t have the brain power to tackle on the fly when I’m tired and stressed for life reasons.
I feel like I’ve squandered really good trains of thought by telling myself “I’ll remember this and write it down later”. So I always start with writing. Future me always appreciates it.