Whether a world keeps its air is a race between gravity and heat.
Every world is leaking. Earth loses about three kilograms of hydrogen to space each second. It is happening now, quietly, over your head.
This page’s interactive simulation and its seven layers need JavaScript. With it switched off, here is the summary.