The immune microenvironment influences tumour evolution and can be both prognostic and predict response to immunotherapy1,2. However, measurements of tumour infiltrating lymphocytes (TILs) are limited by a shortage of appropriate data. Whole-exome sequencing (WES) of DNA is frequently performed to calculate tumour mutational burden and identify actionable mutations. Here we develop T cell exome TREC tool (T cell ExTRECT), a method for estimation of T cell fraction from WES samples using a signal from T cell receptor excision circle (TREC) loss during V(D)J recombination of the T cell receptor-α gene (TCRA (also known as TRA)). TCRA T cell fraction correlates with orthogonal TIL estimates and is agnostic to sample type. Blood TCRA T cell fraction is higher in females than in males and correlates with both tumour immune infiltrate and presence of bacterial sequencing reads. Tumour TCRA T cell fraction is prognostic in lung adenocarcinoma. Using a meta-analysis of tumours treated with immunotherapy, we show that tumour TCRA T cell fraction predicts immunotherapy response, providing value beyond measuring tumour mutational burden. Applying T cell ExTRECT to a multi-sample pan-cancer cohort reveals a high diversity of the degree of immune infiltration within tumours. Subclonal loss of 12q24.31–32, encompassing SPPL3, is associated with reduced TCRA T cell fraction. T cell ExTRECT provides a cost-effective technique to characterize immune infiltrate alongside somatic changes.