Buy whole bean coffee. Grind just before brewing. Preferably with a burr grinder for consistent grind.
Buy fresh locally roasted coffee. If your coffee has a “roasted on” date you can figure out freshness. If it has an expiration date, you can’t. There are no consistent standards for coffee expiration.
Take the time to taste test beans from different regions and roasters. I thought I loved oily dark roasts but after trying a lightly roasted, clover-brewed, Yirageffe from Starbucks, I sought out Ethiopian beans from roasters whose product I found in my local Whole Foods. I found that Ceremony Coffee Roasters in Annapolis Maryland will roast small batches of Ethiopian heirlooms for me after my order and ship via USPS for $5. I have found true coffee love.
Bonus tip: also test out different brew processes for yourself. I have been single cup brewing for years but manual processes such as aeropress or pour over (with some stirring) work best for the kind of rich extraction I want. I own a Breville hot water heater with selectable temperature to help make this part automatic.
Photo Credit: Allagash Brewing