CRISPR–Cas12a was used to directly replace mouse antibody variable chain genes with human versions in primary B cells. The edited cells underwent affinity maturation in vivo, improving the potency of HIV-1 and SARS-CoV-2 neutralizing antibodies without loss of bioavailability. Affinity maturation of edited cells also enables new vaccine models and adaptive B cell therapies.