Add doc schemas

From brabos-ai/code-addiction · View interactive version

Add doc schemas is an AI agent skill from the GitHub repository brabos-ai/code-addiction. Source of truth for ADD doc rules, depth floors, IDs, refs, validation gate. Load before any doc write.

How to use this skill

Skill file

Documentation Schemas & Standards

<!-- uses:

-->

Overview

Single source of truth for every documentation asset generated by ADD commands. This SKILL.md carries the universal content — output-length doctrine, voice principles, language rules, formatting rules, cache discipline, ID convention, validation gate. Schemas live in references/<category>.md, organized by doc purpose rather than by producing command. Commands load this skill once and resolve their schema via the Schema Index by Category below.

When to Use

When NOT to Use

Output Length Doctrine

Agent-generated documentation has no character or word limit. Length is governed by depth floors and density; numeric advisories (<200 words, etc.) are prohibited in any rule constraining agent output.

  1. Completeness beats brevity. A section is done when someone can act on it without follow-up questions. A missing fact is a worse failure than a long section.
  2. Density beats length. Every sentence earns its place. No filler, no restating the heading, no narrative that could be a bullet.

Platform-imposed limits stay (Anthropic SDK name ≤64, description ≤1024, slug/branch identifier shapes) — external constraints, not framework opinions on density.

Universal Rules

Schema-agnostic rules that apply to every generated doc, even when the schema is silent.

Voice

It binds the writing, not the language of the writing: it holds in whatever language the ### Language table below selects. An invented figure is precisely the class of writing that has no counterpart to translate into, so a rule stated once in English governs output in every language.

Established technical terms of figurative origin are kept. branch, tree, cache, pipeline, parent, orphan, handler and race are the literal names of their concepts and have no plainer substitute. The rule targets a figure the writer invents to stand in for a mechanism, not the vocabulary the field already settled on.

Test each sentence before writing it: does it name the action, or name something the action resembles? Replace a resemblance with the action — "confirm the tests bite" becomes "run the tests and check they fail against the broken code". That pair illustrates the device. It is not a list of banned words, and MUST NOT be turned into one: a word list holds in one language only, which is the failure this rule exists to prevent.

1. Short sentences, one idea each. A sentence carrying a second idea is two sentences. A stack of subordinate clauses is the failure this catches — it is grammatical, factual, free of figures, and still costs the reader a second pass.

2. The common word over the rare one, wherever both are exact. "Ask" over "interrogate", "check" over "ascertain", "goes away" over "is elided". Where the rare word is the precise one and the common word is not, the rare word wins — precision is never traded for plainness.

3. A technical term is explained in one line the first time it appears in a document. Then it is used freely. The term itself stays; this adds a line, it never substitutes a vaguer word for an exact one.

This catches what the rules above let through. A passage can carry no filler, no figure, no marketing and no aspiration, and still be hard to read — because none of those rules says anything about register. That gap is what this closes.

⛔ It is not a list of banned words either, and MUST NOT become one. The reason is the one stated directly above: a word list holds in one language only, and this rule binds output in whatever language the ### Language table selects. Test the sentence, not its vocabulary — can it be read once and understood?

Register is not length. A long passage of short, plain sentences passes. A single sentence with four clauses fails. Do not turn this into a budget: the rule against numeric length caps in this skill still holds, and it holds here for the same reason.

Language

| Context | Language |

|---|---|

| Prose, explanations, rationale | Match the language the user writes in; default to English. |

| Code, git, CLI flags, technical terms | English |

| Frontmatter keys and schema type names | English (machine-parsed) |

Technical terms (commit, branch, frontmatter, chunk, schema, hook) stay in English whatever language the rest of the document is written in. Do not translate them.

Markdown Formatting

Cache Documental (MANDATORY)

Every write to an existing doc MUST follow: read → preserve → complement → bump updated:. Never overwrite blind.

| Situation | Action |

|---|---|

| Doc does not exist | Create from schema + set created: + updated: |

| Doc exists, template-empty | Fill sections + bump updated: |

| Doc exists, populated | Read → complement → bump updated: |

| Conflicting info | New info wins; log change in-section |

Anti-patterns: recreating a doc from scratch; silently overwriting populated sections; forgetting to bump updated:; duplicating content already owned by another doc (link instead).

Docs Branch

Every output a command writes lives under .codeadd/docs/. That directory is a git worktree of codeadd-docs, an orphan branch in the project's own remote — it is not part of the code branch, so docs never ride in a code PR. status.cjs prepares it and prints one DOCS= line: ready, created, linked or missing. On missing, run node .codeadd/scripts/docs-branch.cjs prepare once; if it is still missing, report its DOCS_REASON= line and stop writing docs. Never write an output anywhere else.

Search it by passing the root. rg, Grep and Glob skip git-ignored paths, and .codeadd/docs/ is ignored by the code branch. A search that does not name the root finds nothing and looks like absence:

rg -n "^id: F0042$" .codeadd/docs/

The end-of-command rule. A command that wrote or changed anything under .codeadd/docs/ runs this as the last step before its final report:

node .codeadd/scripts/docs-branch.cjs commit "<what changed, one line>"

It prints DOCS_COMMIT=committed, clean or failed. Name a failed result in the report; do not retry in a loop. Commits stay local until /add-done pushes codeadd-docs (agent-mode pushes it at the handoff), and a command never runs git in the docs directory itself.

ID Convention & References

Docs reference each other via stable IDs (F0042, H0013, PRD0009, CHG0001) rather than paths or titles. References use {{doc:<ID>}} syntax and are resolved at runtime by agents via grep on frontmatter id: — NOT at build time.

Contrast with build-time variables: {{cmd:}} / {{skill:}} are resolved by build.js during provider build. {{doc:ID}} passes through build untouched. build.js MUST NOT be extended to resolve {{doc:}}.

ID Prefixes

Every ADD doc type that participates in the reference graph has a prefix. IDs are global within their prefix and zero-padded to 4 digits.

| Letter | Type | Format | Example | Allocator |

|---|---|---|---|---|

| F | Feature | [NNNN]F | 0042F | /add-new |

| H | Hotfix | [NNNN]H | 0013H | /add-hotfix |

| PRD | PRD (framework strategy) | PRD[NNNN] | PRD0009 | /add-plan (framework mode) |

| CHG | Changelog entry | CHG[NNNN] | CHG0001 | /add-done |

Convention: Feature/hotfix IDs use [NNNN][L] (number first, letter suffix) per {{skill:add--id-convention/SKILL.md}}. PRD and CHG are separate namespaces with no letter suffix.

Other doc types (AUDIT-<date>, DIAG-<slug>, COPY-<slug>, LAND-<slug>, BRN-<slug>, RCPT-<command>) use fixed or slug-based IDs — see individual schemas in the category files. QA validation reports use a per-scope sequence ID (<feature-id>-qa-validation-NNN, not a global prefix) — see qa-validation in references/review.md and {{skill:add--id-convention/SKILL.md}}.

ID Allocation

**{{skill:add--id-convention/SKILL.md}} is the owner of the [NNNN][L] shape, the counter, and the

allocation command.** Load it before allocating, allocate through status.cjs next-id <LETTER>, and never hand-roll an id — one

manual grep here and the manual copy could hand out a number second, under an old allocator that stays

open instead of the shipped one. Never reuse an ID even if the doc is deleted.

Reference Syntax

Body text uses {{doc:<ID>}} so agents distinguish refs from incidental text. Frontmatter related: is a YAML list of bare IDs (no wrapping).

Inline (body):

See {{doc:F0042}} for the feature scope.
The regression was introduced by {{doc:H0013}}.

Frontmatter:

related: [F0042, PRD0009, H0013]

Resolution. When an agent encounters {{doc:F0042}}: (1) rg "^id: F0042$" .codeadd/docs/ (the root is passed explicitly — see Docs Branch), (2) resolve to file path, (3) read target (frontmatter + TL;DR first, sections on demand).

Orphans. A {{doc:<ID>}} whose target does not resolve is a warning, not error — the gate surfaces it; user decides. Deleting a doc does NOT fix inbound refs — prefer status: deprecated over deletion.

Edit Discipline

Relations & Observations

Two body sections carry a work item's place in the graph. The document body is the source of truth for a relationship — not an index, not a frontmatter array. The body is what every wikilink parser already reads, it exists from the document's first minute, and it survives any change to the index format.

Both sections are plain markdown. No library parses them and none is needed.

Relation Lines

One line per relationship, in a ## Relations H2:

## Relations
- caused_by [[0051F]]
- part_of [[0042F]] — the refresh flow this hotfix broke

The grammar is fixed: - <type> [[<id>]], optionally followed by — <why>.

| Part | Rule |

|---|---|

| <type> | One value from the closed vocabulary below. An unrecognised type is a FAIL |

| [[<id>]] | The target's own id: value, exactly as that document carries it. Double square brackets, no path, no title |

| — <why> | Optional one-line reason. It is the rejection surface for the edge: an agent discards a candidate from the why without opening the target |

⛔ A relation points at a work item, never at a file. One work item is one node, anchored on its *-about document; plan.md, changelog.md and the rest are its attachments. Pointing an edge at an attachment gives it no single target.

Relation Types

The vocabulary is closed. Four values, and no fifth is added without a schema change.

| Type | Means | Written by |

|---|---|---|

| caused_by | This work item exists because that one broke something | /add-hotfix, from the candidate set the user confirmed |

| depends_on | This work item cannot ship until that one has | /add-new, from its own discovery result |

| part_of | This work item is one piece of that larger one | /add-new for an epic member. For a changelog, whichever of /add-pull-request and /add-done writes it first — the changelog schema has two writers and either may be the first |

| links_to | The two reference each other and the intent is unrecorded | the codeadd update migration only, never authored by hand |

links_to is the honest label for an edge recovered mechanically. A migration reading a {{doc:}} reference in a sentence knows the two documents are connected and does not know why, and writing a guessed depends_on there would be worse than admitting the gap.

⛔ Nobody is asked which work item a change depends on. The command runs the query itself and writes what it found. A relationship born from human memory is a relationship nobody can reproduce.

Observation Lines

One line per fact worth finding later, in an ## Observations H2:

## Observations
- [cause] refresh shipped with no expiry test #auth
- [impact] every session past 1h dropped #auth

The grammar is - [<category>] <text> with optional #tag words at the end. The category is free text and names what kind of fact the line is — cause, impact, constraint, measurement. Tags match the tags: frontmatter key.

Observations are extractive like every other section. A line that restates the TL;DR is filler; a line carrying a measurement, a constraint or an observed effect is what the section exists for.

What `related:` Does Now

related: is unchanged and stays exactly as the Reference Syntax section above defines it. It is not deprecated and it is not rewritten.

It has one added role: it is migration input. The codeadd update migration reads the existing related: ids of a brownfield project and harvests them into ## Relations as links_to edges. A document keeps both — the frontmatter list it always had, and the typed section derived from it.

The TL;DR Is the Node's Rejection Surface

## TL;DR is already required by Universal Document Requirements below, and nothing about its content changes. What changes is that something now reads it: a graph search returns a snippet (about 200 characters) of the field that matched, with a score, so an agent discards an irrelevant work item without opening the document. The summary and the full section come on a follow-up get.

That is why an empty ## TL;DR heading satisfies nothing. /add-done refuses to close a delivery whose document carries an empty one, and the graph's orphans action reports every node still missing one.

Universal Document Requirements

Every schema inherits these rules. Do NOT override unless the schema explicitly relaxes them.

Frontmatter — mandatory fields (YAML):

---
id: <PREFIX><NNNN>        # per ID Convention section above
type: <schema-type>       # one of the schemas in references/<category>.md
created: YYYY-MM-DD
updated: YYYY-MM-DD
schema: {{doc-schema}}    # the doc format version — see Schema Version below
related: []               # list of doc IDs this doc depends on or references
tags: []                  # list of bare topic words; the grouping a graph search filters on
---

Optional: by: (last editor — human or agent identifier), status:, slug:.

tags: is a list of bare lowercase words — [auth, token], never a sentence and never a path. It is the one frontmatter key this format adds, and it groups work items the way area: already groups a wiki reference page. An empty list is valid; the key is written either way.

Body requirements:

Schema Version

schema: is the doc format version — an integer in the YAML frontmatter that says which version of this skill's document standard the file was written to. Always write it as the build variable {{doc-schema}}, never as a number: the build resolves it, and a build lint warns on any literal schema: <digit> in markdown source, fenced examples included.

Schema Index by Category

Schemas are grouped by doc purpose, not by producing command. Each category file owns its schemas plus the section-shape conventions and notation rules shared by them. Commands resolve their schema by name — the category file holding it is below.

| Category | File | Schemas |

|----------|------|---------|

| new-feature | references/new-feature.md | feature, feature-plan, feature-design, brainstorm, brainstorm-intent, epic |

| fix | references/fix.md | hotfix |

| review | references/review.md | audit-report, diagnose-report, review, qa-validation |

| history | references/history.md | changelog |

| strategy | references/strategy.md | prd |

| ~~marketing~~ | retired | saas-copy and landing-page were dropped with their category file; nothing writes either, and a command asking for one gets no schema |

| receipt | references/receipt.md | setup-receipt (legacy — current receipts are sections of .codeadd/settings.json; schema in add--settings) |

Loading discipline. A command that produces, say, a feature loads this SKILL.md (universal rules + ID + gate) plus references/new-feature.md (its category). It does NOT load every category file — JIT by category.

Schema name → category lookup. Use the table above. Adding a new schema = (1) place it in the right category file, (2) update this table, (3) if a new ID prefix is needed, add it to the ID Prefixes table.

Format References (NOT Doc Schemas)

references/ also holds files that describe a machine-readable format, not a Markdown document an agent authors. They carry no frontmatter template, no id: under the ID convention, no TL;DR, no depth floors and no Decision Log, and they are deliberately absent from the Schema Index above — listing one there would declare a machine log to be a doc, and the validation gate would then run against something that has no schema type.

| File | Describes | Read it when |

|------|-----------|--------------|

| references/delivery-index.md | .codeadd/docs/delivered.jsonl — the per-project delivery index: one JSONL line per delivered feature, its {what, at, find} item anchor, the four statuses, the corpus rule, the nine hard bans and the REFUSED= vocabulary | authoring or reading a delivery-index entry, or changing .codeadd/scripts/delivered.cjs |

Validation Gate Block

Every generator command MUST paste the following block as the final STEP that operates on the doc — i.e. after every step that writes, edits, or transforms the doc, and before any post-doc step (completion summary, fresh-reader review via add--plan-review then the comprehension readback via add--feature-readback, next-step routing, merge execution, iteration logging). Steps that do not modify the gated doc may follow the gate. The block is self-contained and imperative. Replace <SCHEMA> with the schema type in use.

Known gap — generators with no fresh-reader review. Only add-new and add-plan run the fresh-reader review, and only add-plan runs the readback. Every other generator that writes a schema-gated doc (add-hotfix, add-wiki, add-audit, add-diagnose) passes the validation gate and stops there. An earlier version of this line routed those "other generators" to a question-only reviewer, but no command ever implemented that step and the agent it named was deleted in plan 0076. The route is not restored here: pointing at a reviewer nobody dispatches is what produced the confusion in the first place. Giving those commands a real review step is open work, not a documented behaviour.

## STEP N: Validation Gate (add--doc-schemas)

Run these checks against the doc you just wrote. DO NOT skip. DO NOT mark the command complete until every check passes or warns.

⛔ **A schema that explicitly narrows a Universal Document Requirement is exempt from the check that enforces it.** Universal Document Requirements says the rules bind "unless the schema explicitly relaxes them", and this is where that sentence takes effect: a frontmatter field the schema's own **Frontmatter** line does not name, and a `## TL;DR` or TOC the schema's **Sections** list does not name, are not missing — they were declared out. Checks 1, 2, 3 and 9 all read this rule. A schema that is merely silent narrows nothing; the narrowing has to be written down in the schema.

1. **Frontmatter presence.** Grep `^---$` at line 1. Confirm YAML block closes. Required fields for `<SCHEMA>`:
   - `id:` matches the prefix rule in the ID Convention section of this skill
   - `type: <SCHEMA>` exact match
   - `created:` and `updated:` are ISO dates (YYYY-MM-DD)
   - `related:` is a YAML list (may be empty `[]`)
   - `tags:` is a YAML list (may be empty `[]`)
   - `schema:` is present on a document being written now (FAIL when absent on a document this command creates or brings up to the current standard; a legacy document that is only read or lightly edited stays schema `0` — see Schema Version)
   - **`feature` only** — `branch:` present, matches `^[a-z]+/[0-9]{4}[A-Z]-[a-z0-9-]+$`, and its post-`/` slug equals the docs dir name (Hard Invariant). Legacy docs predating this field: **warn**, do not FAIL.
   If any field is missing: STOP. Fix the doc. Re-run this gate.

2. **TL;DR present and complete.** Grep `^## TL;DR$`. The body MUST convey: what the doc is, why it exists, and the headline outcome/decision. If any is missing: rewrite extractively — do NOT summarize abstractively, do NOT shrink by dropping the headline.

3. **TOC rule.** Count H2 sections (`^## `). If >3 and no `## TOC` / anchor list right after TL;DR: add it. Flat bullets only.

4. **Depth floors met.** For each H2/H3 in the schema, walk the schema's depth-floor list and confirm every required fact is present in the chunk. A section that looks clean but omits required facts is INCOMPLETE. If a floor is unmet: add the missing content. If a fact is genuinely unknowable, write `unknown — <why>` rather than omit.

5. **Non-redundancy / density.** Apply Universal Rules → Voice: every sentence is fact, decision, constraint, link, or signal — never filler. Delete restatements, paraphrase, repetition. Numeric length caps are prohibited.

6. **Doc refs resolve.** For every `{{doc:<ID>}}` in the doc, run reverse grep: `rg "^id: <ID>$" .codeadd/docs/`. Each ref MUST return ≥1 hit. Unresolved refs = WARNING (not error); print them in the command output for the user to fix.

7. **`## Relations` lines are well-formed, and every target resolves.** For each line under `## Relations`, confirm it matches `- <type> [[<id>]]` with an optional ` — <why>` tail, that `<type>` is one of `caused_by`, `depends_on`, `part_of`, `links_to`, and that `<id>` resolves with the same reverse grep as check 6. Any of the three failing = **FAIL**, not a warning: STOP, fix the line, re-run this gate.

   **This is deliberately stricter than check 6, and the difference is what the two are for.** A `{{doc:}}` reference is prose that names another document, so a stale one costs a reader one dead link. A `## Relations` line is an edge in a graph other commands query, so a stale one returns a hit nobody can open and is indistinguishable from a real one at the point it is read. A relation whose target genuinely no longer exists is deleted, never left dangling.

8. **Hard bans absent.** Confirm none of the schema's "Hard bans" items are present (emojis in headers, ASCII art where forbidden, aspirational language, abstractive paraphrase, forbidden content types).

9. **Metadata footer.** Confirm `updated:` in frontmatter matches today's date. If editing an existing doc, confirm original `created:` was preserved.

DO NOT use abstractive summarization to trim a section — summarization loses information the depth floor requires. DO NOT delete required content to make the gate pass — split into linked docs instead, or mark items `unknown — <why>`. DO NOT silently drop unresolved refs — surface them as warnings. DO NOT introduce numeric length caps (e.g. `<200 words`, `~100-150 words`) anywhere in the doc body.

Output at end:
- `gate: PASS` or `gate: FAIL`
- list of warnings (orphan refs, `unknown` markers)
- list of fixes applied (if any)

Self-Governance

This skill is itself at risk of becoming unmaintainable. Rules:

Cross-references


Migration note (2026-05-09, PRD0019): Length authority extended to all agent-generated docs — advisory caps removed, depth floors and density are the universal rule. Schemas reorganized by purpose category in references/<category>.md. business.md and technical.md deleted; their voice principles moved to this SKILL.md (Universal Rules), schema-specific notation moved to the relevant category file, and JSON/compression discipline already lived in add--token-efficiency.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.