Skip to content
SprecherEast
Issue 712

Epic: Knowledge layer — the site explained for agents and people, kept in sync with the code

Back to our plan
Done
documentationcitoolingpriority: high

Type

documentation

Summary

Every time an agent or a person works on the site, they have to work out again how it is put together: which screens exist, what each content type holds, which shared components a page uses, and where each piece of data comes from. That costs time and tokens, and two sessions can reach two different answers.

This epic builds a knowledge layer: one short index that is always loaded, short notes that sit next to the code, and reference pages a script generates from the code. A required check blocks a pull request when the code's behavior changes and the notes don't. It comes before the agent team (#685) is built.

Summary of the owner's direction (2026-11-04 voice session; 2026-11-06 Claude session, text)

  • The knowledge layer comes first. The agent team (#685) follows, in a leaner form.
  • Reduce what is loaded into every session. Use progressive disclosure: a light first level, deeper levels only when the work needs them.
  • It serves agents and people. It documents screens, content types and common components, and says where data comes from (the CMS, hardcoded, or shared code).
  • Follow Andrej Karpathy's method, open standards and best practice, and list the sources.
  • When code changes behavior (how a content type behaves, its properties, or its events), the documentation is updated in the same pull request. The code-writing skills, the hooks and the review all carry this. The review always checks for behavior changes. A pull request whose documentation is out of sync is blocked.
  • Agreed on 2026-11-06: pilot on one module, measure, then roll out.

What the research says

SourceFindingWhat we do with it
Karpathy, LLM wiki, opens in a new tab (2026-04)Three layers: raw sources that are never edited, a wiki the model keeps up to date, and a schema that says how the wiki is structured. An index is read first. New material is "ingested" into the pages it touches, and a periodic "lint" finds stale pages. Works without search infrastructure at a few hundred pages.Mapping below. It was written for personal knowledge bases, not code, so this is an adaptation.
ETH Zurich, Evaluating AGENTS.md, opens in a new tab (2026)Context files did not improve task success on average and raised cost by over 20%. Repository overviews did not help agents find the right files sooner. Model-written context files gave no gain.Notes hold only what the code can't show. Facts that can be read from code are generated by a script. We measure before rolling out.
Vercel, AGENTS.md outperforms skills, opens in a new tab (2026)A compact index that is always loaded beat skills the agent had to choose to open; the skill was not opened in 56% of runs.A small index is always loaded and points to everything else.
Claude Code: memory, opens in a new tabTarget under 200 lines per instruction file; imports don't reduce the cost; instruction files in subfolders load when a file there is read; instructions are context, not enforcement.Slim the always-loaded set (#144). Notes sit in the module's folder. Enforcement is a CI check, not a sentence.

Measured on main at d268658 (2026-11-06): CLAUDE.md is 87 lines and imports ten files, 1,564 lines (about 17,500 words) in total, into every session and every subagent.

Karpathy's method, mapped to this repo

His termHere
Raw sources (never edited by the wiki)The code, the Payload config and the decision records
The wikiThe module notes and the generated reference
The schemaA short section in AGENTS.md plus the note template
index.md, read firstOne index, the only part of the layer that is always loaded
log.mdGit history and pull requests already are this log; no extra file
IngestEach pull request updates the notes its diff touches
LintA scheduled check for stale, orphaned or contradicting notes

The design in short

PartWhat it isProposed placeKept true by
IndexOne line per module, screen group and reference pagedocs/knowledge/index.mdThe scheduled check
Generated referenceContent types (fields, access, hooks), routes, shared components and their props. Made by a script, never edited by handdocs/reference/CI regenerates it and fails on a difference
Module notesAt most 80 lines each: purpose, screens and where their data comes from, behaviors and events, shared pieces used, rules and the test that protects each, boundaries, decisionssrc/modules/<name>/README.md and one per shared area in src/platform/The sync check and the review
SchemaHow a note is structured and what belongs whereAGENTS.md ("Where knowledge lives") and a templateReview

What already exists stays the starting point: docs/architecture/ (map, conventions, glossary, data model, 18 decision records) and docs/ui/ (the inventory and component set from #170). The design issue decides what the generated reference replaces and what is marked as history.

Sub-issues, in order

OrderIssueWhat it doesWaits for
1#144Slim what loads into every session to at most 300 lines (a sub-issue of #182, linked here)Nothing
2#713The design: inventory of what exists, the note template, the index, what is generated, the sync ruleNothing
3#714Content-type reference generated from the Payload config, with a CI check#713
4#715Pilot note on the events module, measured with and without#713, #144
5#716The required check that blocks a pull request when documentation is out of sync#714, #715
6#717The code-writing skills, the hooks and the review carry the rule#716
7#718Route and shared-component reference generated from the code#714
8#719Plan the notes for the other modules and shared code (one issue each)#715, #716
9#720Scheduled check for stale or broken notes#716

#144 and #713 can start now and don't share files, so they can run in parallel.

Out of scope

  • Building the agent team (#685).
  • A documentation website, and search by embeddings. At this size (about 66,000 lines, 8 modules) an index is enough.
  • A code knowledge graph (#95, closed).

Acceptance criteria

  • Not done: The instructions loaded at the start of every session are at most 300 lines, measured by a script (#144).
  • Not done: A reference page generated from the code exists for every content type, every public route and every shared component, and CI fails when one is out of date.
  • Not done: Every module in src/modules/ and every shared area in src/platform/ has a note that follows the template and is at most 80 lines.
  • Not done: A required check blocks a pull request that changes a module's code without changing its note, unless the pull request declares "no behavior change" with a reason, which the reviewer verifies.
  • Not done: AGENTS.md, the write-code, self-review and pr-review skills and the guard rails state the rule, and the review treats a missing update as a Blocker.
  • Not done: The pilot's numbers are recorded, and the rollout was decided from them.
  • Not done: The scheduled check for stale notes runs.
  • Not done: Every sub-issue lists its sources.

Related

  • Step 1 lives under another epic: #144 (lean agent context), a sub-issue of #182. It keeps its parent; this epic links to it.
  • #685 (agent team) waits for this epic. #444 (tools that check our rules) and #182 (agents stay inside the rules) are neighbors.
  • Earlier documentation work: #128 (architecture map, closed), #170 (UI inventory, closed).
  • Known drift this layer has to absorb or fix: #495, #517, #279, #158, #366, #531.
  • #106 (a separate GitHub account for agents) is what lets a review block a merge by itself.

Area

tooling, ci

Priority

high


Generated by Claude Code, opens in a new tab

Issues in this epic

See it on GitHub, opens in a new tab