MUST, SHOULD, and MAY: Using RFC 2119 Keywords in Your Own Specs
Quick answer
RFC 2119 gives a short list of words, including MUST, SHOULD, and MAY, a precise meaning, and RFC 8174 adds that those meanings apply only when the words are in all capitals. Paste one boilerplate sentence into your spec, write the keywords in capitals, and "you must" stops being a matter of opinion. Most RFCs share this vocabulary, and it works just as well in a README, an API note, or a team convention file. Specs you depend on, like the CSV quoting rules from RFC 4180, lean on the same idea: be exact about what is required.
What each keyword means
RFC 2119, written by Scott Bradner in 1997, defines the words one by one.
MUST and MUST NOT
MUST, or REQUIRED or SHALL, means the item is an absolute requirement of the specification. MUST NOT, or SHALL NOT, is an absolute prohibition. Break one and the implementation doesn't conform.
SHOULD and SHOULD NOT
SHOULD, or RECOMMENDED, means there may be valid reasons in particular circumstances to ignore an item, but the full implications must be understood and carefully weighed before choosing a different course. SHOULD NOT, or NOT RECOMMENDED, is the mirror image: the behavior can be acceptable or even useful in some cases, but you should understand the consequences first.
MAY
MAY, or OPTIONAL, means an item is truly optional. One implementation can include it because its market needs it, another can skip it. The catch is interoperability: an implementation without the option must be ready to work with one that has it, and the other way around.
| Keyword | Plain meaning | | --- | --- | | MUST | Required, no exceptions | | MUST NOT | Forbidden, no exceptions | | SHOULD | Expected, with a good reason to deviate and a clear head about the cost | | SHOULD NOT | Avoid, unless you have a good reason | | MAY | Up to the implementer |
Only capitals count: the RFC 8174 rule
RFC 2119 said these words "are often capitalized". That wording left readers unsure whether a lowercase "must" in the same document carried the special meaning. RFC 8174, published by Barry Leiba in 2017, settles it. The words have the defined meanings only when they are in all capitals, and when they are not capitalized they have their normal English meanings.
A useful habit follows. Write "the parser MUST reject a file with no header" when you mean a hard requirement, and "you must restart the app" when you are just talking.
One point people miss: using the keywords isn't required. Normative text does not need them, and a lot of normative text does not use them and is still normative. They're there for clarity and consistency when that's what you want.
The boilerplate sentence to paste
RFC 8174 gives the current sentence to put near the top of a document. It adds NOT RECOMMENDED to the older list and points at both RFCs:
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.BCP 14 is the Best Current Practice number that both RFCs share. If your spec isn't an RFC, you can still keep the sentence and link the two RFCs so readers can check the definitions.
Use them sparingly
RFC 2119 itself warns that these imperatives must be used with care and sparingly. They belong where a rule is actually required for interoperation, or to limit behavior that could cause harm. They aren't for pushing a preferred method on implementers where it does not affect interoperability.
Three habits keep a spec honest:
- Reserve MUST for rules you would reject an implementation over. If you'd shrug, it's a SHOULD or plain prose.
- Explain what happens when someone ignores a SHOULD. The RFC asks authors to spell out the security implications of not following a MUST or SHOULD, because most readers have not seen the discussion that produced the rule.
- Do not mix registers. If a lowercase "must" appears next to an uppercase one, readers will wonder whether you meant a difference.
Using the keywords in a Markdown spec
In a Markdown file, plain capitals are enough. You don't need bold or code formatting, and the capitals survive any renderer and any diff. One rule per bullet makes each requirement easy to point to:
## Requirements
- A note file MUST be valid UTF-8.
- A note file SHOULD end with a single newline.
- A note file MAY include a front matter block.
- Tools MUST NOT rewrite the body of a note on open.Put the boilerplate sentence under the title, keep the keywords out of examples and rationale paragraphs unless you mean them, and link the RFCs the first time they appear. If you are writing about file types, what RFC 7763 actually registers for text/markdown and the security.txt file are good examples of short specs with clear requirements.
How Carets fits in
A spec is a plain text file, and the capitals only help if they stay exactly as you typed them. Carets is a native notes and code editor for iPhone, iPad, and Mac that keeps Markdown, plain text, and code in one place. Your spec stays a portable plain text file, and you can organize related drafts into files, projects, and tags instead of scattering them across folders. Code fences like the ones above get syntax highlighting, so a requirements list and its test snippets sit side by side. Get Carets on the App Store for iPhone, iPad, and Mac.
Frequently Asked Questions
Do I have to use RFC 2119 keywords in my spec?
No. RFC 8174 says normative text does not require the keywords. They are for clarity and consistency when that is what you want, and plenty of normative text omits them.
Does a lowercase must carry the RFC 2119 meaning?
No. Under RFC 8174 the words have the defined meanings only in all capitals. Lowercase words keep their ordinary English meaning.
What is the difference between SHOULD and MAY?
SHOULD means there may be valid reasons to skip an item, but you must understand and weigh the implications first. MAY means the item is truly optional.
What is BCP 14?
BCP 14 is the Best Current Practice designation shared by RFC 2119 and RFC 8174, which together define the key words.