Escherichia coli exhibits remarkable genetic diversity that enables it to adapt to the intestinal environment. Here we establish an in vivo CRISPR interference platform that leverages bacterial gene fitness as a high-resolution functional reporter of E. coli adaptations within mice harbouring a defined minimal microbial community (OligoMM12). The screen revealed that diet profoundly shapes the metabolic landscape of E. coli and the essential gene profile identified cross-feeding interactions. Comparison between a laboratory strain (MG1655), a uropathogenic strain (CFT073) and an adherent-invasive E. coli (AIEC LF82) identified distinct genetic requirements for intestinal colonization, highlighting divergent motility, stress response and respiration strategies. In a host inflammatory environment, we found that AIEC LF82 preferably colonized the small intestine with a mobile genetic element, Gally prophage, playing an important role in modulating fitness. These findings provide a high-resolution genetic atlas of E. coli's functional adaptation and demonstrate the utility of functional genomics to probe the gut environment itself.