In their coexistence with microbes, animals must fortify themselves against the onslaught of pathogens while maintaining a healthful consortium of resident commensals. In a recent paper in Science, Ryu and colleagues report that in fruit flies the Caudal transcription factor regulates appropriate immune responses to commensal bacteria, and that when these immune responses are perturbed, the gut microbial consortium shifts to one that is harmful to its host.