Code is Science is back: the journal code policy tracker now covers 24 journals.See the tracker

How to write requirements for research software

Requirement types, who should write them, how to word them so they can be tested, a two-page template, and how much documentation a lab project really needs.

PracticeBy the Code is Science editorsDec 4, 202612 min read
Line illustration of a clipboard checklist linked by thin lines to a laptop, a microscope and a column of sticky notes on a lab desk
Key takeaways
  • Requirements for research software are short, checkable statements of what the code must do, for whom and how well.
  • Write the stable parts first and keep unknowns as open questions with an owner; revise at milestones.
  • Separate the research goal, user needs, functional behaviour and non-functional qualities such as accuracy and reproducibility.
  • Keep a numbered REQUIREMENTS.md in the repository and link issues and tests to each identifier.

Requirements for research software are short, testable statements of what the code must do, for whom, and how well, written before and during development so that everyone involved builds the same thing. In short: name the research question the software serves, list who will use it, write each requirement as one checkable sentence, separate what the code does from how well it must do it, and keep the list in the repository next to the code, where it changes as the science changes.

Most research code starts without any of this. Typically, a PhD student writes a script to answer one question, a second student extends it, a collaborator asks for a web version, and three years later nobody can say which behaviour is intended and which is an accident. A requirements list does not stop the science from moving. It records what the group agreed the software should do at each point, so a change is a decision rather than a surprise.

Industry teams write the same kind of document and call it a product requirements document, and a plain explainer on what a PRD in software development contains is a useful reference for its structure: goals, users, scope, functional and non-functional requirements, and how success is measured. This guide adapts that idea to a lab: lighter, iterative, and tied to the research question rather than to a market.

What are requirements for research software?

A requirement is a statement that the finished software must satisfy and that someone can check. "The tool reads CSV files exported from the plate reader" is a requirement. "The tool should be user-friendly" is a wish until you say who the user is and what friendly means for them.

Reed Milewicz, writing for Better Scientific Software, describes requirements as a device for communication between stakeholders rather than a technical specification for its own sake. That framing fits research well. The people who need to agree are a PI who knows the science, a student or research software engineer who writes the code, reviewers who will ask how results were produced, and, later, users in other groups.

Written requirements pay off in three concrete ways:

  • Shared scope. Everyone knows what is in version 1 and what waits, which stops feature creep from quietly eating a thesis.
  • Testable behaviour. Each requirement becomes one or more tests, so you can show the code does what the paper claims.
  • Handover. When the author leaves, the next person inherits intentions as well as code.

Can you write requirements when the science is still changing?

Yes, if you stop treating requirements as a contract frozen on day one. The common objection is that requirements emerge as the software and the understanding of the problem progress, so writing them up front is impossible. A 2024 study by Bajraktari, Binder and Vogelsang at the University of Cologne, Requirements Engineering for Research Software: A Vision, found exactly this view among researchers, alongside limited training in requirements practice and a sense that engineering process is overhead.

The counter-argument comes from scientific computing itself. Spencer Smith, Malavika Srinivasan and Sumanth Shankar, in Debunking the Myth that Upfront Requirements are Infeasible for Scientific Computing Software (SE4Science workshop at ICSE 2019), argue that requirements are feasible when you write the document as if it had been correct from the start, revise it as you learn, plan for a family of related programs rather than one, and use a template built for scientific computing. Their worked example is software for modelling the solidification of a metal alloy.

The practical lesson: split requirements into what is stable and what is open.

  • Stable: the inputs you will accept, the physical or statistical model you implement, units, platforms, licence, who the users are.
  • Open: parameters you are still exploring, algorithms you may swap, outputs that depend on results. Write these as explicit open questions with an owner, not as silence.

What kinds of requirements does research software have?

Research software has four layers of requirements, from the reason the project exists down to how fast a function must run. The Carpentries Intermediate Research Software Development lesson uses business, user and solution requirements, and splits solution requirements into functional and non-functional. Translated to a lab:

LayerQuestion it answersExample for a lab tool
Research goalWhy does the software exist?Estimate cell growth rates from time-lapse images for the grant's second aim.
User requirementWhat does each user group need to achieve?A technician can process one plate without writing code.
FunctionalWhat does the software do?Reads TIFF stacks, segments cells, exports one CSV row per cell per frame.
Non-functionalHow well, and under what constraints?Processes a 96-well plate in under 30 minutes on a standard lab workstation; runs on Linux and Windows; MIT licence.

Non-functional requirements deserve extra attention in research. Milewicz notes that maximising quality in every sense is impossible, so a project has to choose. A one-off analysis may need correctness and nothing else; a community package needs installability, documentation and stable interfaces; a clinical tool adds audit trails and validation.

Who should take part in writing the requirements?

The person who owns the research question should own the requirements, and the person who writes the code should draft them. Bajraktari and colleagues propose a "research owner" role for this: a senior scientist who balances the research vision against what the software can realistically do, similar to a product owner in industry.

Make a short stakeholder list before you write anything:

  • PI or research owner: decides scope and priorities.
  • Developers: students, postdocs or research software engineers who build and maintain it.
  • Direct users: lab members, technicians, collaborators in other groups.
  • Indirect stakeholders: reviewers and journals that want reproducible results, funders with data or software management plans, ethics boards and data protection officers for human data.

Indirect stakeholders are where many projects get caught late. A journal that requires code deposit or a funder that asks for a software management plan creates requirements just as real as any feature. Our guide to the software management plan covers what funders typically ask for.

How do you gather requirements in a research group?

Gather requirements by watching the current workflow and asking about decisions, not by asking people what features they want. Four methods work well in labs:

  1. Walk through the current process. Sit with the person who runs the analysis today and note every manual step, file format and judgement call. Each one is a candidate requirement.
  2. Write user stories. One line each: "As a technician, I want to process a plate from a folder of images so that I do not need to edit the script." Stories keep the user in view and translate easily into tests.
  3. Collect examples. Real input files, a result you trust, a figure from a previous paper. A requirement anchored to a real file is much harder to misread.
  4. Ask what would make the result wrong. Reviewers and domain experts can usually name the failure modes: unit mix-ups, edge cases in the data, assumptions of the model. These become correctness requirements.

How do you write a good requirement?

A good requirement is necessary, unambiguous, verifiable and free of design decisions. Milewicz lists necessary, feasible, unambiguous, complete, verifiable, traceable and design-independent as the properties to aim for. In practice, check each sentence against three questions: could two people read it differently, could a test show it is met, and does it say what rather than how?

Weak requirementProblemBetter version
The model should be fast.Not verifiable.One simulation year at 1 km resolution completes in under 2 hours on 32 cores.
Results must be accurate.No reference, no tolerance.Output matches the analytical solution for the test case to a relative error below 1e-6.
Use PostgreSQL to store samples.Design decision, not a need.Sample records from three sites can be queried by date and site by all project members.
Support all image formats.Unbounded scope.Reads 16-bit TIFF and OME-TIFF from the two microscopes used in the study.

Give every requirement an identifier (UR1, FR3.2, NFR4). The Carpentries lesson numbers them the same way, and the identifiers let you link issues, commits and tests to the requirement they serve.

What should a requirements document for research software contain?

A requirements document for research software needs eight short sections, and for a small project the whole thing fits on two pages in the repository as REQUIREMENTS.md:

  1. Purpose and research question. Two or three sentences, with a link to the grant aim or paper.
  2. Stakeholders and users. The list from above, with one line on what each needs.
  3. Scope. What version 1 includes, and an explicit "not in scope" list.
  4. Theory and assumptions. Equations, statistical models, units and simplifying assumptions. Smith and colleagues treat this section as central for scientific computing, because it is where correctness is defined.
  5. Functional requirements. Numbered, one checkable sentence each.
  6. Non-functional requirements. Performance, platforms, accuracy, reproducibility, licence, data protection.
  7. Open questions. Unknowns, each with an owner and a date to revisit.
  8. Change log. What changed, when and why, so the history of decisions survives.

How much requirements documentation does a project need?

Match the effort to how long the code will live and how many people depend on it. The Cologne study suggests introducing structured practices in proportion to the growth of the project rather than all at once.

Project typeWhat to writeWhere it lives
One-off analysis scriptPurpose, inputs, expected outputs, one trusted resultREADME
Lab tool used by several peopleUser stories, numbered functional and non-functional requirements, open questionsREQUIREMENTS.md plus issues
Community package or science gatewayFull document, glossary, interface specifications, prioritised backlogDocs site plus issue tracker with labels
Software used in clinical or regulated workFormal specification with traceability from requirement to test and validation evidenceControlled documents under change management

How do you write reproducibility and accuracy requirements?

Write reproducibility and accuracy as non-functional requirements with numbers, so they can be tested rather than hoped for. Bajraktari and colleagues suggest treating reproducibility as a quality attribute made of portability, installability and analysability. Examples:

  • "A new user installs the software and its dependencies with one command from a clean environment."
  • "Running the pipeline twice on the same input with the same seed produces identical output files."
  • "Results on Linux and macOS agree to a relative tolerance of 1e-9."
  • "Every published figure can be regenerated from a tagged release and an archived dataset."

Each of these maps to a check you can automate. Our guides to testing research code and reproducible environments show how.

How do you keep requirements up to date as the project grows?

Keep requirements in version control, next to the code, and review them at fixed points rather than whenever someone remembers. Three habits make this work:

  • Link everything to an identifier. Issues reference the requirement they implement; tests carry the identifier in their name or docstring. When a requirement changes, a search shows what code and which tests are affected.
  • Review at milestones. Before a paper submission, a new student joins or a release, read the list and update it. Twenty minutes in a group meeting is enough.
  • Record decisions, not just results. When the science changes a requirement, write the reason in the change log. Reviewers asking "why did the method change between versions?" get an answer.

What changes when an outside team builds the software?

When someone outside the group builds the software, the requirements document becomes the basis of the agreement, so gaps that a lab member would fill from context turn into delays, disputes or extra cost. A contracted developer or an institutional RSE team does not share the hallway conversations that shaped the project.

Before commissioning work, add four things to the document: acceptance criteria for each requirement (how you will check it is done), the test data and trusted results the developer can use, ownership and licensing of the code, and who maintains it after delivery. Our guide on outsourcing research software development goes through contracts and handover; the research software engineers article covers in-house options.

Which mistakes make requirements fail in research projects?

Most requirement documents in research fail because they are written once and then ignored, not because they are badly worded. The most common patterns:

  • Writing the solution instead of the need. "Build a Django app" fixes the technology before anyone has agreed what the users must do. Keep tools and frameworks in the design notes.
  • No numbers on quality. "Fast", "accurate" and "scalable" cannot be tested. Every non-functional requirement needs a threshold, a reference or a test case.
  • Forgetting indirect stakeholders. Data protection rules, journal code policies and funder requirements arrive late and force rework.
  • A document nobody owns. If no one is named as responsible for the list, it goes stale within a term.
  • Hiding the unknowns. Leaving open questions out makes the document look complete and makes the gaps invisible. Listing them is what lets the group plan around them.

What to do this week: write requirements for one project

  1. Pick the piece of code that the most people depend on.
  2. Write its purpose and research question in three sentences.
  3. List the users and indirect stakeholders, including journals and funders.
  4. Write ten numbered requirements, at least three of them non-functional, each one checkable.
  5. Add an open questions list with owners.
  6. Commit it as REQUIREMENTS.md, link it from the README, and put a review on the agenda of the next group meeting.

Questions about requirements for research software

What are requirements for research software?

They are short, testable statements of what the software must do, for whom and how well. They cover the research goal, user needs, functional behaviour and non-functional qualities such as accuracy, performance and reproducibility.

Can you write requirements if the research is exploratory?

Yes. Write the stable parts first, such as inputs, models, units, platforms and users, and list the unknowns as open questions with an owner. Revise the document at milestones instead of freezing it on day one.

What is the difference between functional and non-functional requirements?

Functional requirements say what the software does, for example reading a file format or exporting a table. Non-functional requirements say how well it must do it and under what constraints, for example run time, numerical tolerance, supported platforms or licence.

Where should a lab keep its software requirements?

In the same repository as the code, usually as a REQUIREMENTS.md file linked from the README, with numbered requirements that issues and tests can reference.

How detailed should requirements be for a small analysis script?

A one-off script needs only its purpose, inputs, expected outputs and one trusted result, written in the README. Lab tools, community packages and regulated software need progressively more.

Keep reading. More from the desk.