Knowing your gauge with a swatch should get close, but other than trial and error I don't know of a reliable way to get it right all the time.
I do no pattern sweaters, socks and hats. Now that I have a collection of errors I can count off those and adjust for differences. But it's usually knit a little, try it on and rip it out and restart.
If you knit a little and try it, check your gauge before ripping, or pin it and count how many stitches there should be. That should have the re-do correct.
I've never done a knit to fit cozy (dust cover for me). I find crochet easier for on the fly shaping.