I have similar issues. My memory is horrible at best.

I struggle to remember basic things. When I was studying electronics I would always forget if the red wire should be live or the black (that was not a good trait).

I can have a conversation in the morning with my wife and forget it by the time I get home from work. With the right triggers I can remember the entire conversation but finding those triggers is hard.

Often I bluff my way through situations until I remember. My father spoke of similar issues. I noticed that as he was struggling with terminal cancer and heavily medicated he was very good at bluffing when he had no idea what was going on.

Yet if you ask me a general knowledge question I can probably recall to the finest detail. I have a great memory for concepts and an ability to connect things that others struggle with.

I have learnt a few things about myself over the years. Maybe sharing them can help others.

Burnout is real and a memory killer. I cannot learn, I can hardly function when burnt out. It creeps up slowly and has a terrible long-lasting impact.

I can get in a state of constant rush, I feel an urgency to get everything done and frustration with the slow pace. This destroys my working memory and prevents me from learning new concepts. If I can remain calm and focused I can achieve great things. Taking it slow and methodically takes discipline but the rewards are huge.

Keeping my space and mind clean also pays off. I used to feel I didn't have the time to keep things tidy. Now I don't have the time not to. The more order I have around me the less I feel rushed and panicked.

Some of the right kinds of music with noise-cancelling headphones can help focus. I like Binaural beats for this. White noise also works well but I don't like the high pitch tones.

Lots of planning and diagrams help. I often attempt to keep too many details in my head and get overwhelmed. Writing down a design first helps. I can narrow my focus to the thing I'm working on. Resisting the need to rush here helps as well. I often want to skip the planning phase. But even if no one reads my documents the thinking that goes into them helps me organise my thoughts.

If I have burnout or depression it will take a long time to recover and working hard in non-technical / thinking roles is the best way for me.

Spelling and punctuation are not my strong points. I can't seem to remember how to spell words. Correctly spelt words often look wrong to me and look up the spelling only to find I had it correct. As a result my code sometimes suffers from inconsistent spelling of variable names. Languages like Perl are really hard for me. I can't remember how to dereference a hash or turn off buffered outputs as the commands are so small and abstract. My memory can't connect them to anything meaningful and I just can't seem to learn them. Dynamic languages I get a bit lost in. JS I can work with but in larger projects, I long for static type to help my memory. But give me a strongly typed language and automated tests and all my problems go away. I love C#, F#, Java and SQL. I can move so fast and effortlessly.

If I'm distracted and surfing Reddit too much, then I'm unhappy about something. I need to sort that out to get productive agian. I can't allow myself to soothe over the issue with distraction.