Amphibians and reptiles are important indicators of ecosystem health, yet their populations are declining worldwide due to habitat loss and climate change. Agroecosystems, such as coffee plantations, can provide important habitat for these species. We conducted field surveys in the Sumapaz region of Colombia to identify the habitat structural variables that influence the diversity and abundance of herpetofauna in coffee crops. The canonical correspondence analysis revealed that abundance of leaf litter, leaf litter moisture, shade percentage, plantation area, and plantation age category were the most important variables for determining herpetofauna diversity. Our findings suggest that shaded coffee plantations can sustain herpetofauna diversity, and maintaining a thick layer of leaf litter is critical for establishing complex and structured animal communities. This study proposes a set of sustainable agricultural management principles to promote the existence of amphibians and reptiles in coffee crops. By adopting these practices, it is possible to prevent the decline in the population of amphibians and reptiles due to the expansion of the agricultural frontier, as seen in other coffee-growing regions. The findings of this study contribute to a better understanding of how to balance agricultural production and biodiversity conservation in the context of agroecosystems.