Objective To compare the effectiveness of molnupiravir, nirmatrelvir-ritonavir, and sotrovimab with no treatment in preventing hospital admission or death in higher-risk patients infected with SARS-CoV-2 in the community. Design Retrospective cohort study of non-hospitalised adult patients with COVID-19 using the Secure Anonymised Information Linkage (SAIL) Databank. Setting A real-world cohort study was conducted within the SAIL Databank (a secure trusted research environment containing anonymised, individual, population-scale electronic health record (EHR) data) for the population of Wales, UK. Participants Adult patients with COVID-19 in the community, at higher risk of hospitalisation and death, testing positive for SARS-CoV-2 between 16th December 2021 and 22nd April 2022. Interventions Molnupiravir, nirmatrelvir-ritonavir, and sotrovimab given in the community by local health boards and the National Antiviral Service in Wales. Main outcome measures All-cause admission to hospital or death within 28 days of a positive test for SARS-CoV-2. Statistical analysis Cox proportional hazard model with treatment status (treated/untreated) as a time-dependent covariate and adjusted for age, sex, number of comorbidities, Welsh Index of Multiple Deprivation, and vaccination status. Secondary subgroup analyses were by treatment type, number of comorbidities, and before and on or after 20th February 2022, when omicron BA.1 and omicron BA.2 were the dominant subvariants in Wales. Results Between 16th December 2021 and 22nd April 2022, 7,103 higher-risk patients were eligible for inclusion in the study. Of these, 2,040 received treatment with molnupiravir (359, 17.6%), nirmatrelvir-ritonavir (602, 29.5%), or sotrovimab (1,079, 52.9%). Patients in the treatment group were younger (mean age 53 vs 57 years), had fewer comorbidities, and a higher proportion had received four or more doses of the COVID-19 vaccine (36.3% vs 17.6%). Within 28 days of a positive test, 628 (9.0%) patients were admitted to hospital or died (84 treated and 544 untreated). The primary analysis indicated a lower risk of hospitalisation or death at any point within 28 days in treated participants compared to those not receiving treatment. The adjusted hazard rate was 35% (95% CI: 18-49%) lower in treated than untreated participants. There was no indication of the superiority of one treatment over another and no evidence of a reduction in risk of hospitalisation or death within 28 days for patients with no or only one comorbidity. In patients treated with sotrovimab, the event rates before and on or after 20th February 2022 were similar (5.0% vs 4.9%) with no significant difference in the hazard ratios for sotrovimab between the time periods. Conclusions In higher-risk adult patients in the community with COVID-19, those who received treatment with molnupiravir, nirmatrelvir-ritonavir, or sotrovimab were at lower risk of hospitalisation or death than those not receiving treatment.