Skip to content

SEC-002 Section order

Validates that section headings appear in the order given by order. If any heading in order appears out of order, an error is reported. Headings not listed in order are ignored.

Even with the same template, individual writers can shuffle the order of sections. When readers move across documents, consistent ordering lets them anticipate where information lives. Inconsistent ordering forces them to re-search every document, raising cognitive cost.

FieldTypeRequiredDescription
orderstring[]YesArray of section headings in their expected order
levelnumberHeading level to validate (when set, headings are grouped by parent and validated per group)
sectionstringWhen level is set, restrict validation to a specific parent heading
filesstringGlob of files this rule applies to

When level is set, only headings at that level are extracted, grouped by parent, and validated within each group. Combine with section to restrict validation to a specific parent heading.

# ADR-001
## Decision
Adopt JWT.
## Background
We need to choose an authentication mechanism.

With order: ["Background", "Decision", "Consequences"], Background appearing after Decision triggers a violation.

docs/adr/001.md
line 7 error Section "Background" must appear before "Decision" SEC-002
# ADR-001
## Background
We need to choose an authentication mechanism.
## Decision
Adopt JWT.
{
"rule": "sec002",
"options": {
"order": ["Background", "Decision", "Consequences"],
"level": 2,
"files": "adr/*.md"
}
}