Gram-positive bacteria colonize mucosal tissues, withstanding large mechanical perturbations such as coughing, which generate shear forces that exceed the ability of non-covalent bonds to remain attached. To overcome these challenges, the pathogen Streptococcus pyogenes utilizes the protein Cpa, a pilus tip-end adhesin equipped with a Cys–Gln thioester bond. The reactivity of this bond towards host surface ligands enables covalent anchoring; however, colonization also requires cell migration and spreading over surfaces. The molecular mechanisms underlying these seemingly incompatible requirements remain unknown. Here we demonstrate a magnetic tweezers force spectroscopy assay that resolves the dynamics of the Cpa thioester bond under force. When folded at forces <6 pN, the Cpa thioester bond reacts reversibly with amine ligands, which are common in inflammation sites; however, mechanical unfolding and exposure to forces >6 pN block thioester reformation. We hypothesize that this folding-coupled reactivity switch (termed a smart covalent bond) could allow the adhesin to undergo binding and unbinding to surface ligands under low force and remain covalently attached under mechanical stress. [Figure not available: see fulltext.] © 2020, The Author(s), under exclusive licence to Springer Nature Limited.