When searching for spies, look out for certain disguises. If a spy is disguised as a scout, he will be moving slower that a usual scout would. If a spy is disguised as a medic, he will not have an ubercharge. Also, watch out for "teammates" closely following other teammates. Chances are they are trying to backstab them.
Be very observant of all your teammates. A spy will have your name when you see them. Make sure to check if anyone is following you for "no reason", or if someone is coming in the opposite direction of your base. Also be careful to talk to everyone. If the person does not talk to you, they either do not have a mic or is a spy. You could also shoot everyone you see. Teammates will not get hurt. If a spy is shot they will not show themselves; you must shoot them a good amount. If the bullets do not go through the "teammate", it is most likely a spy. Remember to look out for unusual movement. A spy disguised as a scout will be slower and spy disguised as a heavy will be faster. You also might want to set up a system where whenever someone sees a teammate they shoot a round off. Spies cannot shoot or their cover is blown. There is no reason for any teammate to follow you. Spies can also destroy sentries, espensers and other things without blowing their cover. If no one but you and someone else is around and your gun just got destroyed, open fire or beat him down with your wrench. Follow these tips and spies will be changing classes quickly. You can also play a spy a few times, to quickly learn the advantages and disadvantages of that class.
There are several ways to reveal an enemy spy. Walking into a spy will make him translucent for a moment. You can walk through teammates, but cannot walk through disguised enemy spies. Attack the spy if you come across him, as all he can do run away. Igniting a cloaked enemy spy will set him on fire and distinguishes him with an enemy-colored glow.
A spy disguised as a medic will not have the ubercharge/kritzkrieg percentage display under the name.
When disguised, the health shown for a spy is never in the red zone. If you see someone with health in the red, it is not a spy. If not, pay attention.
The spy is always showing the primary weapon for a particular class. They cannot show melee or secondary weapons. If one of your teammates is showing any other weapon, you can be sure that it is not a spy. The following is a list of the primary weapons for each class.
Scout: Scattergun
Soldier: Rocket launcher
Heavy: Minigun
Demoman: Grenades launcher
Engineer: Shotgun
Medic: Syringues launcher
Spy: Handgun
Sniper: Sniper rifle
Pyro: Flamethrower
A spy cannot shoot or he will loose his cover. If a teammate does not seem to be shooting, it could be a spy.
If a teammate is voice chatting at the moment you see him without the "?" sign indicating this is happening, it is a spy.
This trick works when a teammate is dead. If you know that he just got killed but see him running near you, it is a spy. The same applies if he is calling "Medic" while the real one is dead.
This requires a medic with the upgraded syringes gun. Shoot some syringes at teammates. If one of them is showing the crosses indicating that you are hitting an enemy, it is a spy.
If you see a blue ball or a red ball near dispensers, it is a cloaked spy.