Primitree

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@next

Binary name: primitree.

Commands

CommandPurpose
buildCheck a source and write DTCG, Resolver, CSS, Tailwind, and TS files
diffCompare configured DTCG files or Figma exports
checkCheck a configured DTCG source or an older input
inspectExplain one token from a configured source
initCreate a token repository with sample data
exportDownload variables through the Figma REST API
pnpm exec primitree <command> --help

Typical 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.json

Change 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 --check

check 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.

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.