What are the rules for China’s visa-free transit programs?

Assuming one wants to travel through China, what are the rules for visa-free access? To be more specific:

  • How does the 24-hour visa free transit work?
  • How does the 72-hour version work?
  • What does a person ineligible for either of these programs have to do to transit China?
  • Do the programs apply to flights only or do they also work for transit on land?
  • Would a visitor save much hassle by using visa free transit instead of just getting a visa?

NB: this is intended as a canonical question on transiting China