StarCraft II - How to handle a Zergling rush
Damn it. Keep your cool!
I'm saying this twice because people immediately make bad decisions the moment they get into a frenzy, myself included. Keep a cool head at all times when you're being rushed. Do not stop production, and do not double click accidentally! Selecting all of your workers can make your life hell to position, and you'll lose all income if you go for an attack with the whole mass at once.
There is only so many of the enemy. At most, you'll see 6-8 Zerglings or 1-2 zealots. You want to collapse your miners into a more congested area, by selecting half of them on a side and telling them to mine with the other half, and get your first combat unit or two right next to them and keep it alive! This comes into play when using the next tactic.
Use the AI against them.
I move one half of the scvs to the other half's mining area.....
Get your first combat unit started!
When your Barracks or Gateway finishes, start a unit immediately and set the rally point into your base! The sooner it comes out, the sooner this will all be over. Do not stop making workers during this, they're combat units too in this dire time!
Put it all together
...issue an attack order with the other half, and tell the moving group to move back to the minerals behind the Zerg before attack. The SCVs walk right by the Zerglings and surround them.
If he backs off for a second? Keep repeating the above until your first Zealot comes out! Keep cranking out workers and warriors until you are safe... for now.
The enemy is weak!
They sacrificed economy to get this attack in your face before you are ready. Now that the Zerglings are dealt with, you need to take the fight to them. The moment the coast is clear, scout for them if you haven't already, and if they seem weak, go for the throat! Skip teching and get multiple Gateways, Barracks, or a Queen/2nd Hatchery and send waves of low-tier units at them to exploit their low tech, low economy rush. Terran players can immediately go for a double gas refinery into Banshees and catch the Zerg before they can have anything to fight air besides a Queen. Once the initial threat is over, the game is yours. If your counterattack isn't working, don't take losses, get out! Don't throw the game away in a counter-rush of your own. Your opponent isn't about to just quit the moment his rush fails.
Then again, I've seen it happen!