Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

initial architecture explorations for AI

Cindy Zhang79308cfb8773
diff --git a/.context/explorations/ai-design-system-gaps.md b/.context/explorations/ai-design-system-gaps.md
new file mode 100644
index 0000000000..af70c52815
--- /dev/null
+++ b/.context/explorations/ai-design-system-gaps.md
@@ -0,0 +1,195 @@
+# AI + Design Systems: Gaps in Current Stack
+
+*Exploration — January 2026*
+
+## Context
+
+Research into problems with the current standard stack (Tailwind CSS, shadcn/ui, utility-first CSS) when used with AI code generation. Focus on design system adherence issues.
+
+---
+
+## Findings
+
+### 1. Design System Adherence Problems
+
+**Utility-class drift**
+- AI generates arbitrary values (`mt-[13px]`) instead of design tokens
+- Different prompts produce different class combinations for same intent
+- No enforcement of spacing scales, color palettes, or typography
+
+**Inconsistency across generations**
+- Each AI session may produce different styling approaches
+- "Style and structure inconsistencies" — fragmented codebases that appear disjointed
+- Lost context means suggestions drift from established patterns
+
+### 2. Architectural Blindness
+
+**Local optimization, not systemic**
+- AI "optimizes for local correctness, not systemic soundness"
+- Doesn't understand *why* previous decisions were made
+- Generates code without knowing if it belongs in that module
+
+**No shared architecture**
+- When developers use different AI sessions, there's no shared ownership
+- Design discussions replaced by autocomplete — no collaborative reasoning
+- Coupling emerges accidentally, not intentionally
+
+### 3. Tailwind-Specific Issues at Scale
+
+**The "utility-class mess"**
+- Bloated markup: dozens of classes per element
+- Without governance, "flexibility turns into chaos"
+- Inconsistent spacing, mismatched colors across teams
+
+**Abstraction gap**
+- Tailwind is low-level; design systems need high-level primitives
+- Requires manual component abstraction that AI often skips
+- No semantic meaning in class names for AI to learn from
+
+### 4. LLM Code Generation Weaknesses
+
+From academic research on LLM failures:
+- **Complexity degradation**: Accuracy drops exponentially with complexity
+- **API misuse**: Wrong arguments, incorrect attribute inference
+- **Corner case failures**: Over 54% of logic errors are edge cases
+- **Real-world gap**: Models underperform on production vs benchmarks
+
+---
+
+## Strategies for Injecting Design System Opinions
+
+### Strategy 1: Context Documents (Cursor Rules, CLAUDE.md, etc.)
+
+**Approach**: Write design guidelines in markdown files, have AI read them as context.
+
+**Results**:
+- ❌ **Rules are suggestions, not constraints** — AI can ignore them without consequences
+- ❌ **No verification system** — Can't confirm AI actually followed rules vs claimed compliance
+- ❌ **Context window degradation** — Performance deteriorates within conversations; rules "forgotten"
+- ❌ **Model-specific behavior** — Some models agree with everything without genuine adherence
+- ❌ **Requires constant reinforcement** — Users report needing to restart sessions to maintain rule-following
+
+**Community workarounds**:
+- Place critical rules prominently with explicit reinforcement
+- Use numbered prefixes for rule priority
+- Reference actual code examples, not abstract instructions
+
+### Strategy 2: Prompt Engineering / System Prompts
+
+**Approach**: Include design tokens and guidelines in system prompts.
+
+**Results**:
+- ⚠️ **Token budget constraints** — Full design systems don't fit in context
+- ⚠️ **Dilution effect** — More instructions = less attention to each one
+- ⚠️ **No enforcement** — Still just suggestions the model can ignore
+- ✅ **Works for simple constraints** — "Always use Tailwind" is followable; "use these 47 spacing values" is not
+
+### Strategy 3: Schema-Enforced Structured Output
+
+**Approach**: Define JSON schema, use API-level constraints to force valid output.
+
+**Results**:
+- ✅ **Actually enforced** — API contract constrains generation itself, not post-hoc parsing
+- ✅ **Type safety** — Compile-time + runtime validation
+- ✅ **Deterministic** — Predictable response shapes
+- ⚠️ **Limited to data, not code** — Works for JSON output, not JSX/TSX generation
+
+### Strategy 4: Typed Component APIs
+
+**Approach**: Constrain what's possible at the TypeScript level.
+
+**Results**:
+- ✅ **Enforcement at compile time** — Invalid props = type error
+- ✅ **AI learns from constraints** — Autocomplete only shows valid options
+- ✅ **Self-documenting** — Types become the source of truth
+- ⚠️ **Requires well-designed API** — Constraint design is hard
+- ⚠️ **Reactive, not proactive** — Types catch errors after generation, not before
+
+**Research on first-try accuracy**:
+- LLMs pass all tests only 46-65% on first attempt (arxiv.org/html/2412.14841v1)
+- Claude 3 Opus: 84.9% pass@1 on HumanEval; GPT-4 raw: ~86%
+- Models with error feedback loops ("Reflexion") jump to 95-98%
+- Best models fix 59% of incorrect code when given error info
+
+**API misuse is common**:
+- Research found "significant challenges in API usage, particularly hallucination and intent misalignment" (arxiv.org/abs/2503.22821v1)
+- Study annotated 3,892 method-level and 2,560 parameter-level misuses
+
+**Key insight**: Types are guardrails for iteration, not first-try guidance. The value is in fast recovery (instant compile error) rather than preventing the mistake.
+
+### Strategy 5: JSDoc / Code Comments
+
+**Approach**: Annotate components with JSDoc to guide AI understanding.
+
+**Results**:
+- ❌ **Not reliably read** — Comments are one signal among many (surrounding code, open tabs, cursor context)
+- ❌ **No privileged status** — GitHub Copilot docs show comments compete with other context sources
+- ❌ **Token inefficient** — Verbose JSDoc bloats context window without enforcement
+- ❌ **No verification** — Can't confirm AI actually read or followed the docs
+
+**Research findings**:
+- Type constraints reduce LLM code generation errors by >50% (arxiv.org/abs/2504.09246)
+- The `llms.txt` standard emerged specifically because traditional docs (including JSDoc) fail for LLM consumption
+- Shorter prompts (<50 words) outperform verbose documentation
+- Concrete code examples work better than abstract documentation
+
+### Key Insight
+
+The pattern is clear:
+
+| Strategy | Enforcement Level | Reliability |
+|----------|------------------|-------------|
+| Context docs / rules | None (suggestions) | Low |
+| System prompts | None (suggestions) | Low |
+| JSDoc / comments | None (suggestions) | Low |
+| Schema-enforced output | API-level | High (for JSON) |
+| Typed component APIs | Compile-time (reactive) | High — via iteration |
+
+**Context injection fails because it's optional.** The AI can always ignore guidance. Typed APIs are reliable but *reactive* — they enable fast error→fix loops rather than preventing mistakes. First-try accuracy is only 46-65%; the value of types is making recovery instant.
+
+---
+
+## Implications for XDS
+
+These gaps suggest opportunities for differentiation:
+
+| Gap | Potential XDS Approach |
+|-----|------------------------|
+| Arbitrary values | Constrained API — only valid tokens accepted |
+| Style drift | Semantic component names AI can learn |
+| Lost context | Typed APIs > JSDoc (types are enforced, docs are ignored) |
+| No enforcement | Plugin system for validation |
+| Spacing chaos | Automatic spacing compensation |
+| Abstraction gap | Pre-composed patterns, not utilities |
+| Docs not read | Types as documentation — context arrives on import; skip llms.txt (not adopted by AI systems) |
+
+---
+
+## Sources
+
+- [Vibe coding is destroying architecture](https://dev.to/dev_tips/vibe-coding-is-destroying-architecture-the-silent-rot-in-our-ai-built-systems-4p1n)
+- [Mastering Tailwind CSS for Enterprise Apps](https://veduis.com/blog/mastering-tailwind-css-enterprise-apps-scalable-design-system/)
+- [Vibe Coding Mistakes](https://dev.to/tirumalaraonaidu/vibe-coding-mistakes-when-using-ai-tools-and-how-to-avoid-them-2p7c)
+- [What is Wrong with LLM Generated Code](https://arxiv.org/html/2407.06153)
+- [Cursor rules are meaningless](https://forum.cursor.com/t/cursor-actively-admitting-that-rules-are-meaningless-and-it-doesnt-have-to-follow-them/131826)
+- [Setting Up Cursor Rules Guide](https://dev.to/stamigos/setting-up-cursor-rules-the-complete-guide-to-ai-enhanced-development-24cg)
+- [Schema-Enforced Outputs](https://dev.to/dthompsondev/llm-structured-json-building-production-ready-ai-features-with-schema-enforced-outputs-4j2j)
+- [The crisis of context](https://standardbeagle.com/ai-coding-assistants-and-context/)
+- [Type-Constrained Code Generation with LLMs](https://arxiv.org/abs/2504.09246) — Types reduce errors by >50%
+- [llms.txt: What It Is and How It Works](https://apidog.com/blog/llms-txt/) — AI-friendly docs standard
+- [ZenML's llms.txt Implementation](https://www.zenml.io/blog/llms-txt) — Tiered token budgets for docs
+- [GitHub Copilot: Responsible Use](https://docs.github.com/en/enterprise-cloud@latest/copilot/responsible-use/copilot-code-completion) — How Copilot uses context
+- [Using LLMs for Code](https://simonwillison.net/2025/Mar/11/using-llms-for-code/) — Context > documentation
+- [LLM Code Generation Accuracy Guide](https://www.prompthub.us/blog/using-llms-for-code-generation-a-guide-to-improving-accuracy-and-addressing-common-issues) — Short prompts outperform verbose
+- [Testing and Static Analysis Feedback for LLMs](https://arxiv.org/html/2412.14841v1/) — 46-65% first-try accuracy, 59% fix rate with feedback
+- [API Misuse in LLMs](https://arxiv.org/abs/2503.22821v1) — Taxonomy of 3,892 method-level misuses
+- [HumanEval Benchmark](https://klu.ai/glossary/humaneval-benchmark) — pass@1 scores across models
+
+---
+
+## Open Questions
+
+- How constrained should the API be vs flexibility for edge cases?
+- ~~What JSDoc patterns work best for LLM consumption?~~ **Answered**: JSDoc doesn't reliably work — types beat comments. See Strategy 5.
+- How do we measure "design system adherence" in AI-generated code?
+- ~~Should XDS ship an `llms.txt` for AI-friendly documentation?~~ **Answered**: No — no AI system currently reads llms.txt. See `ai-trajectory-predictions.md`.
diff --git a/.context/explorations/ai-trajectory-predictions.md b/.context/explorations/ai-trajectory-predictions.md
new file mode 100644
index 0000000000..200ea408c0
--- /dev/null
+++ b/.context/explorations/ai-trajectory-predictions.md
@@ -0,0 +1,152 @@
+# AI Model Trajectory: What to Build For
+
+*Exploration — January 2026*
+
+## Context
+
+Investigating predictable vs unpredictable aspects of LLM improvement to inform XDS design decisions. Goal: avoid building for current limitations that may disappear, while investing in solutions for fundamental limits that won't.
+
+---
+
+## What's Predictable About Model Improvement
+
+### Scaling Laws Are Real (But Slowing)
+
+Performance improves predictably with compute/data/parameters in proportion. However:
+- **Data scarcity** is becoming the bottleneck — high-quality training data is running out
+- **Capability density rising** — newer models achieve same performance with fewer parameters
+- Focus shifting from scale to efficiency and architecture
+
+Source: [LLM Scaling Laws Analysis 2026](https://research.aimultiple.com/llm-scaling-laws/)
+
+### Emergent Abilities Appear Unpredictably
+
+Certain capabilities "jump" suddenly at scale thresholds:
+- Three-digit addition: 8% → 80% accuracy between 13B and 175B parameters
+- Chain-of-thought reasoning emerges above certain model sizes
+- **Cannot predict when abilities will emerge from smaller models**
+
+Source: [Emergent Abilities in LLMs Survey](https://arxiv.org/html/2503.05788v1)
+
+---
+
+## Fundamental Limits (Won't Improve With Scale)
+
+Research identifies **irreducible limits** that scaling cannot overcome:
+
+| Limit | Why It's Fundamental |
+|-------|---------------------|
+| **Hallucination** | Mathematically proven — "no computable LLM can be universally correct over open-ended queries" |
+| **Effective context** | 128K tokens nominal, but effective context is far shorter due to positional encoding decay |
+| **Reasoning degradation** | Models optimize pattern completion, not logical inference |
+| **Long-tail knowledge** | Sample complexity scales linearly with fact count — prohibitively expensive |
+| **Creativity-factuality tradeoff** | Mechanisms enabling creativity necessarily increase hallucination |
+
+### Key Findings
+
+**Hallucination is mathematically inevitable:**
+- Theorem proves any enumerable model class must fail on adversarially constructed inputs
+- Undecidable problems force infinite failure sets
+- "Hallucination is an intrinsic property of learning systems operating over unbounded, open-ended query spaces"
+
+**Context window is deceptive:**
+- Positional under-training: gradient flow to long-range positions is negligible
+- Encoding attenuation: dot products vanish for large separations
+- Result: effective context scales sub-linearly with nominal window size
+
+**Data pathologies compound problems:**
+- Web-scraped text contains 2-3% false claims learned indiscriminately
+- 50%+ of time-dependent facts become stale within months
+- Benchmark contamination creates "illusions of competence"
+
+Source: [On the Fundamental Limits of LLMs at Scale](https://arxiv.org/html/2511.12869)
+
+---
+
+## Implications for XDS
+
+### Always Build For (Fundamental Limits)
+
+These won't improve, so invest heavily:
+
+| Limit | XDS Design Response |
+|-------|---------------------|
+| Hallucination persists | Constraints beat suggestions — invalid output should be impossible |
+| Effective context limited | Keep API surface small; don't rely on LLM reading extensive docs |
+| Pattern completion, not reasoning | Make correct patterns obvious and consistent |
+| Long-tail knowledge fails | Don't expect LLM to know XDS conventions — enforce via types |
+
+### Build For Now, Accept May Become Unnecessary
+
+Current weaknesses that may improve:
+
+| Weakness | Likely to Improve? | XDS Response |
+|----------|-------------------|--------------|
+| First-try accuracy (46-65%) | **Yes** — emergent abilities | Design for iteration, don't assume stays bad |
+| API misuse | **Yes** — tool use improving | Typed constraints help now, remain valuable later |
+| Following docs/rules | **Uncertain** | Don't rely on it, but don't assume permanent |
+
+### Don't Over-Optimize For (Likely to Improve)
+
+Avoid investing heavily in workarounds for:
+- Poor first-try accuracy (will likely improve)
+- Inability to follow complex instructions (improving with reasoning models)
+- Limited context understanding (architectural innovations ongoing)
+
+---
+
+## The Framework
+
+```
+┌─────────────────────────────────────────────────────┐
+│ ALWAYS BUILD FOR (fundamental limits) │
+│ • Constraints over suggestions │
+│ • Small API surface │
+│ • Type enforcement │
+│ • Clear error messages │
+│ • Consistent patterns │
+├─────────────────────────────────────────────────────┤
+│ BUILD FOR NOW, MAY BECOME UNNECESSARY │
+│ • Iteration-friendly design │
+│ • Explicit over implicit │
+│ • Reduced prop optionality │
+├─────────────────────────────────────────────────────┤
+│ DON'T OVER-OPTIMIZE FOR (likely to improve) │
+│ • Workarounds for poor reasoning │
+│ • Dumbing down API for current limitations │
+│ • Assuming models can't follow patterns │
+└─────────────────────────────────────────────────────┘
+```
+
+---
+
+## On llms.txt
+
+**Status**: Proposed standard, not implemented by any major AI system.
+
+- John Mueller (Google): "no AI system currently uses llms.txt"
+- Server logs show zero visits from AI bots
+- Not a viable path for XDS component documentation
+
+**What works instead at scale:**
+- Types as documentation (context arrives on import)
+- Consistent patterns (learn once, apply everywhere)
+- Optional MCP server for on-demand component docs
+
+---
+
+## Open Questions
+
+- How do we measure whether our API design is "AI-friendly"?
+- Should we track LLM success rates against XDS components over time?
+- At what point do we revisit assumptions as models improve?
+
+---
+
+## Sources
+
+- [LLM Scaling Laws Analysis 2026](https://research.aimultiple.com/llm-scaling-laws/)
+- [Emergent Abilities in LLMs Survey](https://arxiv.org/html/2503.05788v1)
+- [On the Fundamental Limits of LLMs at Scale](https://arxiv.org/html/2511.12869)
+- [Semrush: What Is LLMs.txt](https://www.semrush.com/blog/llms-txt/) — No AI systems currently use it
+- [DigitalOcean: Copilot vs Cursor](https://www.digitalocean.com/resources/articles/github-copilot-vs-cursor) — Context handling comparison
diff --git a/.context/explorations/required-props-pattern.md b/.context/explorations/required-props-pattern.md
new file mode 100644
index 0000000000..aa6a15c422
--- /dev/null
+++ b/.context/explorations/required-props-pattern.md
@@ -0,0 +1,117 @@
+# Required Props Pattern
+
+*Exploration — January 2026*
+
+## Context
+
+Exploring whether making all component props required (no defaults) improves AI code generation. Hypothesis: explicit APIs are more "vibe-able" because every example demonstrates all props and errors are more actionable.
+
+Inspired by Rust's reputation for being LLM-friendly due to explicit, detailed compiler errors.
+
+---
+
+## Research Findings
+
+### Why Rust Works Well for LLMs
+
+**Not because everything is required — because errors are explicit and actionable.**
+
+Microsoft's RustAssistant achieved 74% accuracy fixing Rust compilation errors because the compiler provides:
+- Error code
+- Exact location
+- Documentation and examples for the error type
+
+This enables fast iterate-until-correct loops. The LLM knows exactly what's wrong and how to fix it.
+
+Source: [RustAssistant: Using LLMs to Fix Compilation Errors in Rust Code](https://www.microsoft.com/en-us/research/publication/rustassistant-using-llms-to-fix-compilation-errors-in-rust-code/)
+
+### Arguments FOR Required Props
+
+| Benefit | Explanation |
+|---------|-------------|
+| Actionable errors | "Missing prop X" is specific; silent wrong defaults are not |
+| Complete examples | Every usage shows every prop — no hidden behavior |
+| Forced intentionality | Can't accidentally rely on implicit defaults |
+| Training data quality | LLMs learn from complete specifications |
+
+### Arguments AGAINST / Caveats
+
+| Concern | Explanation |
+|---------|-------------|
+| LLMs struggle with detail | Research shows models "overlook details in prompts" — more required props = more to miss |
+| No direct research | No studies found comparing all-required vs optional for LLM accuracy |
+| Human DX cost | Sensible defaults reduce decision fatigue for humans |
+| Rust uses builders | Even Rust uses builder patterns for optional fields |
+
+**Key finding from LLM failure analysis:**
+- Complexity alone doesn't predict failure
+- Semantic understanding is the bottleneck
+- 76/148 tasks failed across *all* models when prompts were underspecified
+
+Source: [Where Do LLMs Still Struggle?](https://arxiv.org/html/2511.04355)
+
+### How Rust Actually Handles This
+
+Rust doesn't make everything required. Instead:
+
+1. **Structs require all fields** — but builders provide optional fields
+2. **Type state pattern** — compile-time enforcement of which fields are set
+3. **Recommendation**: Only use for "types with at least five parts or complex interdependencies"
+
+Source: [Build Rust API with Builder Pattern](https://blog.logrocket.com/build-rust-api-builder-pattern/)
+
+---
+
+## Implications for XDS
+
+The insight isn't "all props required" — it's "explicit errors with actionable messages."
+
+### Proposed Approach
+
+| Prop Type | Required? | Rationale |
+|-----------|-----------|-----------|
+| Behavioral props | Yes | Affects component behavior; must be explicit |
+| Structural props | Yes | Affects DOM structure; must be explicit |
+| Styling/presentation | Optional | Pure visual; safe defaults exist |
+
+### Error Message Design
+
+More important than required-vs-optional is error quality:
+
+```
+// Bad: silent wrong behavior
+<Button>Click</Button> // defaults to type="button", looks like submit
+
+// Better: required prop
+<Button>Click</Button> // Error: missing required prop 'type'
+
+// Best: actionable error with guidance
+<Button>Click</Button>
+// Error: Button requires 'type' prop.
+// Options: "button" | "submit" | "reset"
+// Example: <Button type="button">Click</Button>
+```
+
+---
+
+## Open Questions
+
+- How do we measure "error actionability" for LLMs?
+- ~~Should XDS provide an `llms.txt` with component examples for each prop combination?~~ **Answered**: No — no AI system currently reads llms.txt. Not worth investment. See `ai-trajectory-predictions.md`.
+- Can we A/B test required vs optional props with AI coding assistants?
+
+---
+
+## Related
+
+- `ai-design-system-gaps.md` — Strategy 4: Typed Component APIs
+- `zero-styling-architecture.md` — Zero styling = nothing optional anyway
+
+---
+
+## Sources
+
+- [RustAssistant: Using LLMs to Fix Compilation Errors](https://www.microsoft.com/en-us/research/publication/rustassistant-using-llms-to-fix-compilation-errors-in-rust-code/) — 74% accuracy with explicit errors
+- [Where Do LLMs Still Struggle?](https://arxiv.org/html/2511.04355) — Semantic understanding > complexity
+- [Build Rust API with Builder Pattern](https://blog.logrocket.com/build-rust-api-builder-pattern/) — Required vs optional in Rust
+- [Sensible Defaults](https://www.thoughtworks.com/insights/blog/technology-strategy/better-tech-decision-making-underpinned-by-sensible-defaults) — Value of good defaults
diff --git a/.context/explorations/zero-styling-architecture.md b/.context/explorations/zero-styling-architecture.md
new file mode 100644
index 0000000000..1d412d8d02
--- /dev/null
+++ b/.context/explorations/zero-styling-architecture.md
@@ -0,0 +1,58 @@
+# Zero-Styling Architecture
+
+*Exploration — January 2026*
+
+## Context
+
+Responding to AI + design system adherence problems identified in `ai-design-system-gaps.md`. Core insight: enforcement beats suggestion. If arbitrary values have nowhere to go, they can't exist.
+
+---
+
+## Concept
+
+**Invert the usual pattern.** Instead of "styled by default, override as needed," use:
+
+1. **Zero styling on components** — Components ship with no inline styles, no utility classes, no style props
+2. **Theme file as single source of truth** — All styling controlled through centralized theme configuration
+3. **Swizzling for flexibility** — Explicit opt-out for structural and behavioral customization
+
+---
+
+## Why This Works for AI
+
+| Problem | How Zero-Styling Addresses It |
+|---------|-------------------------------|
+| Arbitrary values (`mt-[13px]`) | No style props = nowhere for arbitrary values to go |
+| Drift across sessions | Theme file is the constraint; components are stateless shells |
+| Context window degradation | Theme is a single file, easy to include in context |
+| No enforcement | Compile-time enforcement — invalid tokens don't exist |
+
+**Note on documentation**: Research confirms that JSDoc/comments are not reliably read by LLMs. Type constraints reduce errors by >50% where documentation has no measurable effect. This reinforces the zero-styling approach: **constrain via types, not docs**.
+
+**Note on reactive enforcement**: Types are guardrails for iteration, not first-try guidance. Research shows LLMs get code right only 46-65% on first attempt; the value of types is enabling instant error→fix loops. This means XDS should optimize for:
+1. **Clear error messages** — Help AI understand what went wrong
+2. **Narrow valid options** — Fewer choices = faster convergence
+3. **No silent failures** — Every violation should surface immediately
+
+---
+
+## Open Questions
+
+### Theme File Structure
+- Token-based (colors, spacing scales)?
+- Component-based (Button.primary.background)?
+- Both with inheritance?
+
+### Swizzle Granularity
+- Full component replacement?
+- Slot-level swizzling (e.g., just the icon area of a button)?
+
+### AI + Swizzled Components
+- When someone swizzles, they lose enforcement
+- Can swizzled components remain "theme-aware"?
+- How do we prevent AI from going off-rails in swizzled code?
+
+---
+
+## Related
+- `ai-design-system-gaps.md` — Problem analysis this responds to