Environmental stability of perovskite solar cells (PSCs) can be improved by a thin layer of low-dimensional (LD) perovskite sandwiched between the perovskite absorber and the hole transport layer (HTL). This layer, called ‘capping layer,’ has mostly been optimized by trial and error. In this study, we present a machine-learning framework to rationally design and optimize perovskite capping layers. We ‘featurize’ 21 organic halide salts, apply them as capping layers onto methylammonium lead iodide (MAPbI3) thin films, age them under accelerated conditions combining illumination and increased humidity and temperature, and determine features governing stability using random forest regression and SHAP (SHapley Additive exPlanations). We find that a low number of hydrogen-bonding donors and a small topological polar surface area of the organic molecules correlate with increased MAPbI3 film stability. The top performing organic halide salt, phenyltriethylammonium iodide (PTEAI), successfully extends the MAPbI3 stability lifetime by 4±2 times over bare MAPbI3 and 1.3±0.3 times over state-of-the-art octylammonium bromide (OABr). Through morphological and synchrotron-based structural characterization, we found that this capping layer consists of a Ruddlesden-Popper perovskite structure and stabilizes the photoactive layer by “sealing off” the grain boundaries and changing the lead surface chemistry, through the suppression of lead (II) iodide (PbI2) formation and methylammonium loss.