-
Notifications
You must be signed in to change notification settings - Fork 28
Required Props Pattern
Exploration — January 2026
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.
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
| 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 |
| 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?
Rust doesn't make everything required. Instead:
- Structs require all fields — but builders provide optional fields
- Type state pattern — compile-time enforcement of which fields are set
- Recommendation: Only use for "types with at least five parts or complex interdependencies"
Source: Build Rust API with Builder Pattern
The insight isn't "all props required" — it's "explicit errors with actionable messages."
| 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 |
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>
- How do we measure "error actionability" for LLMs?
-
Should Astryx provide anAnswered: No — no AI system currently reads llms.txt. Not worth investment. See AI Model Trajectory.llms.txtwith component examples for each prop combination? - Can we A/B test required vs optional props with AI coding assistants?
- AI and Design Systems — Strategy 4: Typed Component APIs
- RustAssistant: Using LLMs to Fix Compilation Errors — 74% accuracy with explicit errors
- Where Do LLMs Still Struggle? — Semantic understanding > complexity
- Build Rust API with Builder Pattern — Required vs optional in Rust
- Sensible Defaults — Value of good defaults