It's very hard to develop a built-in resistance to this kind of manipulation, except for one very strong thing: people who are likely to gaslight you are likely to not respect your boundaries because gaslighting is a form of boundary violation.
The other one is to have a robust support network of the kind of people who respect your boundaries. Those behaviors are correlated with identifying when someone is trying to gaslight and warning you. This is particularly helpful when you are already vulnerable due to poor social intelligence, trauma from previous abuse, or otherwise in a vulnerable moment (tired, inebriated, angry or upset, etc).