Skip to content
SprecherEast
Issue 714

tooling: Generate the content-type reference from the Payload config, and fail CI when it is out of date

Back to our plan
Done
enhancementcicmstoolingpriority: high

Type

enhancement

Summary

A script reads the site's Payload setup and writes one reference page per content type: its fields, who may do what, its hooks, and whether it has drafts. Nobody edits those pages by hand. A check regenerates them on every pull request and fails if the committed pages differ, so a changed content type can never have an old description.

Problem

docs/architecture/data-model.md lists each collection's fields, relations, hooks and field-level access by hand (250 lines). Every change to a collection has to be repeated there, and it isn't always (#517). An agent that wants to know what an event holds either trusts a page that may be stale or reads the config and its hooks again. The owner's direction (2026-11-06, recorded on the epic): when a content type's behavior or properties change, its documentation changes in the same pull request, or the pull request is blocked.

Proposed fix

Follow the decision record from the design sub-issue. The outline:

  1. A generator in scripts/ that loads the real Payload config without a database (reuse loadConfig from src/platform/payload/testing/accessHarness.ts; don't write a second loader) and writes, for every collection and global, including the ones plugins add:
    • docs/reference/content-types/<slug>.md: what it is for (from admin.description when set); a table of fields (name, type, required, relation target, options, and notes such as hidden or server-only); access per operation by function name; hooks by phase with the function's name and file; drafts and versions; auth and upload settings; fields a plugin adds.
    • docs/reference/content-types/README.md: the list of pages, one line each.
    • Each page starts with a line saying it is generated, from what, and how to regenerate it.
  2. Two commands: npm run docs:generate writes the pages; npm run docs:check regenerates them and fails if anything differs from what is committed.
  3. A CI job named Knowledge sync that runs docs:check on every pull request. It is not a required check yet; the sync-gate sub-issue makes it one.
  4. Tests first for the functions that turn a field, an access map and a hook list into Markdown.
  5. docs/architecture/data-model.md keeps what a script can't know (why the model is shaped this way, the relations diagram, what a hook is for) and links to the generated pages in place of its field lists, as the decision record says.

Output is formatted so the Prettier check passes. A page that would go over 250 lines is split by the content type's tabs or groups.

Acceptance criteria

  • Not done: npm run docs:generate run twice in a row leaves no diff.
  • Not done: Every collection and global in the loaded config has a page: the twelve collections and two globals in src/payload.config.ts, and the ones plugins add (forms, form submissions, redirects, search, MCP API keys, media folders).
  • Not done: Each page shows fields, access per operation, hooks and the draft setting.
  • Not done: Adding a field to a collection without regenerating makes npm run docs:check fail with a message that says to run npm run docs:generate. A test or the PR's "How to test" shows this.
  • Not done: The generator starts no database and no server, and the CI job reports its run time in the PR.
  • Not done: docs/architecture/data-model.md no longer repeats field lists.
  • Not done: What each step of the native-first ladder found is recorded on this issue before custom code is written.

Files likely touched

scripts/ (generator and its tests), package.json (two scripts), docs/reference/content-types/ (new, generated), .github/workflows/ci.yml (one job), docs/architecture/data-model.md, knip.jsonc and .jscpd.json if the new files need an entry.

Must not touch

Behavior under src/ (the generator only reads the config), src/payload-types.ts, src/migrations/, the main ruleset (the sync-gate sub-issue changes required checks).

Open questions

None for the owner.

Area

cms, tooling, ci

Priority

high


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab