add writes your design system into an existing React app: the theme into the global stylesheet, the kit's components under the app's components/ui, the cn helper in lib/utils.ts, the libraries those components import, and the /design-system section that shows them. Run it again to pull updates.
How to use it
npx designsource add [names…] [--all] [--yes] [--force] [--skip-install] [--blocks] [--no-blocks] [--no-rules] [--screen <name>|all|shell|site] [--token <project token>] [--api <origin>]Run it in the app's folder. It needs React 19 and TypeScript and stops with one line otherwise. On a first run it asks Add which components? (All, or Pick some… as a comma-separated list), then for the project token unless it already has a way in (see --token below), then names each setup step as it runs.
| Flag | Does |
|---|---|
names… |
Only these components, plus the kit files they import. |
--all |
Every component, no question. |
--yes |
No questions, also outside a terminal: all components on a first run, your edits kept. It never reads a token from stdin, so a coding agent passes it. |
--force |
Replace component files add did not write, and ones you edited. |
--skip-install |
Write the files, then print the install command instead of running it. |
--blocks |
Add the blocks and their libraries to a /design-system section written without them. Not together with --no-blocks. |
--no-blocks |
The /design-system section without its blocks and their libraries. |
--no-rules |
Leave AGENTS.md and CLAUDE.md alone this run. |
--screen |
Screens from DS source, by file name (repeatable, or comma-separated); all for every one; shell for a sidebar app shell listing the screens in the app; site for a menu and footer listing the marketing pages in the app. Pages (home, features, pricing, about, contact, waitlist) are pulled by name like screens. |
--token |
The project token, or set DS_SYNC_TOKEN in the shell profile or a CI secret store. Never type either into a command an agent runs: it lands in the transcript. Else the one connect saved for this folder, else your login sign-in when this folder is linked to a design system; only then is the token asked for. |
--api |
Another server (a local one, staging). |
Outside a terminal with no token found, add stops with the no-design-system line on CLI errors; see For coding agents.
A rerun with no names refreshes the theme and every component add wrote before; add <names…> adds more; --all adds everything.
How it works
Setup. What the app lacks is added first, one printed line per step: Tailwind v4 (through PostCSS, or the Vite plugin), an older Tailwind upgraded with Tailwind's own tool (which refuses a git tree with uncommitted changes), the @/ alias, and components.json. An app on shadcn keeps its components.json; paths and aliases follow it. An app not on shadcn keeps an existing lib/utils.ts, which then has to export cn.
The theme sits between designsource:theme markers in the global stylesheet, with font imports above. In a shadcn app it replaces the :root, .dark and @theme inline blocks shadcn wrote, keeping variables of yours the theme does not define in a block after it. An app that was not on Tailwind gets no page-wide reset, only the theme, the utilities and a reset scoped to the kit's own elements. If a later rule of yours still sets a theme variable, yours wins and add prints that line.
Libraries are installed only when a written component imports them, with the app's own package manager. One already present at the same major keeps your version; at a different major it is left alone and the components needing it are skipped, with a line saying which.
Reruns and edits. Each written file's first line is // designsource: <name> <hash>. A rerun refreshes a file whose body still matches; a file you edited is kept by default (Keep your edits to …?, Enter keeps) and named at the end; --force replaces it. A file designsource did not write, a stock shadcn component say, is replaced only on a yes or with --force; a no changes nothing.
Edited screen files. A screen you edited is kept, and one whose shared part you edited while the kit changed it is skipped until --force; see Pulling screens into an app.
The /design-system section comes with the full kit: a first run answered All, --all, --yes, a run outside a terminal, or a bare rerun in an app that already holds every component. It is your component gallery, blocks and sample pages inside your app, with its own copy of the theme and its own light and dark switch. In a Next.js app (App Router) it is a route folder, app/design-system/; in a Vite app its own page, design-system.html, listed among vite.config's build inputs. add <names…> and Pick some… write no section. Blocks follow what is on disk: a --no-blocks run's choice is not undone by a bare rerun, and --no-blocks on blocks already there leaves them and says how many. add --blocks adds them to a section that has none, installing their libraries; a block library your app holds on another major skips the section with a line, as for any other library.
Rules for coding agents. add keeps a short block of rules (use the kit, never hardcode colours, refresh with add, run check) in the app's AGENTS.md between designsource:rules markers, leaving the rest of the file as it was. With no CLAUDE.md it writes one line, @AGENTS.md, for Claude Code. An edited block is kept; a deleted one comes back unless the file says <!-- designsource:rules:off -->.
All files go down in one write, so one rollback covers them; the install runs last.
Screens
--screen <name> pulls a screen made in the workbench into <components>/screens/ as ordinary code, and --screen all pulls every one. It needs Pro. Rerunning add refreshes the screens already there and keeps the ones you edited. See Pulling screens into an app.
What can go wrong
This folder has no React app. Run this in your React app's folder. DS source supports React apps only for now.Vue, Svelte, Angular and plain CSS are not supported yet.The UI kit needs React 19 — this app is on React 18.React 18 is not supported: upgrade the app to React 19 first.- A failed install leaves the files in place and names the command that finishes it.
This Next.js app uses the Pages Router; the /design-system section needs the App Router, so it was skipped.The components are still written.- A
vite.configthataddcannot edit safely, or an app with its own/design-systemroute, gets a line and no section.
Related
- The UI kit in your app, from the app's side.
- For coding agents: running
addfrom an agent. - Components and slots: what each component reads.
- CLI errors.