T cells play a central role in immune protection against pathogens. After resolution of an infection, tissue-resident memory T cells (TRM) provide a high degree of protection against localised infection. However, they may also drive aberrant immune responses associated with autoimmunity. Here, we investigated the role of the protein tyrosine phosphatase non-receptor type 2 (Ptpn2) in TRM formation and function using models of Herpes simplex virus skin infection and skin autoimmunity. We observed a profound defect of Ptpn2-deficient CD8 T cells in forming TRM populations in vivo. Mechanistically, Ptpn2-deficient CD8 T cells displayed a defect in seeding the skin with KLRG1- TRM precursors. Normalising memory precursor frequencies by cell sorting or modulation of T cell activation conditions rescued the defect in TRM generation. Finally, Ptpn2-deficient TRM cells in skin accelerated disease onset and severity in an inducible mouse model of autoimmune dermatitis compared to Ptpn2-competent T cells. Our study reveals a dual role for Ptpn2 in skin TRM, promoting TRM development by enhancing precursor frequencies and regulating potentially detrimental effector functions in the context of skin autoimmunity.