I solved this problem by going to a psychiatrist, getting diagnosed with ADHD (at age 35), and starting medication.
Not an exaggeration—I struggled with compulsive video gaming for almost my entire life; now on medication that issue has just completely vanished.
I was fearing/expecting someone to mention ADHD. I have never been formally diagnosed but everything I read about it feels suspiciously similar to the way my brain is wired. I might have to look into it more seriously. I’m currently 33.
This has a profound effect on things not related to focus like background anxiety, mild depression, impulsivity, managing relationships etc.
If you seek evaluation, seek it from someone with a lot of experience with Adult ADHD. If you get a diagnosis, make sure you work with a doctor who starts you at the lowest dose and slowly ups it as needed.
How to ADHD is a great YouTube channel, if you are curious.
My yearly work output is OKish but my daily or weekly productivity has very high variance, which has caused me some trouble in the past (especially in agile shops where constant productivity is expected).
Personally I haven’t found any magical way to meaningfully improve my average productivity. Every time I think I just found a magic bullet, it usually boils down to working closer to my peak productivity for some time (sometimes without noticing it myself) then realizing I can not sustain that on a full year / full decade / full career.
Before thinking of improving specific skills, just being able to be focused and working without distraction all day every day would be an order-of-magnitude improvement for me.