Abstract Background and Aims As the leading cause of chronic kidney disease, diabetic kidney disease (DKD) is an enormous burden for all healthcare systems around the world. However, its early diagnosis has no effective methods. Method First, gene expression data in GEO database were extracted, and the differential genes of diabetic tubulopathy were obtained. Immune-related gene sets were generated by WGCNA and immune cell infiltration analyses. Then, differentially expressed immune-related cuproptosis genes (DEICGs) were derived by the intersection of differential genes and genes related to cuproptosis and immune. To investigate the functions of DEICGs, volcano plots and GO term enrichment analysis was performed. Machine learning and protein-protein interaction (PPI) network analysis helped to finally screen out hub genes. The diagnostic efficacy of them was evaluated by GSEA analysis, receiver operating characteristic (ROC) curve, single-cell RNA sequencing and the Nephroseq website. The expression of hub genes at the animal level by STZ -induced and db/db DKD mouse models was further verified. Results Finally, three hub genes, including FSTL1, CX3CR1 and AGR2 that were up-regulated in both the test set GSE30122 and the validation set GSE30529, were screened. The areas under the curve (AUCs) of ROC curves of hub genes were 0.911, 0.935 and 0.922, respectively, and 0.946 when taking as a whole. Correlation analysis showed that the expression level of three hub genes demonstrated their negative relationship with GFR, while those of FSTL1 displayed a positive correlation with the level of serum creatinine. GSEA was enriched in inflammatory and immune-related pathways. Single-nucleus RNA sequencing indicated the main distribution of FSTL1 in podocyte and mesangial cells, the high expression of CX3CR1 in leukocytes and the main localization of AGR2 in the loop of Henle. In mouse models, all three hub genes were increased in both STZ-induced and db/db DKD models. Conclusion Machine learning was combined with WGCNA, immune cell infiltration and PPI analyses to identify three hub genes associated with cuproptosis, immunity and diabetic nephropathy, which all have great potential as diagnostic markers for DKD and even predict disease progression.