A drop-in documentation system for projects worked on with Claude Code, Cursor, OpenClaw, or any AI agent.
Adapted from Garry Tan's gbrain pattern (skills/RESOLVER.md — thin router,
fat focused files, self-maintaining) and applied to team project docs instead
of personal memory.
What you get (v1.4.0):
Three doc surfaces, all gated, plus an AI auto-maintainer:
- Root router —
AGENTS.mdat repo root. Thin file pointing everywhere. - Cross-cutting docs —
docs/agent/*.mdfor topics spanning multiple apps (architecture, database, deployment, gotchas, _TIMELINE). - Per-app canonical docs —
apps/<app>/AGENTS.mdandpackages/<pkg>/AGENTS.md. Each is scoped to its own app/package code (front-matterdependent_pathsmust stay within that directory, orpackages/). This is what Cursor/Codex/Claude find when agentscdinto a subdirectory.
Every doc carries front-matter:
---
owner: lance
last_verified: 2026-04-18
dependent_paths:
- src/services/payment.ts
- src/db/schema/billing.ts
---Enforced signals (scripts/doc-check.ts):
- Broken
dependent_paths→ error. - Missing front-matter → error.
- App-local doc claiming deps outside its scope → error.
- App-local doc not linked from root router (orphan) → error.
- Router link to missing cross-cutting doc → error.
- Broken
[text](path.md)markdown link → warn. README.md> 80 lines alongsideAGENTS.md→ warn (soft policy).- PR-only: covered code changed without
last_verifiedbeing bumped to today → error. (The single biggest accuracy gate.)
Weekly cron (doc-staleness.yml):
- Staleness: code in
dependent_pathsmodified more recently thanlast_verified→ one GH issue per doc. - Ageing:
last_verifiedolder than 90 days → one GH issue per doc. - Drift: exported symbols in
dependent_pathssource files not mentioned in the doc → one combined dashboard issue.
Why it stops rotting: seven reinforcing layers. A PR can skip one, not all.
- Per-PR coherence gate —
doc-check.tsfails the PR if paths break or app docs drift out of scope. - Per-PR last_verified gate — changing covered code without re-verifying the doc fails CI.
- Push-to-main static gate — direct commits to
mainstill get coherence checks (no last_verified enforcement there). - PR template — checklist nudges human or agent to update docs.
- Weekly cron — per-doc tracking issues for drifted/ageing docs.
- CLAUDE.md rule — agents read it at session start; enforces "update docs in the same PR" as a non-negotiable.
- Post-merge auto-update (v1.2.0) — on every merged PR,
doc-auto-update.ymlruns Claude Code headless with the PR diff and has it prepend a Timeline entry, bumplast_verifiedon any affected doc, and add a Recent Updates row to README if user-visible behavior shipped. Scoped to doc files only (tool allowlist prevents source code edits). RequiresANTHROPIC_API_KEYGH secret + PR labelskip-docsopt-out.
From your project root:
curl -fsSL https://raw.githubusercontent.com/lanceretter/lance-stack-template/main/docs-scaffold/install.sh | bashOr manual install from this repo:
cd /path/to/your/repo
cp -r /path/to/lance-stack-template/docs-scaffold/template/. .Then follow INSTALL.md — takes about 15 min to customize
for your project.
| File | Purpose |
|---|---|
README.md |
This file — what the system is and why |
INSTALL.md |
Step-by-step install + customize |
CONVENTIONS.md |
Front-matter format, Workflow sections, Timeline pattern |
UPDATE.md |
How to pull updates to doc-check.ts / workflows into existing installs |
install.sh |
One-liner installer (clones or curls this repo, copies files in) |
sync-consumers.sh |
Maintainer-run script that pushes the latest release to every registered consumer. Run once per release. |
INSTALLS.md |
Registry of known consumer repos — update when installing into a new repo (keep in sync with sync-consumers.sh REPOS=(...)) |
template/ |
The actual files to drop into your repo |
examples/ |
Real-world usage from conquest-hub |
"AGENTS.md gets too big and we lose things."
That's the problem this scaffold solves. One giant AGENTS.md accumulates until nobody reads it all, stale facts pile up, and agents waste tokens on irrelevant content.
Fix: split into focused docs, each under 200 lines, loaded by an agent only when relevant. Add machinery that makes updates mechanical instead of voluntary.
Written for teams of 1-5 devs building on top of Claude Code + GitHub. Scales up to 20 devs before the assumptions start to creak.
Current: v1.4.0 (2026-04-19 — maintainer-run sync script replaces the cron).
History:
- v1.4.0 (2026-04-19) — drops the in-consumer weekly cron in favor
of a single maintainer-run script (
docs-scaffold/sync-consumers.sh). GitHub's restriction on workflow-file modification by the defaultGITHUB_TOKENmade the cron impractical; a local script using the maintainer's authenticatedghCLI doesn't have that problem.install.sh/update.shno longer copy/fetchdocs-scaffold-update.yml; existing copies in consumers are deleted on next sync. - v1.3.2 (2026-04-19) — [superseded by v1.4.0] auto-update workflow added clear error on workflow-file push failures. Remained fundamentally constrained by GitHub platform rules, which drove the v1.4.0 rewrite.
- v1.3.1 (2026-04-19) — bump
actions/checkout@v4→v5andactions/setup-node@v4→v5to silence Node 20 deprecation warnings. - v1.3.0 (2026-04-19) — [superseded by v1.4.0] self-updating via weekly cron
(
docs-scaffold-update.yml). Each consumer repo runs the workflow weekly, compares its.docs-scaffold-versionagainst upstream, and opens a PR if a new release is available. UsesGITHUB_TOKEN— no PAT or secret required for the default path. Also fixes a v1.2.0 oversight:install.shnow copiesdoc-auto-update.yml, andupdate.shnow updates it. New: upstreamINSTALLS.mdregistry tracks which consumer repos have the scaffold installed. - v1.2.0 (2026-04-19) — post-merge AI auto-documentation workflow
(
doc-auto-update.yml). Runs Claude Code headless after every PR merge, has it prepend Timeline entries, bumplast_verifiedon affected docs, and surface user-visible changes in README. Tool allowlist restricts to doc files only — cannot modify source.ANTHROPIC_API_KEYGH secret required.skip-docsPR label or[skip docs]in PR title opts out. Backwards compatible; workflow is additive. Proven out inconquest-hub(initial rollout). - v1.1.0 (2026-04-18) — per-app AGENTS.md scope + orphan check,
last_verifiedbump enforcement on PRs, markdown link integrity, README policy lint, push-to-main trigger, per-doc tracking issues, absolute-age (90d) signal. Backwards-compatible with v1.0.0 consumers. - v1.0.0 (2026-04-18) — initial release from conquest-hub PRs #8/#9.
Bump when: breaking changes to doc-check.ts CLI or to the front-matter
format. Consumers running older versions see a migration note in
UPDATE.md.
- Pattern from
garrytan/gbrain— specificallyskills/RESOLVER.mdstructure + compiled-truth-plus-timeline page format. - Extracted from
conquest-solutions/conquest-hubPRs #8 and #9 where the system was first built and proven.