home / skills / harborgrid-justin / lexiflow-premium / design-system-token-architecture
/frontend/.github-skills/design-system-token-architecture
This skill helps architect scalable design token propagation using React Context and CSS-in-JS, enabling dynamic theming and efficient token updates.
npx playbooks add skill harborgrid-justin/lexiflow-premium --skill design-system-token-architectureReview the files below or copy the command above to add this skill to your agents.
---
name: design-system-token-architecture
description: Architect scalable design token propagation using React Context and CSS-in-JS/Variables.
---
# Design System Token Architecture
## Summary
Architect scalable design token propagation using React Context and CSS-in-JS/Variables.
## Key Capabilities
- Define semantic token layers (Primitive vs. Component).
- Implement dynamic theming with runtime token switching.
- Optimization re-renders when swapping global themes.
## PhD-Level Challenges
- Manage type-safety for deeply nested token schemas.
- Analyze the performance cost of CSS generation at runtime.
- Synchronize token updates across micro-frontends.
## Acceptance Criteria
- Demonstrate a multi-theme switching capability.
- Provide a token schema definition file.
- Benchmark theme switch render cost.
This skill architects a scalable design token propagation strategy for React apps using Context plus CSS-in-JS and CSS variables. It focuses on clear token layering (primitive vs component), runtime theme switching, and minimizing re-renders during global theme updates. The goal is a predictable, type-safe token system suitable for single apps and micro-frontends.
The skill defines a token schema and separates primitive tokens (colors, spacing, type) from component-level tokens derived from them. A ThemeProvider exposes tokens via React Context and also writes CSS variables to a top-level element so CSS-in-JS and plain styles can consume them. It includes runtime theme switching that updates Context values and CSS variables with minimal React re-renders, plus tools to benchmark rendering cost.
Can this work without CSS-in-JS?
Yes. The approach writes CSS variables to a root element so plain CSS or preprocessor outputs read the same tokens.
How do you avoid excessive re-renders on theme switch?
Limit Context consumers, memoize derived tokens, and update CSS variables directly for style-only changes to avoid React tree updates.