CLI

Run the right docs command with the right flags: init, preview, check, and agent setup.

Global options

These options apply before any subcommand.

bash
docs [global options] <command> [command options]
--api-urlurl

Base docs.page API URL for agent commands. When unset, the CLI uses the production API.

Environment variable: DOCS_PAGE_API_BASE

--help, -hflagoptional

Show help for the command.

--version, -vflagoptional

Print the CLI version.

init, preview, and check do not call the docs.page API.


docs init

Initialize docs.page files in a project directory.

bash
docs init [path] [flags]
pathstringoptional

Project directory to initialize. Defaults to ..

--namestringoptional

Project name written into docs.json. Inferred from package.json, pubspec.yaml, or the folder name when omitted in interactive mode.

--docsflagoptional

Create starter docs/**/*.mdx files. Default in non-interactive mode when neither --docs nor --no-docs is passed.

--no-docsflagoptional

Write docs.json only; skip starter page files.

--overwriteflagoptional

Replace existing files created by docs.page init.

In an interactive terminal, the CLI prompts for missing values. In non-interactive mode (CI or piped stdin), pass --name, --docs or --no-docs, and --overwrite when replacing existing files; otherwise the command exits with a Missing --<flag> error.

Errors

ConditionMessage
docs.json exists in non-interactive mode without --overwritedocs.json already exists. Re-run with --overwrite to replace it.
docs/ conflicts in non-interactive modedocs/ already exists. … Re-run with --overwrite … or --no-docs …
Init templates missing from the packageUnable to find docs.page init templates.
Required flag missing in non-interactive modeMissing --<flag>. Pass it as an option when running non-interactively.

Output

On success, the CLI prints created file paths or No docs.page files were changed. when all targets already exist.


docs preview

Start a local preview server and open the docs.page preview UI.

bash
docs preview [flags]
--portnumberoptional

TCP port for the local WebSocket server. When omitted, the CLI binds an ephemeral port on localhost (OS-assigned).

--no-browserflagoptional

Do not open the preview URL automatically.

Requires docs.json or docs.yaml and at least one .mdx file under docs/.

Errors

ConditionMessage
Missing config fileNo docs.json or docs.yaml file was found in the current directory.
Missing docs/ directoryNo docs/ directory was found in the current directory.
No page filesNo .mdx files were found in the docs/ directory.
Invalid --port value`--port` must be a valid TCP port.
Port bind failureNode.js EADDRINUSE or related bind error

Output

On success, the CLI prints Local preview server started., the WebSocket URL (ws://localhost:<port>), and a Preview URL shaped like https://docs.page/preview?url=ws://localhost:<port>. The server runs until you stop it with Ctrl+C (exit code 0).


docs check

Check documentation for broken links and missing assets.

bash
docs check [path] [flags]
pathstringoptional

Project directory to check. Defaults to ..

--internal-linksoff | warn | erroroptional

Check internal links and frontmatter redirect, next, and previous paths. Default: error.

--assetsoff | warn | erroroptional

Check that referenced local image and asset files exist. Default: error.

--external-linksoff | warn | erroroptional

Fetch external URLs and report failures. Default: error.

--renderoff | warn | erroroptional

Validate that each page's MDX renders without errors. Default: error.

--metadataoff | warn | erroroptional

Warn when title or description is missing on pages that use auto-generated social preview images. Also checks site name and description in docs.json. Default: error.

All five severity flags accept off, warn, or error. Default for each: error.

Exit codes

CodeMeaning
0No error-level issues found.
1One or more error-level issues found.

Errors

ConditionMessage
Missing configNo docs.json or docs.yaml file was found.
Invalid docs.jsondocs.json is not valid JSON: …
Invalid docs.yamldocs.yaml is not valid YAML: …
No page filesNo docs/**/*.mdx files were found.
Broken internal linkInternal link points to a missing docs page. (or frontmatter variant)
Missing assetReferenced asset does not exist.
Unreachable external URLUnable to reach external link: … or External link returned &lt;status&gt; …

docs agent create

Create an in-docs chat agent for a GitHub repository.

bash
docs agent create [flags]
--repoorg/nameoptional

Target GitHub repository. Prompted when omitted in an interactive terminal.

--providerstringoptional

LLM provider: openai, anthropic, google, or xai.

--apikeystringoptional

Provider API key. Encrypted locally before upload. Prompted as a password when omitted in an interactive terminal.

--gh-authstringoptional

GitHub token instead of gh auth token.

--forceflagoptional

Overwrite an existing agent configuration.

Success

The CLI prints Your documentation agent is ready to use. and a JSON snippet with agent.key to add to docs.json.

Errors

ConditionMessage
Missing --repo in non-interactive modeMissing --repo.
Invalid repository format`--repo` must be in the form `org/name`.
Invalid provider`--provider` must be one of: xai, openai, anthropic, google.
API key too short`--apikey` must be longer than 1 character.
gh not installedGitHub CLI (\gh`) is required when `--gh-auth` is not provided.`
gh not authenticatedUnable to read a GitHub auth token from \gh`. Run `gh auth login`, or pass `--gh-auth`.`
API error responseServer \error` string or Agent creation failed (<status> …).`
Missing token in responseAgent creation failed: response did not include a token.

docs agent delete

Delete the agent configuration for a repository.

bash
docs agent delete [flags]
--repoorg/nameoptional

Target GitHub repository. Prompted when omitted in an interactive terminal.

--gh-authstringoptional

GitHub token instead of gh auth token.

Success

The CLI prints Deleted agent for org/name.

Errors

ConditionMessage
Missing --repo in non-interactive modeMissing --repo.
Invalid repository format`--repo` must be in the form `org/name`.
GitHub auth failureSame messages as agent create
API error responseServer \error` string or Agent deletion failed (<status> …).`

See also