How can I render only shadow in Cycles?
A shadow catcher was added in blender 2.79.

There is no reason to use compositor tricks any longer to generate a shadow. You simply add an object (In my case a simple plane) and check the Shadow Catcher box.

Go to the Object tab of the Properties Editor. In 2.79 the Shadow Catcher option is in the Cycles Settings section. In 2.8 the Shadow Catcher option is in the Visibility section.

 

Here is what my rendered scene looks like so far.


Now to get just the shadow you need to disable the Camera visibility on all the other objects. This setting is in nearly the same place as the shadow catcher. Go to Object tab of the Properties Editor. In 2.79 it's under the Cycles Settings section. In 2.8 it is in the Ray Visibility subsection of the Visibility section.