Ask AI — generate tokens
Route: Library → Properties → Tokens → Primitives → Ask AI
The Ask-AI modal turns a prose description of a brand into a structured token patch — adds, updates, and removes you can review and apply.
Opening the modal
On the Primitives page, click Ask AI in the page header. The modal opens with a single textarea for your prompt.
When no API key is set, the modal shows a stub banner — the flow still works but returns a deterministic mock so you can test the diff/apply path without paying for a call.
Writing a useful prompt
Two patterns that work well:
Pattern A — brand brief
"Calm, professional palette for a fintech onboarding flow. Trust signals: navy primary, off-white surfaces, warm gold accent for the CTA. Avoid neon."
Pattern B — example anchor
"Match the feel of Linear's marketing site — muted neutrals, restrained accent, slightly warm grays in dark mode."
Both work because they give the model role (what the palette is for), mood (formal / playful / restrained), and at least one constraint (no neon, or 'restrained accent').
Reading the diff
The response is a TokenPatch:
- Add — new primitives the model proposed (e.g.
color-navy-500,color-gold-400) - Update — existing tokens whose value changed (shows old → new with swatches)
- Remove — tokens the model proposed deleting (rare; usually empty)
- Rationale — one paragraph explaining the choices
Each row has the proposed value with a swatch so you can scan the diff visually before applying.
Applying
Click Apply. The patch commits via the standard token-mutation actions (addToken / updateToken / deleteToken), which means:
- The change is on your undo stack —
Ctrl/Cmd + Zreverts the whole patch. - The Primitives page updates immediately.
- Every semantic and component binding downstream re-resolves.
- The Documentation tab regenerates fresh
tokens.css,design-system.md, anddesign-system.json.
To dismiss without applying, click Cancel or hit Escape.
Stub vs real mode
| Mode | When | What you get |
|---|---|---|
| Stub | No API key set | Deterministic mock (same prompt → same patch). Tests the UI, not the AI. |
| Real | Key in Settings | Direct call to Anthropic. Subject to your account's rate limits and pricing. |
Today the AI call surface ships with the stub wired and the real call deferred — see REBUILD_PLAN.md → M7. The diff/apply UX is final; the prompt that generates the patch is what's still landing.
Tips
- Don't ask for a full system — ask for primitives. Tostada's semantic and component layers stay yours to author.
- Iterate. Re-open the modal, refine the prompt, apply a new patch. Undo if you don't like it.
- Name your primitives. A patch arrives with names like
color-navy-500. Rename them to your team's convention before binding semantics.