CLI commands
Check local DTCG sources, build output files, compare changes, and inspect tokens.
The CLI requires Node.js 24 or newer. Add it as a development dependency:
pnpm add -D @primitree/cli@nextBinary name: primitree.
Commands
| Command | Purpose |
|---|---|
build | Check a source and write DTCG, Resolver, CSS, Tailwind, and TS files |
diff | Compare configured DTCG files or Figma exports |
check | Check a configured DTCG source or an older input |
inspect | Explain one token from a configured source |
init | Create a token repository with sample data |
export | Download variables through the Figma REST API |
pnpm exec primitree <command> --helpTypical workflow
Add a local DTCG file and primitree.config.ts. The config names the source,
its layers, owners, and output files. This example uses the brand source from
Getting started.
pnpm exec primitree check --source brand
pnpm exec primitree inspect semantic.motion.control --source brand
cp tokens.json before.tokens.jsonChange base.motion.quick.$value.value in tokens.json from 0.2 to 0.3.
Compare the files and build the output:
pnpm exec primitree diff before.tokens.json tokens.json --source brand
pnpm exec primitree build --source brand
pnpm exec primitree build --source brand --checkcheck reports source findings. inspect shows one resolved token and its
alias chain. diff compares the saved file with the edited file. build
writes the configured files. build --check reports generated-file changes
without writing.
build
Generate the configured files
diff
Review token changes
check
Validate before merge
inspect
Explain one token
init
Start a tokens repo
export
Enterprise REST download
Figma variables export
The older commands remain available for Figma variables exports. Build an
export with pnpm exec primitree build variables.json. See
primitree build for its output options. Figma REST access
requires access to the Figma file, a Figma Enterprise seat, and a Personal
Access Token with file_variables:read. Set the token in FIGMA_TOKEN or
FIGMA_PAT, and set the file key in FIGMA_FILE_KEY. Run
pnpm exec primitree export.