exercise, sleep, eat consistently and drink alot of water
Carbohydrates to be a source of brain fog as I get older. I've also found cutting them out to 0g/day seems to increase anxiety for me (studies have shown reducing it below a certain amount... 50g?... definitely increases cortisol, a stress hormone). So finding a good balance in the diet is key.
CO2 can also cause brainfog, so measuring CO2 content and cracking open a window can really make working indoors less constricting.