I have been watching Scott Manley's KSP tutorials, specifically this one here. He intentionally strands a Kerbal in orbit, then shows how to build a "rescue rocket", but doesn't go very in depth on the latter. I have pasted the video at the point where he begins talking about the rescue rocket, but I don't understand why he attaches the Stayputnik probe to the top of the command capsule? What purpose does this serve for a rescue mission?
Using a stayputnik or other drone module along with a kerbal command capsule means the rocket can be remotely piloted without a kerbal in the capsule at launch.
This way, you can remove your pilot before launch, and the stranded kerbal can get into the empty command capsule to return home.