Skip to content

CLI Commands

Complete reference for all grimorio CLI commands.

init

Scaffolds the configuration file, specs directory, and an example tokens file.

bash
grimorio init

Creates:

  • grimorio.config.ts -- project configuration
  • specs/ -- directory for component specs
  • tokens.json -- default token set (13 W3C DTCG categories)

spec:infer

Analyzes a component file and generates a JSON spec from it using static analysis.

bash
grimorio spec:infer <file>

Examples:

bash
grimorio spec:infer src/components/Button.tsx
grimorio spec:infer src/components/Modal.vue -o specs/modal.json

Extracts: props, variants (cva), accessibility attributes, Tailwind classes, and dependencies.

OptionDescription
--output, -oOutput path for the spec file

add

Creates a component spec. If the name matches a built-in preset, generates a complete spec. Otherwise, creates an improved skeleton with accessibility defaults.

bash
grimorio add <name>

Examples:

bash
grimorio add Button                         # uses built-in preset
grimorio add Select -d "Country picker"     # preset + custom description
grimorio add CustomWidget                   # improved skeleton
grimorio add Dialog -p dialog               # explicit preset
grimorio add --list-presets                  # list available presets

Built-in presets: button, input, select, checkbox, dialog, card, avatar, badge, tabs, textarea.

OptionDescription
--preset, -pUse a specific preset
--description, -dComponent description
--category, -cComponent category
--list-presetsList available presets and exit

validate

Validates all components against their specs and design tokens.

bash
grimorio validate

Examples:

bash
grimorio validate
grimorio validate --level strict
grimorio validate --watch
grimorio validate --watch --level strict
OptionDescription
--levelValidation level: basic, standard (default), or strict
--watchRe-validate on file changes (300ms debounce)

Validation levels:

LevelChecks
basicRequired props
standard+ variants, hardcoded token values, ARIA attributes
strict+ extra props/variants, anatomy parts, all keyboard interactions

Exits with code 1 if any validation errors are found.


figma:import

Imports component specs from Figma. Maps Figma component properties to props, variants, slots, token mappings, anatomy, states, and events deterministically.

bash
grimorio figma:import <url>

Examples:

bash
grimorio figma:import "https://figma.com/design/ABC/..." --component Button
grimorio figma:import "https://figma.com/design/ABC/..."
grimorio figma:import "https://figma.com/design/ABC/...?node-id=1-234"
OptionDescription
--componentComponent name to find in the file
--tokenFigma API token (or set FIGMA_TOKEN env var)
--output, -oOutput path for the spec

Mapping rules:

Figma propertySpec field
VARIANTvariants + props
BOOLEANprops (boolean)
TEXTprops (string)
INSTANCE_SWAPslots
Bound variablestokenMapping

figma:validate

Validates a Figma component against an existing spec. Reports differences in props, variants, token mappings, slots, anatomy, states, and events.

bash
grimorio figma:validate <url>

Examples:

bash
grimorio figma:validate "https://figma.com/design/ABC/..." --component Button
grimorio figma:validate "https://figma.com/design/ABC/..." --component Button --json
OptionDescription
--componentComponent name to validate
--tokenFigma API token (or set FIGMA_TOKEN env var)
--jsonOutput as JSON

Exits with code 1 if differences are found.


tokens:list

Lists design tokens from your tokens file.

bash
grimorio tokens:list

Examples:

bash
grimorio tokens:list                    # tree view (default)
grimorio tokens:list --flat             # flat list with full paths
grimorio tokens:list --type color       # filter by $type
grimorio tokens:list --json             # output as JSON
grimorio tokens:list --json --flat      # flat JSON
grimorio tokens:list --theme dark       # list a specific theme
OptionDescription
--flatShow flat list instead of tree
--typeFilter by $type (e.g., color, dimension)
--jsonOutput as JSON
--themeTheme to list (multi-theme configs)

tokens:validate

Validates tokens against the W3C DTCG schema and cross-references with component specs.

bash
grimorio tokens:validate

Examples:

bash
grimorio tokens:validate
grimorio tokens:validate --watch
OptionDescription
--watchRe-validate on file changes (300ms debounce)

Checks performed:

  1. Schema validation -- validates against TokenFileSchema
  2. Statistics -- counts tokens by $type, reports deprecated tokens
  3. Cross-reference -- missing (error), deprecated used (warning), orphans (info)

Exits with code 1 if schema errors or missing tokens are found. Multi-theme configs validate all themes.


tokens:export

Exports design tokens to CSS, SCSS, JS, or Tailwind format.

bash
grimorio tokens:export <format>

Examples:

bash
grimorio tokens:export css
grimorio tokens:export scss --prefix ds
grimorio tokens:export js --no-descriptions
grimorio tokens:export tailwind -o tailwind.tokens.js
grimorio tokens:export css --theme dark
OptionDescription
--output, -oOutput file path (default: stdout)
--prefixPrefix for CSS/SCSS variable names
--no-descriptionsOmit description comments
--themeExport a specific theme

Formats:

FormatOutputExample
cssCSS custom properties in :root {}--color-primary: #3b82f6;
scssSCSS variables$color-primary: #3b82f6;
jsES module exportsexport const colorPrimary = "...";
tailwindTailwind theme.extend configcolors: { primary: "..." }

mcp:serve

Starts an MCP server over stdio for AI assistant integration.

bash
grimorio mcp:serve

Exposes 16 tools, 4 prompts, and 2 resources. See MCP Server for details and client configuration.