One of my cats has a very similar issue, and no, keeping your face away from your cat isn't the solution (like some of the comments mentioned above). Mine's a senior and she was a stray island jungle cat so she can definitely be pretty feisty. She's only been with me for just under a year now and has come around, but I do notice that she doesn't know how to properly play with my other two cats and will just run up to them and swipe then run off (which can be a little clue). She can be extremely cuddly and typically follows me around, sleeps with me, sits beside me, and is very affectionate when you pick her up, going out of her way to nuzzle my face. And this is the tricky part because she has a similar reaction to your cat. She will be rubbing her face against mine and then out of nowhere will throw a claw in there. The switch can happen fairly often, and really quick. She isn't necessarily aggressive but has those random moments of being super feisty out of nowhere. I still haven't figured out how to reduce this behavior, but you're not alone.