BackgroundHepatocellular carcinoma (HCC) is the fifth most frequently diagnosed malignancy and the third leading cause of cancer death globally. T cells are significantly correlated with the progression, therapy and prognosis of cancer. Limited systematic studies regarding the role of T-cell-related markers in HCC have been performed.MethodsT-cell markers were identified with single-cell RNA sequencing (scRNA-seq) data from the GEO database. A prognostic signature was developed with the LASSO algorithm in the TCGA cohort and verified in the GSE14520 cohort. Another three eligible immunotherapy datasets, GSE91061, PRJEB25780 and IMigor210, were used to verify the role of the risk score in the immunotherapy response.ResultsWith 181 T-cell markers identified by scRNA-seq analysis, a 13 T-cell-related gene-based prognostic signature (TRPS) was developed for prognostic prediction, which divided HCC patients into high-risk and low-risk groups according to overall survival, with AUCs of 1 year, 3 years, and 5 years of 0.807, 0.752, and 0.708, respectively. TRPS had the highest C-index compared with the other 10 established prognostic signatures, suggesting a better performance of TRPS in predicting the prognosis of HCC. More importantly, the TRPS risk score was closely correlated with the TIDE score and immunophenoscore. The high-risk score patients had a higher percentage of SD/PD, and CR/PR occurred more frequently in patients with low TRPS-related risk scores in the IMigor210, PRJEB25780 and GSE91061 cohorts. We also constructed a nomogram based on the TRPS, which had high potential for clinical application.ConclusionOur study proposed a novel TRPS for HCC patients, and the TRPS could effectively indicate the prognosis of HCC. It also served as a predictor for immunotherapy.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12859-023-05344-7.