Files
supabase/.agents/skills/ask-the-docs/reference/llm-agent-surface.md
Nik RichersandNik Richers a522111d51 docs(skills): update ask-the-docs skill and add a drift check (#54149)
## I have read the CONTRIBUTING.md file.

YES

## What kind of change does this PR introduce?

**Skill fix + drift check.** This PR fixes stale facts in the
`ask-the-docs` skill after the Next.js 16 upgrade and the AI layout
work. It also gives the skill a cheap way to notice its own drift: each
checked reference file records the commit it was verified at, and the
agent runs one `git log` against that commit before it answers.
Follow-up to #54082.

## What is the current behavior?

- `app-map.md` says the docs app is Next.js 15. It is Next.js 16
(#52045).
- `app-map.md` and `llm-agent-surface.md` point to
`apps/docs/middleware.ts` and `apps/www/middleware.ts`. Both files are
now `proxy.ts` (#52045).
- The skill doesn't say that dev uses Turbopack while the build uses
webpack (#53787), so a loader change can work in dev and fail in the
build.
- The skill doesn't mention layout v2 (#52971 to #52976) or
`apps/docs/style-guide/`.
- No reference file records when it was last checked, so an agent can't
tell an old fact from a new one.

## What is the new behavior?

| File | Change |
| --- | --- |
| `SKILL.md` | New step 1, **Check for drift**: run `git log <Verified
at>..HEAD` for each reference file the answer uses. A file with no stamp
is unverified. New rule: list stale facts under **Skill corrections**
and, with the user's approval, fix them in the user's open PR if it
changes `apps/docs`, else in a new PR. |
| `reference/app-map.md` | Next.js version removed, `proxy.ts`, a
`style-guide/` row, and a short **Layout v2** section (variant, flag,
override, shell files). |
| `reference/llm-agent-surface.md` | Each `middleware.ts` is now
`proxy.ts` (docs and www), including the Mermaid node. A stale line
range is removed. |
| `reference/build-pipeline.md` | Dev uses Turbopack, the build uses
`--webpack`, and a loader change must work in both. |

Only these 3 reference files get a `Verified at: 3089aa3f67
(2026-11-25).` line, because they are the only ones checked claim by
claim. The other 11 files get a stamp when someone checks them.

## Additional context

- **Proof:** none needed. This PR changes skill reference files only,
with no rendered output.
- **Verification:** each changed fact was checked against the code at
this branch's base.

| Fact | Evidence |
| --- | --- |
| Next.js 16 | `pnpm-workspace.yaml` catalog: `next: ^16.4.3` |
| `proxy.ts` | `apps/docs/proxy.ts` and `apps/www/proxy.ts` exist,
`middleware.ts` doesn't |
| Turbopack in dev, webpack in build | `apps/docs/package.json` `build`:
`next build --webpack`; `next.config.mjs` has `webpack` and `turbopack`
blocks |
| `layout-v2:` variant | `apps/docs/styles/globals.css:25` |
| Flag and override | `apps/docs/features/IaNav/constants.ts`
(`docs-ia-mvp-v1`, `option-1`, URL override) |

- `app-map.md` still lists `content/troubleshooting/` on `master`.
#54082 removes it, so this PR leaves those lines alone. The two PRs
touch different lines and can merge in either order.

### Test plan

- [ ] Each fact in the table above matches the code
- [ ] Ask the skill a question about `apps/docs/proxy.ts` and confirm it
runs the drift check first
- [ ] `grep -rn "middleware.ts" .agents/skills/ask-the-docs` returns
nothing

---------

Co-authored-by: Nik Richers <nik@validmind.ai>
2026-11-26 11:17:31 -07:00

10 KiB

LLM and agent consumption surface

How apps/docs exposes machine-readable content and how that relates to apps/www. For markdown export fidelity and agent onboarding pages, see llm-agent-parity.md. For the markdown export pipeline itself, see app-map.md "The two pipelines."

Verified at: 3089aa3f67 (2026-11-25).

Verify against live code — several pieces here span two apps and change independently.

Scope boundary

App Role
apps/docs Produces markdown exports, serves per-guide .md, reference static files, GraphQL search, agent onboarding guides
apps/www Serves discovery indexes (/llms.txt, /llms-full.txt) and product-page .md negotiation

llms.txt is not a route in apps/docs. It is assembled at runtime by apps/www/app/llms.txt/route.ts, reading guide directory names from apps/docs/content/guides/ and linking to docs + reference exports. There is no static llms.txt file in the repo — the www route handler builds it on each request.

Key source files

What Monorepo path Public URL (prod)
llms.txt route apps/www/app/llms.txt/route.ts https://supabase.com/llms.txt
llms-full.txt route apps/www/app/llms-full.txt/route.ts https://supabase.com/llms-full.txt
Guide proxy apps/docs/proxy.ts Negotiates markdown, rewrites to guides-md
WWW proxy apps/www/proxy.ts Product-page markdown negotiation
Negotiation logic packages/common/markdown-negotiation.ts Shared by both proxy files
Guides markdown API apps/docs/app/api/guides-md/[...slug]/route.ts Reads public/markdown/guides/ at runtime
Markdown manifest apps/docs/public/markdown/manifest.json Slugs eligible for .md negotiation

Build outputs → serving paths

flowchart TB
  subgraph docsApp ["apps/docs build"]
    GM["build:guides-markdown"]
    RM["build:reference-markdown"]
    GZ["build:gz-archive"]
    GM --> outGuides["public/markdown/guides/"]
    RM --> outRef["public/markdown/reference/"]
    GZ --> tarball["public/docs.tar.gz"]
  end

  subgraph docsServe ["apps/docs runtime"]
    mw["proxy.ts"]
    guidesMd["api/guides-md"]
    crawlers["api/crawlers"]
    gql["api/graphql searchDocs"]
    mw --> guidesMd
  end

  subgraph wwwApp ["apps/www"]
    llmsTxt["/llms.txt"]
    llmsFull["/llms-full.txt"]
  end

  outGuides --> guidesMd
  outGuides --> llmsFull
  outRef --> llmsFull
  outGuides --> llmsTxt
  gql --> guidesMd

Entry points

URL Owner Source
/llms.txt apps/www app/llms.txt/route.ts — index of guide sections + reference links
/llms-full.txt apps/www app/llms-full.txt/route.ts — concatenated guides + reference + product overviews
/docs/guides/<path>.md apps/docs Proxy → app/api/guides-md/[...slug]/route.ts reads public/markdown/guides/
/docs/markdown/reference/<lib>.md apps/docs Static file from public/markdown/reference/ (build output)
/docs/docs.tar.gz apps/docs internals/generate-gz-archive.ts tarballs all of public/markdown/
/docs/api/graphql (searchDocs) apps/docs Vector search over embedded doc sections — see llm-agent-parity.md
/docs/reference/<sdk>/<section> (bots) apps/docs isbot() → app/api/crawlers/route.ts (simplified HTML, not markdown)

Homepage alternate link points agents at the full dump: https://supabase.com/llms-full.txt (apps/docs/app/page.tsx).

Audience routing (humans vs agents vs crawlers)

Every guide exists in two forms from the same MDX source:

Form Produced by Served to
HTML Live MDX render (partialsRemark, React components) Humans in a browser
Markdown Prebuild (generate-guides-markdown.ts → public/markdown/guides/) Live-fetch agents and bulk downloads

apps/docs/proxy.ts is the bouncer for guide requests. It calls negotiateMarkdown() from packages/common/markdown-negotiation.ts and checks public/markdown/manifest.json before serving markdown.

flowchart TD
  req[Guide request] --> mdSuffix{URL ends in .md?}
  mdSuffix -->|yes| markdown[Serve markdown]
  mdSuffix -->|no| agentUA{Live-fetch agent UA?}
  agentUA -->|yes| markdown
  agentUA -->|no| accept{Accept prefers markdown?}
  accept -->|yes| markdown
  accept -->|no| html[Serve HTML page]
  markdown --> rewrite["Rewrite to /api/guides-md/..."]
  rewrite --> file["Read public/markdown/guides/..."]

Who gets what

Audience Typical request Format Notes
Human (browser) /docs/guides/.../nextjs HTML Default — no special headers
Live-fetch agent Same URL with Claude-User, ChatGPT-User, PerplexityBot, or Claude-Web UA Markdown Auto-negotiated even without .md suffix
Live-fetch agent /docs/guides/.../nextjs.md or Accept: text/markdown Markdown Explicit request
SEO bot (Googlebot) Guide URL HTML Same page humans see; isbot() markdown rewrite applies only to reference pages
Training crawler (GPTBot, ClaudeBot) Guide URL HTML Allowed by robots.txt but not given alternate markdown — avoids cloaking
Bulk ingest /llms-full.txt, /docs/docs.tar.gz Markdown Reads prebuilt public/markdown/ files

Humans see interactive UI (copy buttons, styled panels). Agents and bulk tools read the pre-generated .md transcript — not the live HTML DOM.

Agent discovery

Agents that don't know a specific URL can start from:

  • /llms.txt — section index with links to .md paths
  • /llms-full.txt — concatenated guides + reference + product overviews
  • rel="alternate" type="text/markdown" on each guide page (GuidesMdx.utils.tsx → ${BASE_PATH}${pathname}.md)
  • Docs homepage alternate → https://supabase.com/llms-full.txt

Content negotiation

Shared logic lives in packages/common/markdown-negotiation.ts, used by both apps/docs/proxy.ts and apps/www/proxy.ts.

Markdown is served when:

  • The URL ends in .md
  • Accept: text/markdown wins over HTML (q-value comparison)
  • The user-agent matches live-fetch agents: Claude-User, Claude-Web, ChatGPT-User, PerplexityBot

Training crawlers (GPTBot, ClaudeBot, etc.) are not given alternate markdown — they are governed by robots.txt to avoid cloaking penalties.

On guides, negotiated requests rewrite to /api/guides-md/<slug>. Each guide page advertises its markdown alternate in metadata via GuidesMdx.utils.tsx (text/markdown → ${BASE_PATH}${pathname}.md).

404 responses from guides-md are also markdown and include searchDocs suggestions — useful when an agent fetches a stale URL.

Bulk vs per-page retrieval

Strategy Best for
/llms.txt Discovering available sections and reference libs
/llms-full.txt One-shot full ingest
/docs/docs.tar.gz Offline/batch ingest of all generated markdown
/docs/guides/<path>.md Single guide page
/docs/markdown/reference/<lib>.md Single reference lib export

Reference pages do not use the same Accept: text/markdown negotiation as guides. Reference markdown comes from the static export and llms-full.txt, not from proxy negotiation.