home / skills / phrazzld / claude-config / brand-compile

brand-compile skill

/skills/brand-compile

This skill compiles brand.yaml into CSS variables, Tailwind theme, and TypeScript tokens to streamline branding across projects.

npx playbooks add skill phrazzld/claude-config --skill brand-compile

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.3 KB
---
name: brand-compile
description: |
  Compile brand.yaml into CSS custom properties, Tailwind 4 theme, and TypeScript tokens.
  Run after modifying brand.yaml or when setting up a new project.
argument-hint: "[--format css|tailwind|ts|all] [--out dir]"
effort: low
---

# /brand-compile

Compile brand tokens from `brand.yaml` into consumable formats.

## What This Does

Reads `brand.yaml` from project root and produces:
- `tokens.css` — CSS custom properties (`:root` + `.dark`)
- `theme.css` — Tailwind 4 `@theme inline` with OKLCH values
- `tokens.ts` — TypeScript const export for Satori templates and Remotion

## Process

1. Locate `brand.yaml` in the current project root
2. If no `brand.yaml` exists, check for `brand-profile.yaml` + `design-tokens.json` and offer to migrate:
   ```bash
   node ~/Development/brand-kit/dist/src/cli.js migrate --profile brand-profile.yaml --tokens design-tokens.json --out brand.yaml
   ```
3. Validate the schema:
   ```bash
   node ~/Development/brand-kit/dist/src/cli.js validate brand.yaml
   ```
4. Compile tokens:
   ```bash
   node ~/Development/brand-kit/dist/src/cli.js compile --out ./src/styles
   ```
5. Verify Tailwind `@theme` import exists in the project's CSS entry point (e.g., `globals.css`)
6. Run typecheck if TypeScript project: `pnpm typecheck` or `npx tsc --noEmit`

## Output

Default output directory: `./brand-output/`
Override with `--out ./src/styles` to place tokens where your project expects them.

```
brand-output/
  tokens.css    # CSS custom properties
  theme.css     # Tailwind 4 @theme inline
  tokens.ts     # TypeScript const export
```

## Format Selection

- `--format css` — Only CSS custom properties
- `--format tailwind` — Only Tailwind 4 theme
- `--format ts` — Only TypeScript tokens
- `--format all` — All three (default)

## Integration

After compiling, import in your project:

**Tailwind 4 (recommended):**
```css
/* globals.css */
@import "tailwindcss";
@import "./theme.css";
```

**Plain CSS:**
```css
@import "./tokens.css";
```

**TypeScript (Satori/Remotion):**
```typescript
import { brand } from "./tokens.js";
```

## Related Skills

- `/brand-init` — Create brand.yaml from scratch
- `/brand-assets` — Generate OG cards and social images
- `/og-card` — Legacy OG card generation (superseded by brand-assets)

Overview

This skill compiles brand.yaml into ready-to-use design tokens for CSS, Tailwind 4, and TypeScript. It streamlines turning a single source-of-truth into CSS custom properties, an inline Tailwind @theme, and a TS export for Satori/Remotion or other runtime usage. Run it after editing brand.yaml or when bootstrapping a new project to keep tokens in sync.

How this skill works

The tool locates brand.yaml at the project root, validates its schema, and emits three artifacts: tokens.css (CSS custom properties with light and .dark scopes), theme.css (Tailwind 4 @theme inline using OKLCH), and tokens.ts (a const export for TypeScript consumers). It can migrate older profiles, run schema validation, and place outputs into a configurable directory via --out.

When to use it

  • After modifying brand.yaml to push color, spacing, or token changes into the project
  • When initializing a new project to generate the base theme and token exports
  • Before committing UI or style updates so TypeScript and CSS consumers match
  • When integrating Tailwind 4 to ensure @theme is available to the CSS entry point
  • When migrating from older brand-profile.yaml + design-tokens.json sources

Best practices

  • Keep brand.yaml as the single source-of-truth and re-run the compiler after edits
  • Add the generated theme.css to your CSS entry (e.g., globals.css) before Tailwind import
  • Commit generated tokens to the repo only if your workflow requires reproducible builds; otherwise add to .gitignore
  • Run schema validation (validate command) as part of CI to catch token regressions
  • Use --out to place artifacts where your project expects them (e.g., ./src/styles)

Example use cases

  • Generate tokens.css and tokens.ts so both the runtime Satori remotion scripts and browser CSS use identical colors
  • Produce theme.css for Tailwind 4 projects to enable design system tokens inside utility classes
  • Migrate an older brand-profile.yaml + design-tokens.json into a single brand.yaml and recompile
  • Add to a CI pipeline: validate brand.yaml, then compile to the deploy artifact directory

FAQ

What if brand.yaml is missing?

The tool will look for brand-profile.yaml and design-tokens.json and offer a migration command to produce brand.yaml.

Can I output only one format?

Yes. Use --format css, --format tailwind, or --format ts to emit a single format. --format all (default) emits all three.