Yes, it's really fascinating stuff. Just to add to that, cells must present a continuous sample of their proteasome on the cell surface in the form of a short peptide 9-12 amino acids long. T cells will recognise when the cell is producing protein it shouldn't be (i.e. because it became cancerous or infected with a virus), even if only one amino acid is incorrect.
It learns this in the thymus, which has a bizarre gene called AIRE which switches on genes from all over the body, essentially creating a representation of the entire body in the thymus gland as a sort of sandbox before they are let out.
However, we don't have enough T cells to recognise every possible sequence of 11 amino acids (which would weigh around 1.5 tons), so T cells must be so-called 'cross-reactive'[1]. And therefore other factors must go into how T cells respond to abnormalities.
[1] https://www.nature.com/articles/nri3279