CLI Commands
Complete reference for all TokiForge CLI commands.
init
Initialize TokiForge in your project.
tokiforge initWhat it does
- Creates
tokens.jsonwith default tokens - Creates
tokiforge.config.jsonwith configuration - Sets up project structure
Options
None currently. Run from your project directory.
Example
mkdir my-project
cd my-project
tokiforge initbuild
Build and export tokens to various formats.
tokiforge buildWhat it does
- Reads
tokens.json(or configured input file) - Validates token structure
- Exports to formats specified in
tokiforge.config.json - Outputs to configured directories
Output Formats
- CSS custom properties
- JavaScript modules
- TypeScript modules
- SCSS variables
- JSON
Example
tokiforge build
# Generates files in dist/ directorydev
Start development server with live theme preview.
tokiforge devWhat it does
- Starts local server (default: port 3000)
- Displays interactive theme preview
- Watches for token file changes
- Auto-reloads on changes
Options
None currently. Port is fixed at 3000.
Example
tokiforge dev
# Opens http://localhost:3000lint
Validate token consistency and accessibility.
tokiforge lintWhat it does
- Validates token structure
- Checks for duplicate token names
- Validates color contrast ratios
- Checks for missing references
Exit Codes
0- All checks passed1- Errors found
Example
tokiforge lint
# ✅ All tokens are valid!validate
Validate tokens for CI/CD pipelines with comprehensive checks.
tokiforge validate [options]What it does
- Validates token syntax and structure
- Checks token references
- Validates token format
- Checks for deprecated tokens
- Validates accessibility compliance (WCAG AA/AAA)
- Compares with Figma tokens (optional)
Options
--strict- Treat warnings as errors--no-accessibility- Skip accessibility checks--no-deprecated- Skip deprecation checks--figma- Check against Figma tokens--figma-token <token>- Figma access token--figma-file-key <key>- Figma file key--min-accessibility <level>- Minimum accessibility level (AA or AAA, default: AA)
Exit Codes
0- All checks passed1- Validation failed
Example
# Basic validation
tokiforge validate
# Strict validation with Figma sync check
tokiforge validate --strict --figma --figma-token TOKEN --figma-file-key KEYfigma:diff
Compare Figma tokens with code tokens.
tokiforge figma:diff --token <token> --file-key <key>What it does
- Pulls tokens from Figma
- Compares with local token file
- Generates detailed diff report
- Exports diff as JSON
Required Options
--token <token>- Figma personal access token--file-key <key>- Figma file key
Exit Codes
0- No mismatches found1- Mismatches detected
Example
tokiforge figma:diff --token YOUR_TOKEN --file-key FILE_KEYanalytics
Generate token usage analytics and bundle impact report.
tokiforge analyticsWhat it does
- Analyzes token usage
- Calculates bundle impact
- Identifies unused tokens
- Generates coverage reports
- Estimates token sizes
Output
- Console report with usage statistics
- JSON file:
token-analytics.json
Example
tokiforge analytics
# 📊 Generating token analytics...
# ✅ Analytics saved to: token-analytics.jsongenerate:types
Generate TypeScript type definitions for tokens.
tokiforge generate:types [input] [output]What it does
- Reads tokens from input file
- Generates TypeScript declarations
- Creates token path constants
- Generates type-safe resolver function
Arguments
input- Input tokens file (default:tokens.json)output- Output TypeScript file (default:tokens.d.ts)
Output
.d.tsfile with complete type definitions- Token path exports for autocomplete
- TypeScript utility functions
Example
# Generate types from tokens.json
tokiforge generate:types
# Custom paths
tokiforge generate:types ./design/tokens.json ./src/tokens.d.tsGenerated file:
export const tokens = { /* ... */ };
export type TokenPath = 'colors.primary' | 'colors.secondary' | ...;
export function resolveToken(path: TokenPath): any;watch
Watch token files for changes and regenerate exports.
tokiforge watch [input] [output] [options]What it does
- Monitors token files for changes
- Auto-regenerates exports on change
- Supports debouncing
- Generates TypeScript, JSON, CSS, SCSS
Arguments
input- Input tokens file (default:tokens.json)output- Output directory (default:tokens.generated)
Options
--debounce <ms>- Debounce time in milliseconds (default: 300)
Example
# Watch and generate
tokiforge watch
# Custom paths with faster debounce
tokiforge watch ./tokens.json ./dist --debounce 100Output:
👀 Watching tokens.json for changes...
💾 Output directory: tokens.generated
✅ [12:34:56] Tokens updated
✅ [12:35:01] Tokens updatedmigrate
Migrate tokens from another format.
tokiforge migrate [input] [options]What it does
- Converts tokens from Style Dictionary, Figma Tokens, or Theo format
- Normalizes token structure
- Validates migration
- Creates backup automatically
Arguments
input- Input tokens file (default:tokens.json)
Options
--from <format>- Source format:style-dictionary,figma-tokens,theo(default:style-dictionary)--to <file>- Output file (defaults to input file)--no-backup- Skip creating backup
Supported Formats
From Style Dictionary:
{
"color": {
"primary": { "value": "#007AFF", "type": "color" }
}
}From Figma Tokens:
{
"colors": {
"primary": { "value": "#007AFF", "type": "color" }
}
}From Theo:
{
"global": {
"color": {
"primary": { "value": "#007AFF", "type": "color" }
}
}
}Example
# Migrate from Style Dictionary
tokiforge migrate tokens.json --from style-dictionary
# Migrate from Figma Tokens to new file
tokiforge migrate figma-tokens.json --from figma-tokens --to tokens.json
# Migrate without backup
tokiforge migrate design-tokens.json --from theo --no-backupdiff
Compare two token files with visual diff, change summary, and migration suggestions.
tokiforge diff <old-file> <new-file> [options]What it does
- Compares token files
- Shows detailed differences
- Generates migration suggestions
- Detects breaking changes
- Exports reports in multiple formats
Options
--format <type>- Output format:compact,detailed,json(default:detailed)--no-migrations- Skip migration suggestions--strict- Fail on breaking changes--output <file>- Write report to file
Exit Codes
0- No changes or non-breaking changes1- Breaking changes detected (in strict mode)
Example
# Basic comparison
tokiforge diff old-tokens.json new-tokens.json
# Compact output
tokiforge diff old-tokens.json new-tokens.json --format compact
# With migration suggestions and output file
tokiforge diff old-tokens.json new-tokens.json --output diff-report.md
# Strict mode (fail on breaking changes)
tokiforge diff old-tokens.json new-tokens.json --strictSee Also
For complete documentation, see diff command
generate:changelog
Generate token changelogs from versioned token files.
tokiforge generate:changelog [input] [options]What it does
- Scans directory for versioned token files
- Compares versions sequentially
- Detects breaking changes
- Categorizes modifications
- Generates formatted changelogs
Options
--format <type>- Output format:markdown,json,html(default:markdown)--output <file>- Write changelog to file
Supported Version Formats
tokens-v1.0.0.jsontokens-1.0.0.jsontokens-v1.1.0.json
Exit Codes
0- Changelog generated successfully1- Error occurred
Example
# Generate markdown changelog
tokiforge generate:changelog tokens
# Generate JSON format
tokiforge generate:changelog tokens --format json
# Save to file
tokiforge generate:changelog tokens --output CHANGELOG.md
# Generate HTML for web viewing
tokiforge generate:changelog tokens --format html --output CHANGELOG.htmlSee Also
For complete documentation, see generate:changelog command
Global Options
All commands support:
-V, --version- Show version-h, --help- Show help
Next Steps
- See Configuration for setup options
- Check Overview for workflow