My method of knowing how many chain links to use depends on how the chain looks when I shift it to "small-small" gear combo. That's the 11t gear in the cassette and the smallest size chainring (unless you're on 1x drivetrain).
If the chain isn't slack, I add 1 link and so on and so forth until it's slacking just a little bit. That's how I do it to maximize the number of chain links possible so when I shift to the 42t cassette for example and the biggest chainring, the chain won't be too tight and the rear derailleur doesn't look like it's reaching for it's soulmate.