a, WT mice were transferred naive gBT-I.CD45.1 (gBT-I) cells and e.c. inoculated with B16.gB cells. A separate group of mice received naive gBT-I.CD45.1 cells followed by skin infection with HSV (not shown). Three to four weeks after tumour or viral challenge, mice were i.v. injected with either gB or Ova peptide and brefeldin A, and organs were harvested for flow cytometric analysis 4–5 hours later. b, Proportion of gBT-I cells expressing the indicated cytokines (IFN-γ and TNF-α) isolated from HSV-challenged skin (green), peritumoural skin from developer mice (pink) or tumour-free skin of non-developer mice (orange) administered either gB or Ova peptide. c, In vitro activated gBT-I.CD45.1 cells were transferred to WT mice bearing macroscopic B16.gB tumours or to a separate group of previously naive mice that were then treated with DNFB on skin to facilitate T RM generation. Two weeks later, populations of CD69+ CD103+, CD69+ CD103− and CD69− CD103− gBT-I cells were sorted from DNFB-treated skin (‘Control skin’) or tumour samples, respectively, and expression of the indicated genes was analysed using qPCR. Gene expression is normalized to expression of the housekeeping genes Hprt, Gapdh and Tbp and shown as fold change relative to expression in CD69− populations of gBT-I cells in the spleen. d, WT mice were transferred naive gBT-I.CD45.1 cells and e.c. inoculated with B16.gB cells. Shown is surface expression of PD-1 by gBT-I cells isolated from the indicated organs compared with PD-1 expression in bulk CD8+ Vα2+ T cells from the same tissue at more than 3 weeks post-inoculation. e, Mice were transferred naive gBT-I.CD45.1 cells and e.c. inoculated with B16.gB.Tyr–/–.mCherry cells. Shown is the proportion of gBT-I T RM cells in peritumoural or tumour-free (non-developer) skin expressing PD-1 at more than 2–3 weeks post-inoculation. Data pooled from n = 4 biologically independent experiments with n = 9 (HSV, Ova), n = 17 (melanoma, Ova), n = 5 (non-developer, Ova), n = 11 (HSV, gB), n = 19 (melanoma, gB) or n = 9 (non-developer, gB) mice (a, b); n = 2 biologically independent experiments with n = 20 (control) and n = 43 (melanoma) mice per group (c); are representative of n = 2 biologically independent experiments with n = 10 mice (d); or pooled from n = 2 biologically independent experiments with n = 27 (melanoma, peritumoural) or n = 20 (non-developer) mice (e). Source data