A bacterial metabolic probe combining D-alanine and a photosensitizer with aggregation-induced emission (AIE) has been developed for in vivo light-up imaging of bacterial walls and efficient antibacterial therapy. This activatable probe could serve as a promising non-antibiotic tool for diagnosis and treatment of biofilms and intracellular bacteria, as well as multi-resistant bacterial infections.