Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

check-file-refs

A bare mention of a path in prose, “run scripts/build.py first”, that resolves to no tracked file. The mention is not written as a Markdown link; it is a path-shaped run of text with a recognised extension, and the sentence around it asserts that the file exists. When it does not, that is a gate finding, and the commit is refused until the mention names a file the repository has.

What it checks

A candidate is a run of text shaped like a relative path: at least one directory segment, a slash, and a final segment with an extension, where the extension is in the recognised set. The default set covers the common source, script, data and documentation extensions; the configuration below lists it, and a project adds to it rather than replacing it. Text that is path-shaped but ends in something outside the set, such as the .0 of api/v2.0, is not a candidate and is never reported. Neither is a bare filename with no slash, so “see README” is not checked.

Four kinds of path-shaped text are set aside before resolution:

  • the destination of a real Markdown link, which is check-links’ to validate, so one broken reference does not produce two findings under two names;
  • a URL, which is not a path however path-shaped its tail;
  • a mention starting with / or ~/, which names a place on the host rather than in the repository;
  • a mention starting with ../, which the check does not resolve either way.

A mention inside a fenced code block is not read, and nor is a fence’s own opening line, so an example path in a code sample is never a candidate. A fence that is opened and never closed silences the rest of its file here; that fence is reported by executable-claims over the same sweep.

A candidate is resolved twice before it is reported: first against the repository root, then, if that fails, against the directory of the file that cites it. A page citing a sibling as references/setup.md resolves either way. This trades some precision for recall: a genuinely broken root-relative mention passes if a same-named file happens to sit beside the citing page.

A mention that names a real file the project deliberately never tracks, such as a git-ignored per-machine settings file, is indistinguishable from a typo by tracking alone. The known_untracked key names such paths by glob; a candidate matching one is exempt from having to be tracked but must still exist on disk inside the repository, so a typo under an exempted pattern is still caught, and a symlink out of the repository is refused rather than followed. It applies to both forms: a pattern is matched against the root-relative path and against the path taken from the citing file’s directory, and either one passing is enough.

The check is whole-tree, over every tracked .md file on every run.

Marking a mention as an example

A path that is not meant to exist, a template such as decisions/NNNN-slug.md or a hypothetical plugins/extra.toml , is exempted by writing the HTML comment example immediately after it. Only backticks and plain spaces or tabs may sit between the mention and the marker; the marker’s own spelling is matched without regard to case or internal spacing. The marker binds to one mention. It is not a configuration entry, because a list in claims.toml has no structural link to the prose it exempts and goes stale the day that prose changes.

A marker that does not immediately follow a live candidate has no effect, and the check says so with an advisory finding at that line. That is the one place this gate check reports advisory: an inert marker is not a false claim, but it is a mechanism that has silently stopped working, which is worth a line.

Why it exists

A link is checked by check-links. A path in backticks with no link syntax around it makes the same claim, that this file is here, and is at least as common, in a README’s directory tour, a changelog’s “moved to”, an agent instruction file’s “read x/y.md first”. Nothing read it. A citation-ranking check drops a path it cannot resolve as noise, which is right for ranking and wrong for a claim. Without this check, the bare mention is the one shape of file reference that can be false forever without a finding.

Example

The example is a Markdown file and one script. The file names the script that exists and one that does not, and also carries the shapes the check sets aside: a Markdown link, a URL, a host path, a version-number lookalike, a marked hypothetical path, and a marker following nothing.

examples/check-file-refs/README.md:

# Widget

Build it with `scripts/build.py`, then deploy it with `scripts/deploy.py`.
The [release notes](docs/RELEASES.md) list what each version changed, and
the installer is at https://example.com/widget/install.sh.

Defaults are read from /etc/widget/config.toml. The endpoints are listed under
api/v2.0 of the reference. A plugin adds its own settings in a file such
as `plugins/extra.toml` <!-- example --> beside the main one.

Per-machine overrides live in the home directory. <!-- example -->

examples/check-file-refs/scripts/build.py:

print("building")

Run against a fresh repository holding those two files, the check reports:

# python3 scripts/capture.py: check-file-refs, run against a throwaway git repository seeded from examples/check-file-refs
[GATE] README.md:3 (check-file-refs) `scripts/deploy.py` does not resolve to a tracked file
[advisory] README.md:11 (check-file-refs) `<!-- example -->` doesn't immediately follow a path-shaped mention — has no effect

The gate finding is the deploy script, named on the first line of prose and present nowhere in the tree. The build script, named on the same line, resolves and produces nothing. The release notes are a Markdown link, which this check leaves to check-links; the installer is a URL; the defaults file starts with /; and the endpoint reference ends in .0, so none of those four is a candidate. The plugin settings file is a candidate, and would be a finding, but carries an example marker and is exempted. The advisory finding is the last line’s marker, which follows a sentence rather than a path and so exempts nothing.

The fix for the gate finding is either to add the file the sentence promises, retarget the sentence to a file that exists, or mark the mention as an example if it was never meant to exist.

Configuration

[check-file-refs]
exclude = ["docs/legacy/*.md"]
extensions = [".proto"]
known_untracked = [".claude/settings.local.json", "*.local.toml"]
historical = ["CHANGELOG.md", "decisions/*.md"]
KeyShapeDefaultReach for this when
excludelist of glob strings; a bare string is a one-element list[], nothing excludedA file’s bare path mentions should not be validated at all: prior-art notes discussing another project’s tree, decision records quoting a layout that no longer exists, or a directory of inputs written to be broken, like this site’s own examples. An excluded file is skipped whole.
extensionslist of extension strings, each with its leading dot; a bare string is a one-element listthe built-in set: .py, .rs, .go, .js, .ts, .rb, .java, .c, .h, .cpp, .swift, .sh, .md, .txt, .yml, .yaml, .json, .tomlThe project’s prose names a file type outside that set, such as .proto, and a bare mention of one should be held to the same standard. Entries are added to the built-in set, never substituted for it.
known_untrackedlist of glob strings; a bare string is a one-element list[], every candidate must be trackedA correctly cited file is real but deliberately never added to git, such as a git-ignored per-machine settings file, and should not gate identically to a typo. A match must still exist on disk inside the repository.
historicallist of glob strings; a bare string is a one-element list[], every mention resolves against the working treeA file is an append-only record, such as a changelog or a set of decision records, whose shipped entries your own rules forbid editing, and you still want to rename or move the files it names.

A historical file’s mentions get one more chance. A mention that fails against the working tree is looked up again in the tree at the commit that wrote its line, as git blame attributes it, and in the tree just before that commit, and passes if a file was in either, taken from either the repository root or the citing file’s directory, as in the working tree. A shipped entry that named a file before it moved stays as written, and the move does not have to leave the old path behind. A line recording a removal can land in the same commit as the removal, since the file was there just before it. A mention found nowhere is still a finding, and its message names where it looked: not in the working tree, nor at the commit where the line was written or just before it, given by its short hash. known_untracked plays no part in that second lookup, since a file never added to git is in no commit’s tree.

The same rule, read consistently, settles three edge cases:

  • An uncommitted line is checked against the working tree, and failing that against HEAD, the tree just before it. A changelog’s unreleased section is being written now, and is gated on every mention found in neither; a finding there names HEAD.
  • A line a later commit touched belongs to that commit, and the mention has to have resolved there. Retargeting an old path, if your rules allow it, is checked against the tree it was retargeted in.
  • A line older than the commit that first added claims.toml is skipped when it fails. Nothing gated it when it was written, so it may have been wrong then, and the append-only rule leaves no way to fix it now. With no tracked claims.toml there is no such commit, and every line is checked.

History is read only for a mention that has already failed against the working tree, so records whose mentions all still resolve cost nothing extra. check-links takes the same key for links, and ADR 0002 has the reasoning, including which other checks it does and does not reach.

enabled, which takes this check out of the commit gate while leaving it in the on-demand skill and the CLI, is shared by every check and covered on Configuring claims.

Retirement markers

None. A path mention is checked wherever it appears, including inside a blockquote, an italicised sentence, or a paragraph opening “Previously said:”. The retired-quote exemption exists for a sentence quoted in order to retire it, and a path is a pointer rather than a sentence: a changelog entry saying a file moved is making a claim about where it is now, and if the sentence is genuinely about a file that is gone, the example marker says so for that one mention. A record whose old mentions must stay intact is what historical is for.

Next

That is the last of the gate checks. The advisory checks follow, and check-config-defaults opens them: a stated default value, held to the line of code that sets it.