The production of natural product compound libraries has been observed in nature for different organisms such as bacteria, fungi and plants; however, little is known about the mechanisms generating such chemically diverse libraries. Here we report mechanisms leading to the biosynthesis of the chemically diverse rhabdopeptide/xenortide peptides (RXPs). They are exclusively present in entomopathogenic bacteria of the genera Photorhabdus and Xenorhabdus that live in symbiosis with nematodes delivering them to insect prey, which is killed and utilized for nutrition by both nematodes and bacteria. Chemical diversity of the biologically active RXPs results from a combination of iterative and flexible use of monomodular nonribosomal peptide synthetases including substrate promiscuity, enzyme cross-talk and enzyme stoichiometry as shown by in vivo and in vitro experiments. Together, this highlights several of nature’s methods for diversification, or evolution, of natural products and sheds light on the biosynthesis of the bioactive RXPs.