All cellular life possesses environmental interfaces like cell membranes or cell walls, yet the compositional complexity of these major cell components limits structural and evolutionary studies. Prokaryotic surface layer (S-layer) exoskeletons, with their homopolymer paracrystalline architecture, offer a more tractable model of an environmental interface. However, extreme sequence diversity and heterogeneous multidomain organisation of S-layer proteins confound conventional evolutionary analyses. Here, by combining phylogenomics with structural modelling, we show that extensive sequence divergence, modular evolution and lateral gene transfer drive lineage-specific S-layer diversification across both monoderm (Bacillaceae, Peptostreptococcaceae) and diderm (Caulobacteraceae, Deinococcaceae) bacteria. Focusing on the Gram-positive order Peptostreptococcales, including environmental isolates and clinical pathogens, we uncover multiple S-layer architectures conferring divergent physiological properties. Molecular microbiology reveals that among close relatives utilising the same exoskeleton type, only pathogens display resistance to the antimicrobial immune effectors LL-37 and lysozyme. Furthermore, by experimentally determining two S-layer structures, we unravel how mechanisms including (intra)domain gains and losses generate hyper-diversity of homologous S-layers among clinical isolates of the pathogen Clostridioides difficile. Our findings establish the S-layer as a paradigm of molecular modularity and evolutionary plasticity. Specifically, evolution of a single structural protein enables rapid cell-surface reconfiguration and contributes to immune evasion in bacterial pathogens.