Anyways anti-spy tips :
1) Learn the location of different classes, ie, is there a engineer in a location where engineers don't often go? Shoot the hell out of them. This is also true for offensive classes walking backwards, offensive classes never go backwards, unless of course they're about to die.
2) Shoot at them, if they make any attempt to dodge your shots, its a spy. This is specially true with soldiers, your teamates will never attempt to dodge your rockets.
3) If you see yourself colliding with an ally, that's a spy. There's very little hit detection between you and your teamates to the point where you can basically walk right through them, this isnt true for spies. Also, if you see someone walking suspisiouly towards your back, that's a very good way to identify a spy who's trying to back stab. It's hard to explain it but there's something about the way they walk in a sort of circle towards your back.
4) Look to people who arent shooting, if one of your ally seems to be running around doing alot of nothing, that's a telltale sign of a spy, this last one's harder to notice unless you're really observant.
5) Whenever possible have your back against a wall.
6) Finally, when you're by yourself, be a bit paranoid, and flip to your back every once in a while, you might get lucky and find a spy uncloaking.