We investigated the relationship between characteristics of coffee shade systems and coffee pest infestation by the black coffee twig borer Xylosandrus compactus Eichhoff. The pest deprives Uganda of $40 millions annually, yet its control remains inadequate. The present study considered three rainfall zones in Central Uganda and 50 coffee plots that were randomly selected from each rainfall zone. Data were collected on X. compactus infestation and key shade indicators: canopy cover, tree‐species densities, diameter at breast height (DBH) and ratio of coffee to banana. Cluster analysis revealed two coffee shade systems: a matured shade tree (MST) system and a young poly‐culture (YPC) system. Xylosandrus compactus infestations were significantly less in the MST system than in the YPC system and significantly less in the low rainfall zone than in the high rainfall zone. An increase in the density of Carica papaya and Albizia chinensis significantly reduced and increased X. compactus infestation, respectively. A higher average DBH of individual trees and a higher density of trees that exude sap significantly lowered X. compactus infestation. Suppressing X. compactus infestation requires bigger trees, a high density of sap‐exuding trees and no Albizia chinensis. Further research should aim to investigate X. compactus flight activity and microclimate influencing X. compactus population dynamics.