design-RFC-005 — Figma kit + token sync pipeline
Evaluates 3 mechanisms for keeping a Koder Design Figma kit in lockstep with ratified Verge tokens (Tokens Studio plugin vs Specify CLI vs custom Figma plugin reading from `dist/tokens/tokens.json`). Recommendation: custom plugin v0 consuming the already-emitted `tokens.json` (per design-gen #059).
designRFC005 — Figma kit + token sync pipeline
*tatus* v0.1.0 — Draft. Decision required to unblock Figma kit v0 (sample: Button + Card + Empty State per ticket #157).
R1 — Problem
KDS today has no official Figma kit. Designers work from:
- Screenshots of
kds.koder.dev. - Hand-rebuilt components in their own Figma files.
- Color tokens copied by eye from the Verge token table.
Result: structural drift between Figma designs and production code. Every release lands with "the prototype showed #1a2762, but production ships #1f3a93" surprises.
A Figma kit (per ticket #157) needs a sync mechanism so token changes in internal/kinds/verge.go propagate automatically to the Figma side, not in a separate manual step.
R2 — Options evaluated
Option A — Tokens Studio plugin (formerly Figma Tokens)
Most popular Figma token-sync plugin. Reads / writes JSON in the Tokens Studio Format. Sync via GitHub URL or local file.
*ros*
- Mature, well-known, large community.
- Designers can edit tokens IN Figma, push back to Git.
- Plugin handles token-set composition (light / dark / responsive).
*ons*
- Token format is NOT DTCG-spec — slight transformation needed
from our DTCG-aligned
dist/tokens/tokens.json. - Two
way sync invites designerside edits to conflict with code-side edits; conflict resolution is manual.
- Adds a third
party dependency to the designside toolchain (eachdesigner installs the plugin).
Option B — Specify CLI
Token-sync CLI tool that pulls from Git / GitHub and pushes to Figma via the Figma REST API. One-way: code → Figma.
*ros*
- One-way sync matches the intended direction (code is source of
truth; Figma reflects).
- No designer-side plugin required.
- DTCG-spec native.
*ons*
- SaaS — Specify hosts the sync runner (conflicts with
policies/self-hosted-first.kmdG1). - Free tier limits; commercial pricing for larger teams.
- Adds a third
partycontrolled step in the release pipeline.
Option C — Custom Figma plugin reading from dist/tokens/tokens.json
Build a small Figma plugin (~200 lines TypeScript) that fetches https://kds.koder.dev/api/v1/tokens.json on open, applies the colors / fonts as Figma local styles (color styles + text styles).
*ros*
- Zero external SaaS — fetches from kds.koder.dev which we own.
- 100% self
hosted; aligns with `policies/selfhosted-first.kmd`. - Reuses the already
emittedgen #059).tokens.json(design - One-way enforcement (Figma reflects code; designer can't drift
without intentional override).
- Plugin can be published to the Figma Community for any designer to
install.
*ons*
- Need to author + maintain the plugin (TypeScript + Figma API).
- Designers can't propose token changes from Figma — they raise a
spec PR in
internal/kinds/verge.golike everyone else (arguably a feature: token changes are governance events, not designer-led). - Initial dev cost ~3 days; ongoing maintenance light.
R3 — Decision criteria (per policies/self-hosted-first.kmd)
| Gate | A (Tokens Studio) | B (Specify) | C (Custom plugin) |
|---|---|---|---|
| G1 — own infra | ⚠ third-party plugin per designer | ❌ SaaS-hosted runner | ✅ |
| G2 — own toolchain | ⚠ designer-side install | ⚠ CLI in pipeline | ✅ |
| G3 — parity threshold | reaches parity when adopted | reaches parity when adopted | reaches parity at v0 of plugin |
| G4 — faster than alt | requires roundtrip syncs | similar | direct fetch — fastest |
| G5 — owner approval | TBD | TBD | TBD |
R4 — Recommendation
*dopt Option C (custom Figma plugin)*for v0.
Rationale:
- The token export pipeline already exists (
dist/tokens/tokens.jsonper design-gen #059). The plugin is the missing piece.
- One-way enforcement is the right direction philosophically — token
changes are governance events ratified in
verge.kmd, not designer- side experiments. - Self
hostedfirst gates favor C cleanly. - Re-evaluation if designer experience plateaus — promotion to
Tokens Studio (Option A) is a reversible follow-up if designers demand in-Figma token editing.
R5 — Implementation tickets
Sub-tickets to open after ratification (in a new tools/figma-bridge/ module under tools/ or as part of design-gen):
tools/figma-bridge#001— Plugin scaffolding (manifest.json,TypeScript build, Figma plugin API setup).
tools/figma-bridge#002— Token-fetch loop (fetch tokens.json onplugin open + on user-click "Sync Tokens").
tools/figma-bridge#003— Color-styles writer (creates Figma localstyles for each Verge color token).
tools/figma-bridge#004— Text-styles writer (Verge typographyroles → Figma text styles using Inter + JetBrains Mono families).
tools/figma-bridge#005— Drift detector (compares current Figmastyles to fetched tokens; flags drift in a side-panel).
tools/figma-bridge#006— CI gate: workflow that fails thekoder-stack release wave if Figma kit token export drifts from
tokens.jsonchecksum.
Plus, separate from the plugin:
meta/brand/figma-kit#001..N— author the 3 sample components(Button, Card, Empty State) in Figma using the plugin-applied styles.
R6 — Cross-references
- Coordinates with
tools/design-gen#059— already emitstokens.jsonin DTCG-aligned shape; plugin consumes it. - Coordinates with
projects/koder-stack#156— Storybook RFC choseKoder-native HTMX sandbox for live previews; Figma is the design source, not a code preview replacement.
- Coordinates with
projects/koder-stack#158— token distributionRFC (separate vertical: how product code consumes tokens; this RFC is how design tool consumes tokens).
R7 — Risk mitigation
Risks of Option C and how to mitigate:
- *igma API changes*breaking the plugin → plugin manifest pins
the API version; bump deliberately with each Figma quarterly release.
- *lugin install friction for designers*→ publish to Figma
Community + document install in the kit README.
- *esigner requests token
editinFigma*→ reopen this RFC at6mo evaluation; promote to Option A overlay if demand sustained.
Não-escopo
- The Figma kit content itself (components designed in Figma — separate
metabrandfigma-kit tickets).
- Code
fromFigma direction (Figma → code, e.g., Anima / Locofy) —out of scope; KDS is code
first per `policies/codefirst.kmd`. - Per
product Figma kits (only KDSscoped here).