read-the-grammar-through-the-document-model
Skill1 starsChanged 4 days agoMITView on GitHub
Read checkboxes, headers, sections and comments of a .doctrina artifact through lib/doc-model.js instead of a new regex, so every surface counts the same thing. Use when: The task adds code under packages/doctrina-cli/src/ that parses a checkbox, a list or bare-bold header, a `## ` section, or an HTML comment out of an artifact (proposal, tasks, spec, delivery, ADR).
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/00-doctrina.mdcCursor rule
- add-cli-commandSkill
- check-the-line-ending-before-patchingSkill
- cut-a-releaseSkill
- keep-docs-en-pt-paritySkill
- ledger-abandoned-entries-are-ledger-onlySkill
- read-the-grammar-through-the-document-modelSkill
- split-an-oversized-specSkill
- stage-a-change-backlogSkill
- triage-holds-work-on-the-machinerySkill
- write-acceptance-evidenceSkill
- add-cli-commandSkill
- check-the-line-ending-before-patchingSkill
- cut-a-releaseSkill
- keep-docs-en-pt-paritySkill
- ledger-abandoned-entries-are-ledger-onlySkill
- split-an-oversized-specSkill
- stage-a-change-backlogSkill
- triage-holds-work-on-the-machinerySkill
- write-acceptance-evidenceSkill
- doctrina-contextSkill
- doctrina-nextSkill
- doctrina-onboardSkill
- doctrina-statusSkill
- doctrina-whySkill
- doctrina-workSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Look in packages/doctrina-cli/src/lib/doc-model.js first.
- Very specific: line 30
When two surfaces report on the same boxes, make them call the SAME function.
- Very specific: line 36
If the model genuinely lacks the shape you need, add it to doc-model.js with its test — never a private copy in the caller.
- Very specific: line 38
Run node --test test/one-box-count.test.js before the full suite: it greps src/ for a box-state capture outside the model.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- doctrina:skill-export — generated from .doctrina/skills/read-the-grammar-through-the-document-model.md by `doctrina index rebuild`; edit that file, not this one. -->Skill — read-the-grammar-through-the-document-model
When to use this skill
- A new command or a new lib function reads boxes (
- [ ]), a header (- **Status:**,**Version:**), a section (## Release) or skips an HTML comment in a.doctrina/artifact, or in a workspace delivery file. - A test failure names
one-box-count.test.js("the box grammar has one owner") or another ADR 0021 contract test.
Procedure
- Look in
packages/doctrina-cli/src/lib/doc-model.jsfirst. It owns the on-disk grammar (ADR 0021):parseChecklist(text, { section })andchecklistProgressfor boxes (every bullet marker,-,*,+, and placeholders),readHeader/getHeader/setHeaderfor both header styles,getSection/listSectionsfor sections,maskComments/commentRangesto skip a comment by position. - Compose them instead of re-deriving them. The Release boxes of a
delivery are
parseChecklist(maskComments(text), { section: "Release" })— one line — and that is the reader bothdelivery tickanddelivery checkuse (change 0228). - When two surfaces report on the same boxes, make them call the SAME
function. Two readers drift: in 0.20.0
delivery checkcounted- [ ]with its own regex whiletickused the model, so a+ [ ]claim was tickable and invisible to the check. - A write keeps the file's line ending: edit in LF if you must, then
withEol(text, eolOf(original))fromlib/fs-ops.js. - If the model genuinely lacks the shape you need, add it to
doc-model.jswith its test — never a private copy in the caller. - Run
node --test test/one-box-count.test.jsbefore the full suite: it grepssrc/for a box-state capture outside the model.
Anti-patterns
const m = line.match(/^\s*[-*]\s*\[([ xX])\]\s*(.*)$/)in a command module. It looks harmless and is the sixth copy of a grammar that had six owners and three different answers for the same file (ADR 0021).- Splitting on
\nafter reading an artifact: a Windows checkout is CRLF, and the last field of every line carries a\r. - Skipping comments by deleting them before parsing: offsets move, and
an op value that legitimately contains
<!-- -->is corrupted.
Related material
- ADR 0021 — one document model owns the
.doctrinaon-disk grammar. packages/doctrina-cli/src/lib/doc-model.js— the owner.packages/doctrina-cli/test/one-box-count.test.js— the guard.- The
check-the-line-ending-before-patchingskill — the same discipline for edits made by hand or by script.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

