Closes #5727 Copy a design token from its menu and paste it into another project or the style source input. Paste creates and attaches a new numbered token (for example, `Button copy 1`). It carries all breakpoint styles, referenced CSS variables, images, and fonts, and creates missing breakpoints. MCP offers the same copy and paste commands; `instanceId` attaches the token when supplied. The clipboard format is CSS with one `@webstudio/token-css/v1` comment. The old JSON format is removed. HTML and CSS use the same Webstudio pragma parser, and token CSS reuses the existing CSS declaration parser. Builder and MCP share token copy, parsing, paste, fragment asset import, and asset reference remapping. The latest cleanup also reuses the existing copy-name helper. Repeated Builder pastes reuse the existing content-hash asset deduplication path, including SVG and fonts. The source bytes still download and hash on each paste. MCP downloads and uploads asset bytes on each paste, using the upload path's deduplication; both projects must use the same Webstudio origin for assets. - [x] Implement CSS token copy and paste in Builder and MCP, including selection attachment and numbered names. - [x] Preserve breakpoint styles, variable dependencies, image and font assets, and missing breakpoints. - [x] Detect token CSS pasted into the style source input. - [x] Remove the JSON transfer format and update Builder and MCP documentation. - [x] Reuse CSS parsing, asset transfer, naming, and existing upload deduplication paths. - [x] Resolve review findings, including shorthand variables and selector state positions. - [x] Verify focused tests, typechecks, lint, formatting, package boundaries, and the approved Storybook visual check. - [x] Trace existing CSS editor and HTML paste flows; reuse their parser, declaration mapper, and CSS variable reference collector. - [x] Preserve breakpoint cascade order when copying equal media conditions; add a regression and resolve the review thread. - [x] Share CSS variable traversal between collection and renaming; preserve nested fallbacks and resolve the review comment. - [x] Discover and remap image URLs inside raw variable fallbacks; share the CSS value traversal and resolve the review comment. - [x] Preserve fallback variables in mixed shorthands and custom non-pixel breakpoint styles; add regressions and resolve review threads. - [x] Preserve combined width and custom media conditions in token CSS; add a regression and resolve the review thread. - [x] Preserve range-syntax custom breakpoints in token CSS; add a regression and resolve the review thread. - [x] Preserve negated custom and width media conditions; add regressions and resolve the review thread. - [x] Preserve boolean operators between width conditions; add a regression and resolve the review thread. - [x] Monitor required CI checks for the latest commit. - [x] Reuse the existing asset usage collector for copied token image and font dependencies; verify token and asset usage tests. - [x] Review documentation impact of this internal refactor (none; no user-facing behavior or contract changed). The reuse audit traced CSS editor, HTML paste, instance/page paste, asset usage, and MCP from input to state change. Token copy now uses the existing asset usage collector for image and variable-backed font dependencies. CSS parsing, declaration mapping, variable traversal, breakpoint matching, asset import/remapping, copy naming, and Builder/MCP token mutation also have shared owners. Fragment insertion may reuse tokens and merge overflow breakpoints; token paste must always create a numbered copy and report overflow. The regex-based rename path remains for arbitrary authored text; token transfer uses syntax-aware rewriting to avoid changing text outside `var()`. The asset collector refactor changes no user-facing behavior. The follow-up parser fixes keep fallback variables, non-pixel breakpoint styles, and combined media conditions, range syntax, negation, and width-condition operators intact when copied. No documentation or fixture inputs changed. Focused token, asset usage, HTML, and CSS parser tests, affected typechecks, lint, formatting, package boundaries, and `git diff --check` passed. Agent evaluations were offered and declined.
Webstudio CLI
The Webstudio CLI helps you to link, sync and build projects from Webstudio Cloud. This README will guide you through the process of setting up a Webstudio project on your local machine and continually sync it with the cloud.
Prerequisites: Installing Node.js
You need Node.js to use the Webstudio CLI. If Node.js is already installed in your system, you can skip ahead to the section on installing the Webstudio CLI.
To install Node.js using NVM, first install NVM by running:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Once NVM is installed, you can install Node.js version 22 by running:
nvm install 22
Verify your Node.js installation by checking its version:
node --version
Installing the Webstudio CLI
To get started with the Webstudio CLI:
-
Download and install the CLI using the following command:
npm install -g webstudio@latest -
Confirm the installation by checking the CLI version:
webstudio --version -
To keep your CLI updated, use the same command used for installation whenever a new release is available.
Initiating a Webstudio Project
Now, you can run a Webstudio project on your local machine using this command:
webstudio
This will initiate the flow to connect your Webstudio Cloud project and build it in your local computer. The default flow will guide you through the steps. You can also perform all the operations individually using independent commands.
Commands
Here is the list of independent commands:
- version
- help
- link
- sync
- build
link
The link command stores access to a Webstudio Cloud project. MCP clients use that connection to read and edit the latest Builder build directly; the project does not need to be published or synchronized first.
Shell-capable agents can call MCP tools directly as CLI subcommands immediately after linking. This does not require MCP client configuration or a client restart:
webstudio meta.index
webstudio components.search '{"brief":"button"}'
webstudio insert-fragment --input-file .temp/insert-fragment.json --dry-run
.temp/insert-fragment.json:
{
"parentInstanceId": "<parent-id>",
"fragment": "<section />"
}
The explicit equivalent is webstudio mcp single-op-call <tool> '<json>'.
Use webstudio connect <client> only when you want persistent native MCP tools
inside Claude Code, Codex, Cursor, or VS Code. A persistent client may need to
reconnect after its configuration or cached tool catalog changes.
See the Webstudio MCP documentation for setup, discovery, editing, verification, and safety guidance.
You can link a project from Webstudio Cloud with the following command:
webstudio link
This command will prompt you to paste a link which you can create using the Share option in your project.
Make sure to provide Build access when generating the link in Webstudio Cloud.
sync
Once the project is linked, use the sync command to sync it with the cloud:
webstudio sync
Sync downloads the current saved Builder project and its asset files, then prepares the local content index. Publishing is not required.
Use the export with webstudio build or webstudio import --to "<target-share-link>". Sync is not required for MCP editing.
build
Now, you can build your project with the build command:
webstudio build
During this phase, the CLI establishes the necessary routes and pages, scaffolding the entire application using the default Remix template. Additionally, all assets, such as images and fonts are downloaded to the assets folder inside the public directory.
Once the project is scaffolded, you can run npm install and then npm run dev to run your app in development mode.
If you want to build a production version of the app, you can run npm run build.
Deployment
Vercel
Once you've built the project locally, you can use the Vercel CLI to deploy your project directly to Vercel:
vercel deploy
Follow the instructions here to install the vercel CLI. We plan to add more deployment targets in future.
Netlify
If you want to deploy to netlify, you can use Netlify CLI to deploy your project directly to Netlify:
netlify deploy
You can configure the project to support netlify serverless/edge-functions respectively, as deployment target at the time of initially setting up your project. Please check the initiating-a-webstudio-project section.
You can manually change it using the build command. For serverless functions:
webstudio build --template netlify
Important Notes
If you use vercel build before vercel deploy, make sure to clean your app folder in the project afterward.
Vercel injects a few files to support and deploy Remix using their CLI, but these files are not necessary for your project when you use it locally.