Epic: Knowledge layer — the site explained for agents and people, kept in sync with the code
Back to our planType
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
| Source | Finding | What 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 tab | Target 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 term | Here |
|---|---|
| Raw sources (never edited by the wiki) | The code, the Payload config and the decision records |
| The wiki | The module notes and the generated reference |
| The schema | A short section in AGENTS.md plus the note template |
index.md, read first | One index, the only part of the layer that is always loaded |
log.md | Git history and pull requests already are this log; no extra file |
| Ingest | Each pull request updates the notes its diff touches |
| Lint | A scheduled check for stale, orphaned or contradicting notes |
The design in short
| Part | What it is | Proposed place | Kept true by |
|---|---|---|---|
| Index | One line per module, screen group and reference page | docs/knowledge/index.md | The scheduled check |
| Generated reference | Content types (fields, access, hooks), routes, shared components and their props. Made by a script, never edited by hand | docs/reference/ | CI regenerates it and fails on a difference |
| Module notes | At 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, decisions | src/modules/<name>/README.md and one per shared area in src/platform/ | The sync check and the review |
| Schema | How a note is structured and what belongs where | AGENTS.md ("Where knowledge lives") and a template | Review |
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
| Order | Issue | What it does | Waits for |
|---|---|---|---|
| 1 | #144 | Slim what loads into every session to at most 300 lines (a sub-issue of #182, linked here) | Nothing |
| 2 | #713 | The design: inventory of what exists, the note template, the index, what is generated, the sync rule | Nothing |
| 3 | #714 | Content-type reference generated from the Payload config, with a CI check | #713 |
| 4 | #715 | Pilot note on the events module, measured with and without | #713, #144 |
| 5 | #716 | The required check that blocks a pull request when documentation is out of sync | #714, #715 |
| 6 | #717 | The code-writing skills, the hooks and the review carry the rule | #716 |
| 7 | #718 | Route and shared-component reference generated from the code | #714 |
| 8 | #719 | Plan the notes for the other modules and shared code (one issue each) | #715, #716 |
| 9 | #720 | Scheduled 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 insrc/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, thewrite-code,self-reviewandpr-reviewskills 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
#714 · Closed Nov 6
#715 · Closed Nov 6
#716 · Closed Nov 6
#717 · Closed Nov 6
#718 · Closed Nov 6
- documentation: After the pilot, plan the notes for the other modules and the shared code (issue 719)Open
#719
#720
#725
#728
#730
#732
#734
#736
#737 · Closed Nov 6
#770 · Closed Nov 6
#771 · Closed Nov 6
#775
#781 · Closed Nov 7
#782 · Closed Nov 7
- documentation: Knowledge note for the contact module (forms, held emails, retention) (issue 783)Done
#783 · Closed Nov 7
- documentation: Knowledge note for the directory module (FAQ, resources, team members) (issue 784)Done
#784 · Closed Nov 7
#785 · Closed Nov 7
- documentation: Knowledge note for the site module, part 1: pages and the page builder (issue 786)Done
#786 · Closed Nov 7
#787 · Closed Nov 7
- documentation: Knowledge note for the verification module (email confirmation by link) (issue 788)Done
#788 · Closed Nov 7
#789 · Closed Nov 7
#790 · Closed Nov 7
#791 · Closed Nov 7
#792 · Closed Nov 7
- process: Raise the session-start token ceiling to fit one index line per knowledge note (issue 799)Done
#799 · Closed Nov 7
- process: Copilot review check: judge by whether a review arrives, not by its message (issue 800)Done
#800 · Closed Nov 7
#801 · Closed Nov 7
- process: Rewrite recent rules and issues as principles; rounding is not a discrepancy (issue 802)Open
#802
#849 · Closed Nov 7
#852 · Closed Nov 7
#853 · Closed Nov 7
#862 · Closed Nov 7
#863 · Closed Nov 7
#366
#481 · Closed Oct 27
#493 · Closed Oct 27
#768