Skip to content
Dessert-LabsPublic

About

Clafoutis, a gitops powered design system generator

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Clafoutis

GitOps-powered design token generation and distribution.

The Problem

Design tokens get out of sync. A designer updates the primary color in Figma, but three weeks later the React app still has the old blue. The marketing site has a different shade entirely. Nobody knows which version is "correct."

Without Clafoutis:

Designer updates Figma → exports JSON → emails developer → 
developer copies values → commits to repo A → forgets repo B →
repos drift apart → Figma has different values than code →
"why does the button look different?"

With Clafoutis:

Update tokens in Git → PR merged → GitHub Release created →
all consuming repos sync the same version →
Figma variables regenerated from the same source →
design and code stay in sync

How It Works

Producers (design system maintainers) define tokens in JSON and publish via GitHub Releases:

npx @clafoutis/cli init --producer
# Edit tokens/colors/primitives.json
git push  # GitHub Action runs generate and creates release automatically

The default workflow generates build/, commits updated build/** back to the repository, and creates a GitHub Release. If you opted out of the GitHub workflow during init, run npx @clafoutis/cli generate locally before pushing.

Consumers (application developers) pin to a version and sync:

npx @clafoutis/cli init --consumer --repo Acme/design-system
npx @clafoutis/cli sync
git commit -m "chore: sync design tokens v1.2.0"

Tokens are committed to your repo. No runtime dependencies. No build-time network requests. Just static files under version control.

Why This Approach?

Pain Point How Clafoutis Solves It
"Which Figma file has the latest tokens?" Single source of truth in a Git repo with tagged releases
"Our CI build failed because the token CDN was down" Tokens are committed locally - no network needed at build time
"We updated tokens and broke three apps" Pin to specific versions, update each app on its own schedule
"How do I know what changed between v1.0 and v2.0?" Standard Git diff - tokens are just JSON files
"Setting up Style Dictionary is complicated" Built-in generators for Tailwind and Figma, or bring your own

Quick Start

Installation

npm install -D @clafoutis/cli

For Producers (Design System Teams)

# Initialize with interactive wizard
npx @clafoutis/cli init --producer

# Or non-interactive for CI
npx @clafoutis/cli init --producer --generators=tailwind,figma --non-interactive

This creates:

  • .clafoutis/producer.json - configuration
  • tokens/ - starter token templates (colors, spacing, typography)
  • .github/workflows/clafoutis-release.yml - auto-release on push

Edit your tokens, push to main, and a GitHub Release is created automatically.

For Consumers (Application Teams)

# Initialize
npx @clafoutis/cli init --consumer --repo Acme/design-system

# Sync tokens from the latest release
npx @clafoutis/cli sync

# Commit the synced files
git add .clafoutis/ src/tokens/
git commit -m "chore: sync design tokens"

Updating Tokens

# Check available versions
gh release list -R Acme/design-system

# Update .clafoutis/consumer.json to new version
# Then sync
npx @clafoutis/cli sync

Configuration

Producer (.clafoutis/producer.json)

{
  "tokens": "./tokens",
  "output": "./build",
  "generators": {
    "tailwind": true,
    "figma": true
  }
}

Consumer (.clafoutis/consumer.json)

{
  "repo": "Acme/design-system",
  "version": "v1.2.0",
  "files": {
    "tailwind.base.css": "src/styles/tokens.css",
    "tailwind.config.js": "./tailwind.config.js"
  }
}

Use "version": "latest" during development to always get the newest release. Pin to a specific tag (e.g., "v1.2.0") for production stability.

CLI Reference

clafoutis init

Initialize configuration with an interactive wizard, or use flags for CI:

npx @clafoutis/cli init --producer              # Interactive producer setup
npx @clafoutis/cli init --consumer --repo X/Y   # Interactive consumer setup
npx @clafoutis/cli init --producer --cwd ./packages/design-system
npx @clafoutis/cli init --non-interactive       # Skip prompts, use flags/defaults
npx @clafoutis/cli init --dry-run               # Preview without writing files

clafoutis generate

Transform tokens into platform-specific outputs:

npx @clafoutis/cli generate                     # Use config file
npx @clafoutis/cli generate --tailwind --figma  # Specify generators
npx @clafoutis/cli generate --cwd ./packages/design-system
npx @clafoutis/cli generate --dry-run           # Preview output

clafoutis sync

Download tokens from a GitHub Release:

npx @clafoutis/cli sync                         # Sync if version changed
npx @clafoutis/cli sync --force                 # Re-sync even if cached
npx @clafoutis/cli sync --cwd ./apps/web
npx @clafoutis/cli sync --dry-run               # Preview what would sync

Monorepo Usage

Use --cwd <path> on all CLI commands when running from a monorepo root:

npx @clafoutis/cli init --producer --cwd ./packages/design-system
npx @clafoutis/cli generate --cwd ./packages/design-system
npx @clafoutis/cli format --cwd ./packages/design-system
npx @clafoutis/cli sync --cwd ./apps/web

All relative paths in config/options are resolved from the provided --cwd. Producer output remains ./build by default.

Custom Generators

Create platform-specific generators when the built-ins don't fit:

{
  "generators": {
    "tailwind": true,
    "brand-scss": "./generators/brand-scss.ts"
  }
}
// generators/brand-scss.ts
import type { GeneratorPlugin } from '@clafoutis/cli';

export const generate: GeneratorPlugin = async ({ tokensDir, outputDir, StyleDictionary }) => {
  const sd = new StyleDictionary({
    source: [`${tokensDir}/**/*.json`],
    platforms: {
      scss: {
        transformGroup: 'scss',
        buildPath: `${outputDir}/`,
        files: [{ destination: '_brand.scss', format: 'scss/variables' }],
      },
    },
  });
  await sd.buildAllPlatforms();
};

Private Repositories

Set CLAFOUTIS_REPO_TOKEN with a GitHub PAT that has repo scope:

export CLAFOUTIS_REPO_TOKEN=ghp_xxxx
npx @clafoutis/cli sync

In CI:

- run: npx @clafoutis/cli sync
  env:
    CLAFOUTIS_REPO_TOKEN: ${{ secrets.DESIGN_SYSTEM_TOKEN }}

Token Format

Clafoutis uses the Design Tokens Community Group (DTCG) specification:

{
  "color": {
    "primary": {
      "$type": "color",
      "$value": "#3b82f6"
    }
  },
  "spacing": {
    "sm": {
      "$type": "dimension",
      "$value": "8px"
    }
  }
}

Documentation

Development

make init       # Install dependencies
make build-all  # Build all packages
make check-all  # Lint, format, type-check
make test-all   # Run tests

License

BUSL-1.1

About

Clafoutis, a gitops powered design system generator

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages