Here, we report a method for the one-pot ribosomal synthesis of macrocyclic depsipeptides. This method is based on a Ser-Pro-Cys-Gly (SPCG) motif discovered by in vitro selection of peptides for the function of self-acylation in the presence of a thioester acyl donor, which forms an O-acyl isopeptide bond via intramolecular S-to-O acyl transfer. Ribosomal synthesis of linear peptides containing the SPCG motif and a backbone "acyl donor" thioester at a downstream position results in spontaneous conversion to the corresponding cyclic depsipeptides (CDPs) in a nearly independent manner of ring size and sequence context. Mutational analysis of the SPCG motif revealed that the P and G residues are dispensable to some extent, but the arrangement of residues in SXCX is crucial for efficient acyl transfer, e.g., CPSG is much less efficient. Finally, one-pot ribosomal synthesis of macrocyclic depsipeptides with various ring sizes and sequences has been demonstrated. This synthetic method can facilitate the ribosomal construction of highly diverse CDP libraries for the discovery of de novo bioactive CDPs.