Surface trap-mediated nonradiative charge recombination is a major limit to achieving high-efficiency metal-halide perovskite photovoltaics. The ionic character of perovskite lattice has enabled molecular defect passivation approaches through interaction between functional groups and defects. However, a lack of in-depth understanding of how the molecular configuration influences the passivation effectiveness is a challenge to rational molecule design. Here, the chemical environment of a functional group that is activated for defect passivation was systematically investigated with theophylline, caffeine, and theobromine. When N-H and C=O were in an optimal configuration in the molecule, hydrogen-bond formation between N-H and I (iodine) assisted the primary C=O binding with the antisite Pb (lead) defect to maximize surface-defect binding. A stabilized power conversion efficiency of 22.6% of photovoltaic device was demonstrated with theophylline treatment.