CLI
CLI
Two commands: generate runs the full pipeline, lint validates content. Run leadtype help <command> for inline usage.
generate
Convert MDX, then either produce website artifacts (default) or a package bundle (--bundle).
| Flag | Default | Description |
|---|---|---|
--src <dir> | . | Repo or root directory containing the docs folder. |
--docs-dir <dir> | docs | Docs source folder relative to --src. Repeat to merge multiple folders into one generated docs tree. |
--out <dir> | public | Output root. The pipeline writes to <out>/llms.txt and docs-scoped artifacts under <out>/docs/* in site mode, or <out>/AGENTS.md and <out>/docs/*.md in bundle mode. |
--bundle | off | Bundle mode. Emits AGENTS.md and docs/*.md for offline agents. Skips llms.txt, llms-full.txt, search, sitemap, robots, and Agent Readability artifacts. |
--base-url <url> | — | Base URL for canonical artifacts like sitemap.xml, robots.txt, search metadata, and full-context fallback URLs. Site mode only; ignored in --bundle. |
--name <name> | from docs.config.ts or package.json#name | Product name written into the index file (llms.txt or AGENTS.md). Overrides config. |
--summary <text> | from docs.config.ts or package.json#description | Product summary written into the index file. Overrides config. |
--include <glob> | none | Docs-root-relative glob to include. Repeatable. Works in both modes. |
--exclude <glob> | none | Docs-root-relative glob to exclude. Applied after --include. |
--enrich-git | off | Add lastModified and lastAuthor to frontmatter from git history. |
--format <fmt> | text | text or json. JSON prints a single result object on stdout. |
--json | — | Alias for --format json. |
-h, --help | — | Print usage. |
Exit codes: 0 success, 1 runtime error (docs dir missing, config load error, unknown group, conversion error), 2 CLI usage error.
Config loading
leadtype generate automatically loads docs.config.ts from the docs folder (<src>/<docs-dir>/docs.config.ts). JavaScript config files also work: docs.config.js, docs.config.mjs, and docs.config.cjs.
The config supplies product metadata, group titles, group order, group descriptions, best starting points, and agent guidance. Pages still declare membership with group: in frontmatter. If a page names a group that is not in the loaded config, generation fails.
If no config file exists, the CLI falls back to package.json for product metadata and infers groups from the union of group: values across the generated pages. Inferred groups are sorted alphabetically and title-cased. Use docs.config.ts when order or descriptions matter.
Multiple source folders
Repeat --docs-dir when a project keeps related agent-readable content outside the main docs folder, such as a sibling changelog:
The first source folder is mounted at the generated docs root. Additional source folders are mounted under their folder name, so changelog/v1.mdx becomes public/docs/changelog/v1.md and /docs/changelog/v1.md. --include and --exclude still match docs-root-relative paths after that merge, for example --include "changelog/**".
Use <dir>=<url-prefix> when a source should have its own public URL prefix:
That keeps the internal generated copy at public/docs/changelog/v1.md for search and runtime helpers, also writes a static markdown mirror at public/changelog/v1.md, and emits canonical links such as /changelog/v1.md in llms.txt, search metadata, sitemap entries, and agent-readability.json.
Bundle mode
Writes <out>/AGENTS.md (relative-link index, agent-discoverable) plus <out>/docs/*.md (one per page, group subdirs preserved). Skips every URL-anchored artifact (llms.txt, llms-full.txt, search-index.json, search-content.json) — those are website-only. Use this for npm packages that ship docs alongside the published code; see Bundle docs into a package.
JSON output shape
--json prints a single object describing what was generated. The shape varies by mode:
The sitemap and robots files are docs-scoped so the host app can merge them with blog, marketing, changelog, or product pages before serving site-root /sitemap.xml, /sitemap.md, and /robots.txt.
In --bundle mode, mode is "bundle" and files contains only agentsMd. Site-only fields (search, llmsTxt, sitemap, robots, etc.) are absent.
Errors in JSON mode print {"error": "...", ...} to stderr.
Custom script config
Custom build scripts do not auto-discover config. Import docs.config.ts directly and pass the values to the lower-level APIs:
See LLM files for the rest of the script.
lint
Validate frontmatter, meta.json, and internal links before generation runs.
| Flag | Default | Description |
|---|---|---|
[srcDir] | content | Source docs root. Equivalent to --src. |
--src <dir> | — | Same as the positional. |
--changelog <dir> | — | Subdirectory under srcDir validated against the changelog schema. |
--format <fmt> | pretty | pretty, json, or github (annotation format). |
--ignore <glob> | shared & node_modules defaults | Glob to skip. Repeatable; passing any --ignore overrides defaults. |
--warn-unknown | on | Report unknown frontmatter and meta fields as warnings. |
--error-unknown | off | Report unknown fields as errors. |
--max-warnings <n> | unlimited | Exit non-zero when warning count exceeds n. |
-h, --help | — | Print usage. |
Exit codes: 0 no errors and warnings within budget, 1 lint errors or budget exceeded, 2 CLI usage error.
Default ignored paths: **/shared/**, **/_shared/**, **/_partials/**, **/node_modules/**. Pass --ignore to extend (each pass overrides the defaults — re-add what you need).
See Lint reference for the full rule list, schema, and how to plug in custom Valibot schemas via the library API.
help
Show usage:
Library entry points
The CLI is a thin wrapper. Every command is also available as a TypeScript API for custom build scripts:
leadtype/convert—convertAllMdx,convertMdxToMarkdown,writeMdxFileAsMarkdown.leadtype/llm—generateLlmsTxt,generateLLMFullContextFiles,generateAgentReadabilityArtifacts,generateAgentsMd,resolveDocsNavigation.leadtype/llm/readability— JSON-LD, markdown response, frontmatter, and agent request helpers for hosted docs sites.leadtype/search/node—generateDocsSearchFiles.leadtype/lint—lintDocs.leadtype/remark—defaultRemarkPluginsand individual plugins.
Use the CLI for the happy path, the library entry points when you need custom plugin order, base URL precedence, or alternate output paths.