Have you ever thought of finding a Health Coach? They typically work on problems just like this (removing caffeine from diet and how to compensate on the job). I had a hard time quitting caffeine / coffee a few years ago, but I am in my 30s and I typically have more energy and focus than I did drinking coffee everyday in my 20s.
Regularity is key, and balance is key. Always prioritize rest and sleep, and dont sacrifice on your sleep ever. Diet also plays a huge role, eating a diet packed with fresh organic vegetables, and a balance of macro-nutrients relative to your lifestyle is going to affect your energy levels and ability to focus greatly. We programmers tend to need more carbohydrates for brain fuel than lets say, professional power lifters, though it should not come in the form of junk food or refined wheat/flour, but in the form of whole grains like sorghum, barley, buckwheat, unrefined rice, millet, and quinoa. Then you need ample exercise, something that gets blood flowing throughout your body for a minimum of 20 minutes a day (for most of the days of the week). Running makes ticking this requirement off easy, but also some mixup of bodyweight exercises, or some internal arts like yoga, kung fu, or tai chi. The important thing is to use your body well, and dont confine it to long sessions in a chair. I find that jogging regularly really helps me think clear and focused.
Lately I have fallen in love with the Pomodoro technique (wikipedia.org/wiki/Pomodoro_Technique). The short version is you work in 25 minute blocks, then get up and move around for 3-5 minutes in between. As a software dev, this drove me nuts at first, as I wanted large uninterrupted blocks of sitting to get more code out. After I disciplined myself and followed this technique, I found that my focus sustained far longer, and I actually enjoyed working longer hours, and all around felt more clear and mentally focused in other areas of life. Plus it allowed me more mental focus for non work things, like relationships, chores, or other life-maintenance tasks. I use a service called Kanban Flow (free), but there are a lot of project/time management services which have Pomodoro techniques built in.
Again, I seriously recommend finding a Health Coach that works via remote / internet to help with caffeine addiction. Coffee is a powerfully addictive substance and leads to a condition known as adrenal fatigue, and if you are not knowledgeable of adrenal fatigue, you can suffer from it chronically without knowing it (most of the developed world does). It ages a person quickly, and leads to chronic lack of focus, will, and energy, and gets worse with age, and the symptoms are only temporarily alleviated with more caffeine. Having a trained professional assist with diet and lifestyle changes can only help. I have worked with remote health coaches out of New Zealand and America, and could recommend some I like to you.
All in all, just find balance between rest, diet, and exercise, and know that caffeineโs effects are subtle, insidious, and strong, and that it will take weeks, perhaps a month, before natural focus and will flow (if you are recovering from a daily caffeine habit). The first week is the worst! It does get better over time. Good luck!