The most important thing to realize is that 3 workers per mineral is the max you would want. It is not necessarily optimal however. The third worker is not as effective as the first 2. Once you have more than 2 workers, one of them will always be "hanging around" waiting for its turn to be useful. Therefore, if you have an expo with less than 2 workers per patch, you would do better to move some workers there. You will get more minerals per minute by having 2 workers per patch at your main and 1 per patch at your expo than you would with 3 workers per patch at your main.
With that in mind, here are some answers:
How to keep track of how many you have at a specific base?
Make sure all your mineral patches and gas geysers are visible on the screen. Now double click on one of your workers. This will select all your workers. At the bottom middle of your screen you'll see wireframes of all of them, 8 per row. if you have 3 rows full, that's 24 workers, which is a decently saturated base. "Full" saturation would be about 24 on minerals and 6 on gas, or 30. But if you have an expo, you're better off moving some of them... (Note that MULEs do not conflict with SCV's for mining time, so they should not factor into your counts.)
When you expand, should you build workers from that base or transfer?
This depends on the situation. If your expo is far away from your main, and there are potentially enemy forces in between, then transferring is probably a bad idea. If you have more than 2 workers per patch in your main, and your natural is nearby and well defended, then transferring makes sense. In my experience, Zerg players usually expand before they have much more than 2 workers per patch, while a 1 base terran or protoss will often build up 30 workers on one base before expanding.
**Rebuilding after some being killed **
I'm not sure what the question is here - you can just rebuild them like you normally build them.
Transferring when minerals run out
There is no automatic way to have workers move to an expansion when minerals or gas run out. However, you can listen for the voice that says "mineral patch depleted" and start transferring them. You can also look for the idle worker icon that pops up on the lower left hand side of your screen, that will alert you to a worker who is not doing anything.
Race Specific Tidbits
Protoss can chronoboost workers to help get an economy up and running, or recover from an attack.
Terrans can get by with less SCVs if they have a lot of orbital commands to summon MULEs with.
Terrans can load SCV's into command centers, then fly them to a new base.
Zerg players need to remember to build more drones to replace drones used to build buildings.
The easiest way to count harvesters is probably going to be to double click on a worker mining at each base. A full page is 24 workers and don't forget to add one for each geyser you have going (the double click won't select the worker currently inside of it). Just add up the results from there and it should be pretty close at least.
If you want your full worker count, you can also look at the bottom left to see your idle worker count and if for some reason it is not zero, then presumably these will have been missed by your mining worker counting and can be added as well. Other than that you are probably only going to miss a couple guys currently building things if you are terran. As far as non-mining workers though, this will really mostly apply to terran and even then will probably never average higher than 3 workers.
As for production, you should really never stop scv/probe production unless one of the following is true:
- You are planning a one or two base push and are at your desired number of workers for it.
- You absolutely have to to stay alive.
- You have in excess of ~70-75 workers.
The 70+ workers is enough to give you three bases worth of decent saturation while leaving enough room for an army.
As zerg things get trickier as you don't have a building dedicated to worker production, but since you didn't mention drones I won't get into that for now.
Best Answer
No
First of all, if you have 2 bases near a mineral patch, your drones/svcs/probes will always go to the closer base (rendering the other base obsolete).
The optimal amount is much less than 30 drones (30 is the amount where it is not possible to harvest minerals any faster from the given mineral field).
In HoTS, a fraction is displayed above your command centre/hatchery/nexus indicating how many harvesters you have over a suggested maximum of 24 (for bases with 8 mineral patches).
Refer to this page on liquipedia, which has an interesting graph about optimal amount of gatherers.