File formats
ontrack works on three files. This page says what it reads in each, what it writes, and what it leaves to you.
| File | Where | Written by |
|---|---|---|
package.json of a track |
The track’s repository | The track’s author |
| An ADR | The track, then docs/adr/ in each repository |
The track, then the repository |
AGENTS.md |
The root of each repository | ontrack, between two markers |
The ontrack key of a track
Section titled “The ontrack key of a track”A track is an npm package whose package.json has an ontrack object.
{ "name": "@trivoallan/ontrack-engineering", "ontrack": { "adr": "adr", "namespace": "trivoallan" }}| Property | Type | Required | Meaning |
|---|---|---|---|
adr |
string | Yes | The directory that holds the ADRs, relative to the package. It must stay inside the package. |
namespace |
string | No | The alias the track proposes to be installed under. A value that is not a string counts as absent. |
- Unknown properties are accepted and ignored.
- A dependency whose
ontrackis absent, or is not an object, is not a track. ontrack skips it. - The namespace in effect is the npm alias the repository installs the track
under, whatever
namespaceproposes. The alias must be unscoped: a track installed as@scope/nameis an error, and so is one installed aslocal, the namespace of the repository’s own ADRs. - Every
.mdfile directly in theadrdirectory is an ADR. Subdirectories are not read.
ontrack publishes a JSON Schema for this key,
schema/ontrack.schema.json,
derived from the model it validates with. It applies to a whole
package.json and constrains its ontrack property only. In VS Code, add it
in .vscode/settings.json:
{ "json.schemas": [ { "fileMatch": ["package.json"], "url": "https://raw.githubusercontent.com/trivoallan/ontrack/main/schema/ontrack.schema.json" } ]}The schema cannot state one rule: adr must resolve inside the package.
The frontmatter of an ADR
Section titled “The frontmatter of an ADR”An ADR is a Markdown file with a frontmatter. ontrack reads seven keys of it. Any other key belongs to the track, which decides the rest of the format and how to check it.
This is an ADR as its track ships it, then the same ADR once a repository has ruled:
---adr: ADR-0006title: Commitsstatus: proposedrevision: 1check: npx --no-install ontrack-engineering-check ADR-0006supersedes: []traits: commits: scopes: tool:------adr: ADR-0006title: Commitsstatus: acceptedrevision: 1check: npx --no-install ontrack-engineering-check ADR-0006supersedes: []traits: commits: scopes: [api, web] tool: commitlint---The keys ontrack reads
Section titled “The keys ontrack reads”| Key | Value | Filled by | What ontrack does with it |
|---|---|---|---|
adr |
A string. Defaults to the file name without .md. |
The track | Identifies the ADR in review <adr> and in supersedes. |
title |
A string. Surrounding quotes are removed. Defaults to the first # heading of the body. |
The track | Shows it in plan and in the headings of the instructions block. |
revision |
An integer, written with digits only. | The track | Compares the repository’s value with the track’s. See below. |
status |
proposed, accepted or rejected. | The repository | Decides how the ADR is treated. See below. |
check |
A shell command, on one line. | The track | Runs it in check, once the ADR is accepted. apply copies the track’s line into the repository’s copy. |
supersedes |
A list of ADRs: [ADR-0003] on the line, or one - item per line below. |
The repository | Treats each ADR named by an accepted ADR as superseded. |
traits |
An indented block. | The track ships the keys, the repository fills the values | Copies the block as it is into the instructions block, once the ADR is accepted. |
What status decides
Section titled “What status decides”status |
Instructions block | review |
check |
|---|---|---|---|
| proposed | Listed under “Not yet decided” | Prepares a ruling | Not run |
| accepted | Its traits are written, unless it is superseded | Drafts an ADR that supersedes it | Run, unless it is superseded |
| rejected | Absent | Refused, with an error | Not run |
With any other value, the ADR is neither decided nor listed as pending.
check, supersedes and traits are read only when the status is
accepted.
How revision is compared
Section titled “How revision is compared”plan compares the revision of the repository’s copy with the track’s.
| Repository’s copy | Track | Category in plan |
|---|---|---|
| Lower than the track’s | An integer | revised |
| Equal or higher | An integer | Up to date |
Absent, 0, or not an integer |
Any | undetermined |
| Any | Absent or not an integer | undetermined |
Nothing else is compared: not the status, not the traits, not the text.
apply --confirm writes the track’s revision into an undetermined
copy. It is the only case where ontrack writes this key.
How the frontmatter is read
Section titled “How the frontmatter is read”ontrack does not use a YAML parser. It reads the frontmatter line by line, which sets a few rules a YAML parser would not.
- The file starts with a
---line, and the frontmatter ends at the next one. - A key is read at column zero, with its value on the same line. Only
supersedesandtraitscontinue on the lines below. - A value can be quoted, except
revision. Foradr,status,checkandsupersedes, a#that follows a space starts a comment and ends the value. This holds inside acheckcommand too. traitsmust be an indented block.traits: {}and an absent key both mean no trait. Any other value on thetraits:line is an error.- Trait values are never interpreted. ontrack copies the block, with its indentation removed.
- An entry of
supersedesis theadrvalue of another ADR in the same namespace, or<namespace>/<adr>for one in another namespace. - Between the two
---lines, ontrack accepts blank lines,#comments,key:lines, list items and indented lines. Anything else makes the frontmatter unreadable:planreports the ADR asunreadable, and the other commands ignore it.
What the track decides
Section titled “What the track decides”ontrack never checks that an ADR is well formed beyond the keys above. Which
other keys exist, which sections the body has, and which values a trait
accepts are the track’s to define and to check.
trivoallan/ontrack-engineering does it
with one schema file shipped next to its ADRs,
adr/.mdschema.yml,
which lists the accepted values of every trait.
The instructions block in AGENTS.md
Section titled “The instructions block in AGENTS.md”ontrack apply keeps the block printed by ontrack instructions current in
the AGENTS.md at the root of the repository, and ontrack plan reports its
state. The text between <!-- ontrack:begin --> and <!-- ontrack:end -->
belongs to ontrack and is overwritten; everything outside the markers is
yours and is never touched.
applyreplaces the block when the file holds one marker pair, appends it after an empty line when the file has no marker, and createsAGENTS.mdwhen there is none. It printsAGENTS.md: instructions block updatedorAGENTS.md: instructions block created. With--dry-runit printsAGENTS.md: instructions block to updateorAGENTS.md: instructions block to createand writes nothing.planprintsAGENTS.md: instructions block missingorAGENTS.md: instructions block out of dateand exits with2, like any other pending change.- The block is needed as soon as one ADR is decided or pending. With none, and no marker in
AGENTS.md, nothing is printed and no file is created. - When the block cannot be written (a marker without its pair, more than one pair, or two decided ADRs sharing a trait key), only this step is skipped: the ADRs are still handled,
AGENTS.mdis left untouched, and both commands printAGENTS.md: skipped, <reason>and exit with2. - Claude Code reads
AGENTS.mdon its own only when the repository has noCLAUDE.mdand noCLAUDE.local.md. When one of them exists andCLAUDE.mdholds no line@AGENTS.md, both commands printAGENTS.md: not read by Claude Code while CLAUDE.md exists; add a line "@AGENTS.md" to CLAUDE.md. ontrack never writesCLAUDE.md; this warning does not change the exit code.
