Files
webstudio/docs/university/cli.md
T
Oleg Isonen 99371187dc docs: Move product documentation into Builder (#5987)
## Summary

- move the complete GitBook documentation tree and assets into Builder
under `/docs`
- generate the exhaustive MCP page from the local CLI source in the same
change
- publish GitBook from a release-gated `docs` branch containing the
exact successfully released revision
- run MCP documentation tests, typechecking, and stale-output checks
with the existing generated-docs check
- remove links to the Community Discussions repository

## Technical choices

- Import the current documentation as a linear snapshot so the branch
satisfies Builder's required-linear-history protection.
- Keep the Markdown wrapper separate from the TypeScript generator at
`scripts/docs/mcp-page.md`.
- Generate through `packages/cli/local.js` so CLI guidance and its
documentation are reviewed together.
- Let `check:generated-docs` reject CLI changes that leave the committed
MCP page stale.
- After both GitHub release creation and package publication succeed,
fast-forward the read-only `docs` branch to the immutable release tag
commit. A divergent update fails instead of publishing a different
revision.
- Configure GitBook to publish `/docs` from the `docs` branch, not
directly from `main`.
- Exclude `/docs` from the repository-wide `oxfmt` scan so imported
GitBook Markdown retains its established formatting; generator tests and
stale-output checks still validate the MCP page.
- Exclude `transcripts/` and GitHub Discussions from the migration.

## Todo

- [x] Import documentation, navigation, includes, and assets under
`/docs`.
- [x] Generate the MCP page from the local CLI source.
- [x] Move MCP generation and validation into Builder.
- [x] Require MCP documentation updates alongside CLI changes.
- [x] Publish released revisions through a read-only `docs` branch.
- [x] Remove Community repository links from Builder and the migrated
docs.
- [x] Preserve and verify a final Community Git bundle locally.
- [ ] Merge this pull request.
- [ ] Let the next successful release create or advance the `docs`
branch.
- [ ] Repoint GitBook Git Sync to `webstudio-is/webstudio`, branch
`docs`, root directory `/docs`.
- [ ] Verify `docs.webstudio.is`, navigation, assets, anchors, and the
MCP page in production.
- [ ] Delete `webstudio-is/webstudio-community`.

## Verification

- `pnpm check:generated-docs`
- `pnpm lint`
- `pnpm oxfmt --check`
- `git diff --check origin/main...HEAD`
- generator regression test demonstrated failing when the GitBook
wrapper behavior was removed, then passing after restoration
- no fixture inputs or outputs are affected

## Known limitation

All documentation merged after the previous release waits for the next
successful release before GitBook publishes it. This deliberately keeps
the public MCP reference aligned with an installable CLI revision.

Ref #5986
2026-08-03 17:55:50 +02:00

7.9 KiB
Raw Blame History

description
description
Webstudio's Command Line Interface (CLI) allows you to interact directly with your Projects from the command line.

⬛ CLI

Webstudio's CLI lets you work with Projects from the command line. You can export and build a Project, publish and manage domains, inspect Project permissions, capture screenshots, and expose the configured Project to automation tools through MCP.

For self-hosting, the CLI can export your entire Webstudio Project. Once exported, these projects are ready to be deployed on any hosting platform of your choice - giving you complete freedom over where and how your website goes live.

Quick setup

The current Webstudio CLI package is webstudio. Run it with npx; do not install it globally or create a permanent webstudio command unless you intentionally need that. Do not use the old @webstudio-is/cli package or the old wstd command.

Use this page as the source of truth for the CLI package. Do not infer the package name or command from local repositories, old README files, or older examples.

First, check whether Node.js and npm are already installed:

node --version
npm --version

If node is version 22 or greater and npm prints a version, skip Node.js installation. If either command is missing, install Node.js 22 or greater before using the Webstudio CLI.

Run the latest Webstudio CLI without a global install:

npx --yes webstudio@latest --version

No separate Webstudio CLI installation is required when using npx. After verifying the latest CLI with npx --yes webstudio@latest, you can use the shorter npx webstudio command in the same environment.

For the latest version regardless of any existing global install, use npx --yes webstudio@latest.

How to run Webstudio commands

Examples on this page use the no-install npx webstudio command:

npx webstudio <command> [options]

Use one of these command formats:

Setup Command format
Latest one-off run, all OSs npx --yes webstudio@latest <command> [options]
After verifying latest npx webstudio <command> [options]

Running with npx does not install a permanent webstudio command. Continue using npx webstudio for normal usage.

Use npx webstudio --help for the current command list.

How to update the CLI

The recommended npx setup does not install a permanent copy of the Webstudio CLI, so there is no separate update command. Run the latest published version explicitly:

npx --yes webstudio@latest --version

Then use @latest with any command when you need to guarantee that run uses the newest release:

npx --yes webstudio@latest <command> [options]

This updates the CLI used by npx; it does not modify your linked Project or its .webstudio files until you run a command that does so. If you previously installed webstudio globally, remove that installation to avoid invoking an older permanent command:

npm uninstall --global webstudio

First use

To use the CLI with a Project, you need an existing Webstudio Project and a Builder share link with Build access. Create the share link from the Share dialog in the Builder.

Run the guided flow:

npx webstudio

Or link a Project non-interactively:

npx webstudio link --link "<share-link-with-build-access>"

Publish the Project in Webstudio Cloud before syncing when you need recent Builder changes in the local export.

Install Node.js only when needed

You need Node.js 22 or greater to use the Webstudio CLI. If node --version reports version 22 or greater, skip this section.

On macOS or Linux, you can install Node.js with NVM. First check whether NVM already exists:

command -v nvm

If nvm is not found, install it:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

After installing NVM, restart your terminal. If nvm is still not found, source your shell profile and try again.

Once NVM is installed, you can install Node.js version 22 or greater by running:

nvm install 22

Verify your Node.js installation by checking its version:

node --version

On Windows, install Node.js 22 or greater from nodejs.org or use a Windows-compatible Node version manager. After installing Node.js, open a new terminal and verify:

node --version
npm --version

How the CLI connects to a Project

Most CLI commands operate on the single Project configured in the current directory.

  • .webstudio/config.json stores the Project ID.
  • The global Webstudio config stores the origin and share-link token.
  • npx webstudio sync downloads the Project bundle to .webstudio/data.json.
  • Synced asset files are stored in .webstudio/assets.

You can configure a Project interactively:

npx webstudio link

Or pass a share link directly:

npx webstudio link --link "<share-link>"

For automation, use init with JSON output:

npx webstudio init --link "<share-link>" --json

The share link should include Build access when you need to sync, build, import, or automate Project changes.

Export and build a Project

After linking, publish the Project in Webstudio Cloud, then sync it locally:

npx webstudio sync

Build a dynamic app with a deployment template:

npx webstudio build --template docker

{% hint style="info" %} See export types for more information about JavaScript applications vs. static sites. {% endhint %}

The CLI scaffolds the application, creates its routes and pages, and downloads assets. In the generated project, install dependencies and use the scripts in its package.json to develop or create a production build.

Build a static site with:

npx webstudio build --template ssg

Please review the limitations of using the static site export instead of dynamic templates.

Other workflows

The CLI can also:

  • Import a synced Project into another Project.
  • Preview an export and capture screenshots.
  • Publish, unpublish, and inspect publishing jobs.
  • Manage and verify custom domains.
  • Audit accessibility, security, SEO, and performance settings.
  • Expose a Project to AI agents and other automation through MCP.

Use the built-in help for current commands and options:

npx webstudio --help
npx webstudio <command> --help

Automation and MCP

Webstudio MCP lets agents inspect and edit the native visual-builder model so their changes remain editable in the Builder. After linking a Project, shell-capable agents can call MCP tools directly without configuring or restarting an MCP client:

npx webstudio meta.index
npx webstudio insert-fragment '{"parentInstanceId":"<parent-id>","fragment":"<ws.element ws:tag=\"section\" />"}' --dry-run

The explicit equivalent is npx webstudio mcp single-op-call <tool> '<json>'. To keep Webstudio tools available inside a supported client, generate its persistent configuration:

npx webstudio connect claude
npx webstudio connect codex
npx webstudio connect cursor
npx webstudio connect vscode

See Webstudio MCP for the exhaustive, versioned setup, discovery, editing, verification, safety, and troubleshooting reference generated from the latest published CLI manual.