In this Perspective article, Bernheim and Sorek present the ‘pan-immune system’ model in which bacteria employ horizontal gene transfer to access immune defence mechanisms encoded by closely related strains, and conclude by discussing the implications on the evolution of anti-defence strategies in phages.