Tumor heterogeneity of immune infiltration of cells plays a decisive role in hepatocellular carcinoma (HCC) therapy response and prognosis. This study investigated the effect of different subtypes of CD8+T cells on the HCC tumor microenvironment about its prognosis. Single-cell RNA sequencing, transcriptome, and single-nucleotide variant data from LUAD patients were obtained based on the GEO, TCGA, and HCCD18 databases. CD8+ T cells-associated subtypes were identified by consensus clustering analysis, and genes with the highest correlation with prognostic CD8+ T cell subtypes were identified using WGCNA. The ssGSEA and ESTIMATE algorithms were used to calculate pathway enrichment scores and immune cell infiltration levels between different subtypes. Finally, the TIDE algorithm, CYT score, and tumor responsiveness score were utilized to predict patient response to immunotherapy. We defined 3 CD8+T cell clusters (CD8_0, CD8_1, CD8_2) based on the scRNA- seq dataset (GSE149614). Among, CD8_2 was prognosis-related risk factor with HCC. We screened 30 prognosis genes from CD8_2, and identified 3 molecular subtypes (clust1, clust2, clust3). Clust1 had better survival outcomes, higher gene mutation, and enhanced immune infiltration. Furthermore, we identified a 12 genes signature (including CYP7A1, SPP1, MSC, CXCL8, CXCL1, GCNT3, TMEM45A, SPP2, ME1, TSPAN13, S100A9, and NQO1) with excellent prediction performance for HCC prognosis. In addition, High-score patients with higher immune infiltration benefited less from immunotherapy. The sensitivity of low-score patients to multiple drugs including Parthenolide and Shikonin was significantly higher than that of high-score patients. Moreover, high-score patients had increased oxidative stress pathways scores, and the RiskScore was closely associated with oxidative stress pathways scores. And the nomogram had good clinical utility. To predict the survival outcome and immunotherapy response for HCC, we developed a 12-gene signature based on the heterogeneity of the CD8+ T cells.