Functional T-cell responses are essential for virus clearance and long-term protection after severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) infection, whereas certain clinical factors, such as older age and immunocompromise, are associated with worse outcome. We sought to study the breadth and magnitude of T-cell responses in patients with coronavirus disease 2019 (COVID-19) and in individuals with inborn errors of immunity (IEIs) who had received COVID-19 mRNA vaccine. Using high-throughput sequencing and bioinformatics tools to characterize the T-cell receptor β repertoire signatures in 540 individuals after SARS-CoV-2 infection, 31 IEI recipients of COVID-19 mRNA vaccine, and healthy controls, we quantified HLA class I- and class II-restricted SARS-CoV-2-specific responses and also identified several HLA allele-clonotype motif associations in patients with COVID-19, including a subcohort of anti-type 1 interferon (IFN-1)-positive patients. Our analysis revealed that elderly patients with COVID-19 with critical disease manifested lower SARS-CoV-2 T-cell clonotype diversity as well as T-cell responses with reduced magnitude, whereas the SARS-CoV-2-specific clonotypes targeted a broad range of HLA class I- and class II-restricted epitopes across the viral proteome. The presence of anti-IFN-I antibodies was associated with certain HLA alleles. Finally, COVID-19 mRNA immunization induced an increase in the breadth of SARS-CoV-2-specific clonotypes in patients with IEIs, including those who had failed to seroconvert. Elderly individuals have impaired capacity to develop broad and sustained T-cell responses after SARS-CoV-2 infection. Genetic factors may play a role in the production of anti-IFN-1 antibodies. COVID-19 mRNA vaccines are effective in inducing T-cell responses in patients with IEIs.