---
title: "CLI"
description: "Scaffold, upgrade, export static Agent Bundles, compact agent docs, validate code blocks, generate sitemaps and robots.txt, sync search, and run MCP"
canonical_url: "https://docs.farming-labs.dev/docs/cli"
markdown_url: "https://docs.farming-labs.dev/docs/cli.md"
last_updated: "2018-10-20"
agent:
  tokenBudget: 1400
  task: "Choose and run the appropriate Farming Labs docs CLI workflow for a project."
  outcome: "The selected CLI operation completes and the resulting docs configuration passes the agent doctor."
  appliesTo:
    framework:
      - "nextjs"
      - "tanstackstart"
      - "sveltekit"
      - "astro"
      - "nuxt"
    version:
      - ">=0.2.60"
    package:
      - "@farming-labs/docs"
  prerequisites:
    - "Run commands from the docs project root with its package manager available."
    - "Install project dependencies before invoking the local docs binary with pnpm exec."
  files:
    - "package.json"
    - "docs.config.ts"
    - "docs.config.tsx"
    - "src/lib/docs.config.ts"
  commands:
    - run: "pnpm exec docs doctor --agent"
      description: "Validate the configured agent-facing docs surface after a CLI workflow."
  verification:
    - run: "pnpm exec docs doctor --agent"
      expect: "The doctor loads docs.config and reports the enabled discovery surfaces without hard failures."
  rollback:
    - "Restore generated configuration and public artifacts from version control if a mutating command produced the wrong result."
  failureModes:
    - symptom: "pnpm cannot find the docs executable."
      resolution: "Install dependencies or invoke the published CLI with pnpm dlx @farming-labs/docs."
    - symptom: "The CLI loads the wrong config file."
      resolution: "Run from the project root or pass the documented --config path explicitly."
---

<!-- farming-labs:agent-contract:start -->
## Agent Contract

Task: Choose and run the appropriate Farming Labs docs CLI workflow for a project.
Outcome: The selected CLI operation completes and the resulting docs configuration passes the agent doctor.

### Applies To

- Framework: `nextjs`, `tanstackstart`, `sveltekit`, `astro`, `nuxt`
- Version: `>=0.2.60`
- Package: `@farming-labs/docs`

### Prerequisites

- Run commands from the docs project root with its package manager available.
- Install project dependencies before invoking the local docs binary with pnpm exec.

### Files

- `package.json`
- `docs.config.ts`
- `docs.config.tsx`
- `src/lib/docs.config.ts`

### Commands

- `pnpm exec docs doctor --agent` — Validate the configured agent-facing docs surface after a CLI workflow.

### Verification

- Run `pnpm exec docs doctor --agent`
  - Expected: The doctor loads docs.config and reports the enabled discovery surfaces without hard failures.

### Rollback

- Restore generated configuration and public artifacts from version control if a mutating command produced the wrong result.

### Failure Modes

- pnpm cannot find the docs executable. — Recovery: Install dependencies or invoke the published CLI with pnpm dlx @farming-labs/docs.
- The CLI loads the wrong config file. — Recovery: Run from the project root or pass the documented --config path explicitly.
<!-- farming-labs:agent-contract:end -->

# CLI

## CLI task

Task: Choose and run the appropriate Farming Labs docs CLI workflow for a project.

Expected result: The selected CLI operation completes and the resulting docs configuration passes the agent doctor.

Exact implementation:

```bash title="terminal"
pnpm exec docs codeblocks validate --plan
pnpm exec docs codeblocks validate
pnpm exec docs codeblocks validate --json
```
## CLI prerequisites

- Run commands from the docs project root with its package manager available.
- Install project dependencies before invoking the local docs binary with pnpm exec.
- Applies to framework nextjs, tanstackstart, sveltekit, astro, nuxt; version >=0.2.60; package @farming-labs/docs.

## CLI verification

- Run pnpm exec docs doctor --agent. Expected: The doctor loads docs.config and reports the enabled discovery surfaces without hard failures.
- Failure: pnpm cannot find the docs executable.
- Recovery: Install dependencies or invoke the published CLI with pnpm dlx @farming-labs/docs.
- Rollback: Restore generated configuration and public artifacts from version control if a mutating command produced the wrong result.

## CLI agent guidance

Choose the CLI workflow before changing files. For a published release use
`pnpm dlx @farming-labs/docs <command>`; use `pnpm exec docs <command>` only after the project has
installed its dependencies. For a non-interactive fresh scaffold, use
`init --template <framework> --name <dir>`; omit `--name` to be prompted. Plain `init` asks whether
to modify the current app or create a fresh project.

After a mutating command, run `pnpm exec docs doctor --agent`; the expected result is a loaded
`docs.config.ts`, `docs.config.tsx`, or `src/lib/docs.config.ts` with no hard failure for an enabled
agent surface. For SvelteKit or Astro, append `--config src/lib/docs.config.ts`. Prefer `--dry-run`
for upgrade or compaction previews and `--check` for generated agent bundles, sitemaps, robots, or
AGENTS files where the command documents that flag.

If `pnpm` cannot find `docs`, install dependencies or switch to the published `pnpm dlx` form. If
the wrong config is loaded, return to the project root or pass the command's documented
`--config <path>` option; do not copy flags between unrelated subcommands.
## CLI runnable code-block validation

Plan fenced MDX examples with `pnpm exec docs codeblocks validate --plan`, then run the documented validation workflow before publishing.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
