Always consult the project docs (and /docs routes when available) for the latest API and examples.
@farming-labs/docs is a modern, flexible MDX-based documentation framework. Write markdown, get a polished docs site. Supported frameworks: Next.js, TanStack Start, Farm.js, SvelteKit, Astro, Nuxt.
Quick reference
CLI (see also the cli skill)
| Scenario | Command |
|---|---|
| Interactive init (existing or fresh) | npx @farming-labs/docs@latest init — first asks Existing project or Fresh project; then theme (or Create your own theme), entry path, etc. Prompts with a placeholder (e.g. docs, my-docs) accept Enter as default. |
| Add docs to existing app | Run init in project root; choose Existing project when prompted. |
| Start from scratch (bootstrap, no prompts) | npx @farming-labs/docs@latest init --template <next | tanstack-start | nuxt | sveltekit | astro> --name <project-name> |
| Add generated API reference during init | npx @farming-labs/docs@latest init --api-reference (optional --api-route-root <path>) |
| Upgrade docs packages | npx @farming-labs/docs@latest upgrade — auto-detects next, tanstack-start, nuxt, sveltekit, or astro; use --framework if detection is ambiguous. |
Packages by framework
| Framework | Core + adapter | Theme package |
|---|---|---|
| Next.js | @farming-labs/docs, @farming-labs/next |
@farming-labs/theme |
| TanStack Start | @farming-labs/docs, @farming-labs/tanstack-start |
@farming-labs/theme |
| Farm.js | @farming-labs/docs, @farming-labs/farmjs |
@farming-labs/theme |
| SvelteKit | @farming-labs/docs, @farming-labs/svelte |
@farming-labs/svelte-theme |
| Astro | @farming-labs/docs, @farming-labs/astro |
@farming-labs/astro-theme |
| Nuxt | @farming-labs/docs, @farming-labs/nuxt |
@farming-labs/nuxt-theme |
Install only the Farming Labs package set for the chosen framework. Do not ask users to install
Fumadocs or Scalar packages directly; API reference renderers are bundled by @farming-labs/docs
and the framework adapters.
Built-in themes
Twelve CLI-selectable built-in theme entrypoints: fumadocs (default), darksharp, pixel-border, colorful, greentree, darkbold, shiny, ledger, shadcn, concrete, command-grid, and hardline. hardline is the existing hard-edge preset, concrete is the louder brutalist poster-style variant, command-grid is the mono-first paper-grid preset inspired by the better-cmdk landing page, ledger is a Stripe Docs-inspired product docs shell, and shadcn recreates the compact neutral shadcn/ui documentation shell. The init CLI offers Create your own theme — it prompts for a theme name (default my-theme) and scaffolds themes/<name>.ts and themes/<name>.css. The theme name in config must match the theme's CSS import path (e.g. shadcn → @farming-labs/theme/shadcn/css for Next.js).
Built-in UI features
- MDX components — built-ins like
Callout,Tabs,HoverLink,Agent,Human, andAudienceare available without imports. Content is shared by default. Use<Agent>or<Audience only="agent">for agent-only context, and<Human>or<Audience only="human">for human-only context. KeepAudience.onlystatic and avoid spread props;docs reviewreports declarations that static agent outputs cannot resolve consistently. - Page feedback — enable with
feedback: trueorfeedback: { enabled: true, onFeedback() {} }. - Agent discovery — agents can use the RFC 9727
/.well-known/api-cataloglinkset and the hashed/.well-known/agent-skills/index.jsonindex. The existing/.well-known/agent.jsonmanifest remains the preferred Farming Labs document, with/.well-known/agentas fallback and/api/docs/agent/specas its canonical framework route. These resources cross-link one another, and dynamic responses expose discoveryLinkheaders. - Generated AGENTS.md —
GET /AGENTS.md,GET /.well-known/AGENTS.md, andGET /api/docs?format=agentsreturn coding-agent instructions by default. A rootAGENTS.mdorAGENT.mdoverrides the generated fallback; usedocs agents generatefor static exports. - Generated robots.txt — use
docs robots generateto write a static policy that allows docs routes,.mdroutes,llms.txt, sitemaps,AGENTS.md,skill.md, the API catalog, Agent Skills discovery, MCP aliases, existing agent discovery routes, and common AI crawler user agents. Existing files are preserved by default; use--appendto add the managed block or--forceto replace the file. - Structured data — every docs page emits Schema.org
TechArticleJSON-LD with title, description, canonical URL, freshness, and breadcrumbs. It reusessitemap.baseUrl,llmsTxt.baseUrl,robots.baseUrl, orai.docsUrl; no separate config flag is required. - Agent feedback endpoints — add
feedback.agentwhen agents should report structured{ context?, payload }feedback through/api/docs/agent/feedbackand/api/docs/agent/feedback/schema. - Page actions — enable with
pageActions.copyMarkdownandpageActions.openDocs. - Built-in changelog pages (Next.js) — enable
changelogto publish a release feed from dated MDX entries. - Built-in MCP server — enabled by default at
/mcpand/.well-known/mcp, backed by/api/docs/mcp, and for local stdio tools. Next.js wires rewrites withwithDocs(); TanStack Start/SvelteKit/Astro/Nuxt scaffold one public forwarder each. Opt out withmcp: falseormcp: { enabled: false }. - Machine-readable markdown routes —
/docs.mdand/docs/<slug>.mdreturn agent-ready markdown in Next.js and in the generated TanStack Start, SvelteKit, Astro, and Nuxt forwarding layer. Next.js also returns the same markdown from/docs/<slug>when the request sends an unambiguousAccept: text/markdown; mixed headers containing an HTML-capable range should use the exact.mdURL or API format route. Markdown responses start with YAML frontmatter fortitle, optionaldescription,canonical_url,markdown_url, andlast_updatedwhen a freshness date is known. Use embedded<Agent>...</Agent>or<Audience only="agent">...</Audience>blocks insidepage.mdxwhen the normal page only needs extra machine context. Use<Human>or<Audience only="human">to keep presentation-only content out of agent context, and add a siblingagent.mdwhen the whole machine-readable page should be overridden. The shared docs API also supportsGET /api/docs?format=markdown&path=<slug>. Page frontmatterrelatedappears as a comma-separated machine-readable markdown metadata line besideDescriptionunless a siblingagent.mdfully overrides the page. - Audience projection — rendered HTML and public search use the human projection; Markdown,
Ask AI, MCP,
llms-full.txt, and static agent exports use the agent projection. Compactllms.txtcontains discovery links to agent-projected Markdown, and sitemaps contain route metadata only. Audience filtering is not authentication, so never place secrets in an audience block oragent.md.
MCP quick test
To verify the HTTP MCP route in this repo, use the Next example:
pnpm --dir examples/next dev
Then point your MCP client or inspector at http://127.0.0.1:3000/mcp or http://127.0.0.1:3000/.well-known/mcp.
Critical: theme CSS
Every setup must import the theme's CSS in the global stylesheet. Without it, docs pages will not be styled.
- Next.js:
app/global.css→@import "@farming-labs/theme/<theme>/css";(e.g.default,greentree,pixel-border). - TanStack Start:
src/styles/app.css(or your main global CSS file) →@import "@farming-labs/theme/<theme>/css"; - Farm.js:
src/app/globals.css(or your main global CSS file) →@import "@farming-labs/theme/<theme>/css"; - SvelteKit:
src/app.css→@import "@farming-labs/theme/<theme>/css"; - Astro: Import in the docs layout or page file:
import "@farming-labs/theme/<theme>/css"; - Nuxt:
nuxt.config.ts→css: ["@farming-labs/theme/<theme>/css"]
Use the same theme name in docs.config and in the CSS import.
Core config: defineDocs
All frameworks use a single config file (docs.config.ts or docs.config.tsx):
import { defineDocs } from "@farming-labs/docs";
import { fumadocs } from "@farming-labs/theme"; // or svelte-theme, astro-theme, nuxt-theme
export default defineDocs({
entry: "docs",
contentDir: "docs", // SvelteKit, Astro, Nuxt
theme: fumadocs(),
metadata: {
titleTemplate: "%s – Docs",
description: "My documentation site",
},
});
- Next.js:
docs.config.tsat project root; wrap Next config withwithDocs()from@farming-labs/next/config. Content lives underapp/docs/(path derived fromentry). - TanStack Start:
docs.config.tsordocs.config.tsxat project root; setcontentDirandnav, create/api/docs, and load content from yourdocs/directory via@farming-labs/tanstack-start/server. - Farm.js:
docs.config.tsat project root; setcontentDirandnav, then wrap Farm'sdefineConfig()result withwithDocs()from@farming-labs/farmjs/config. Farm owns development and production docs routing. - SvelteKit:
src/lib/docs.config.ts; routes undersrc/routes/docs/; setcontentDirto the folder containing your markdown (e.g.docs). - Astro:
src/lib/docs.config.ts; pages undersrc/pages/<entry>/; setcontentDir. - Nuxt:
docs.config.tsat project root;server/api/docs.tsandpages/docs/[...slug].vue; setcontentDirandnav.
TanStack Start, Farm.js, SvelteKit, Astro, and Nuxt require contentDir (path to markdown files) and nav (sidebar title and base URL).
Optional generated pages
- API reference: Read references/api-reference.md when enabling local route scanning, a hosted OpenAPI document, or non-Next handler routes.
- Changelog: Read references/changelog.md when adding the generated Next.js release feed and dated entry pages.
Doc content and frontmatter
Docs live under the entry directory (e.g. docs/ or app/docs/). Each page is MDX or Markdown with frontmatter:
---
title: "Installation"
description: "Get up and running"
related:
- /docs/configuration
- /docs/customization/agent-primitive
icon: "rocket"
order: 1
---
# Installation
Content here.
Routing is file-based: docs/getting-started/page.mdx → /docs/getting-started. Use order in frontmatter to control sidebar order (numeric ordering).
Path aliases and defaults (CLI)
When running init and choosing Existing project, the CLI asks about path aliases (Next: @/, SvelteKit: $lib/, Nuxt: ~/ vs relative paths). If the user chooses "no alias", generated code uses relative paths to docs.config, and tsconfig may omit the paths block.
Optional defaults: Prompts that show a placeholder (entry path docs, theme name my-theme, project name my-docs, global CSS path) use that value as the default — the user can press Enter to accept without typing.
Static export
For fully static builds (e.g. Cloudflare Pages, no server), set staticExport: true in defineDocs(). This hides search and AI chat in the layout. Omit or do not deploy the docs API route so no server is required.
Common gotchas
- Theme CSS missing — Docs look unstyled until the theme CSS is imported in the global stylesheet (or Nuxt
css). - Wrong theme helper package — Use the framework theme helper for
docs.config(e.g.@farming-labs/svelte-themefor SvelteKit), while theme CSS imports come from the shared@farming-labs/theme/<theme>/csspath. - From scratch — Use
init --template <next|tanstack-start|nuxt|sveltekit|astro> --name <project>; the CLI bootstraps a project with that name and runs install. - Existing project — Run
initin the project root; the CLI detects the framework and scaffolds files. - Static hosting — Set
staticExport: true; search and AI are then hidden. - API reference on non-Next frameworks —
apiReferenceindocs.configis not enough by itself on TanStack Start, SvelteKit, Astro, or Nuxt; add the/{path}handler manually or letinit --api-referencescaffold it, even when you use a remotespecUrl. - Changelog generation today — The built-in generated changelog pages are currently wired in Next.js. Use the Next adapter if you want the turn-key
/docs/changelogsflow. - TanStack Start in a monorepo — If the app and docs packages live in the same workspace, keep
@farming-labs/docs,@farming-labs/theme, and@farming-labs/tanstack-startlinked locally (for exampleworkspace:*). This avoids Node 22 / Vercel loading raw adapter TypeScript fromnode_modules.
Resources
- Repo: github.com/farming-labs/docs
- Docs site: docs.farming-labs.dev (or the project's
/docsroute) - Other skills in this repo:
cli,creating-themes,ask-ai,page-actions,configurationunderskills/farming-labs/.