This is something I've thought about a lot and I think most conversations about imposter syndrome skip over it.
There are two different problems that feel identical from the inside: You have the skills but don't believe you do. You don't have the skills and are correctly sensing a gap.
Both feel like imposter syndrome. The advice for one can make the other worse.
For case 1, the usual stuff applies: collect evidence of past wins, notice the cognitive distortion, talk to people who've seen your work.
For case 2, what you actually need is to close the gap, not to feel better about the gap. Telling a data scientist who doesn't know their causal inference to "feel more confident" is bad advice. The nervousness is accurate.
So how do I actually tell which one I'm in? Some things that helped me:
Ask someone whose opinion is calibrated. Not a friend who'll be kind. Someone who will tell you the truth. "Do you think I'm actually ready for a staff DS role or am I missing things?" A mentor or honest peer can separate these.
Look at whether your anxiety is domain-specific. Imposter syndrome tends to be global ("I don't belong here"). A real skill gap tends to be specific ("I'm not confident on the ML system design round in particular"). Specificity is a clue.
Try teaching something. If I can explain a concept to someone more junior and answer their follow-up questions, I actually know it. If I fold under basic questions, the gap is real.
Track where the anxiety is loudest. If it's loudest in your actual weak areas, listen to it. If it's loudest everywhere, it might be the syndrome.
The mix is almost always both. There are real gaps and there's also cognitive distortion on top of them. Separating the signal from the noise matters because the fix is different.