Metagenomic sequencing has the potential to transform microbial detection and characterization, but new tools are needed to improve its sensitivity. We developed CATCH (Compact Aggregation of Targets for Comprehensive Hybridization), a computational method to enhance nucleic acid capture for enrichment of diverse microbial taxa, and implemented it in a publicly available software package. CATCH designs compact probe sets that achieve full coverage of known microbial sequence diversity and that scale well with this diversity. Using CATCH, we designed and synthesized multiple probe sets, including one to capture whole genomes of the 356 viral species known to infect humans, and conducted a rigorous evaluation of their performance. Capture with these probe sets enriched unique viral content on average 18-fold in sequencing libraries from patient and environmental samples and allowed us to assemble viral genomes that we could not otherwise recover. We show that capture accurately reflects co-infections and within-host nucleotide variation, enriches sequence with substantial divergence from the probe sets, and improves detection of viral infections in samples with unknown microbial content. Our work provides a new approach to probe design and evaluation, and demonstrates a path toward more sensitive, cost-effective metagenomic sequencing.