Skip to main content


If you’d like to write a study using OpenSAFELY, then the documentation is the best place to start; the getting started guide covers setting up your computer and writing a “toy” study. After that, the study definition section describes how to define the patient population, as well as the associated variables, in detail. You can copy the research template to write your study even faster, using other OpenSAFELY studies for help. You can find other OpenSAFELY studies within our OpenSAFELY GitHub organisation.

Most studies are based on a codelist, or a list of codes for clinical events or demographic characteristics. You can create and share codelists using OpenCodelists. We have created and shared over 370 codelists, which we have used in over 20 published papers.

OpenSAFELY has many components; the most important are the command-line interface; ehrQL (the Electronic Health Record Query Language); and the job runner/job server.

  • Use the command-line interface to control the other components. For example, running opensafely codelists update updates your study’s codelists to match those at OpenCodelists.
  • Use ehrQL to generate expected, or “dummy”, data when writing your study and real data when running your study in a secure environment.
  • Use the job runner/job server at OpenSAFELY Jobs to run your study in a secure environment.

You can find these, and more, within our OpenSAFELY Core GitHub organisation.

OpenSAFELY is under constant development; we suggest you regularly check our Platform News page to learn about significant improvements to the platform and other important updates.