Schema engineering beats prompt engineering, says Microsoft
TypeChat turns your TypeScript types into a natural language interface, then validates and repairs the LLM's output automatically.

What it does
TypeChat lets you build natural language interfaces by defining TypeScript types instead of writing prompts. You declare the intents your app supports—sentiment classification, shopping cart actions, music requests—as ordinary types and discriminated unions. TypeChat constructs the LLM prompt from those types, validates that the response matches your schema, and if the model hallucinates or malforms the output, it initiates a repair conversation automatically. Finally, it summarizes the result to confirm it aligns with what the user actually asked.
The interesting bit
The “meta-schema” idea: you can nest schemas so the model first picks which sub-schema applies, then fills in the details. It’s decision trees by another name, except the tree is your type system and the routing is handled by an LLM. The README’s “Types are all you need!” is almost sincere.
Key highlights
- Replaces prompt engineering with schema engineering—define intents as TypeScript types
- Automatic validation and repair loop when LLM output doesn’t conform to schema
- Hierarchical schemas via “meta-schema” that selects sub-schemas based on user input
- Summarizes and verifies user intent without calling the LLM again
- Multi-language: TypeScript/JavaScript (npm), plus Python and C#/.NET ports
Caveats
- The Python and C# versions are separate repos/efforts; maturity across languages is unclear
- “Repair” means more LLM round-trips—latency and cost implications aren’t discussed
- No candidate images available, so no screenshots or architecture diagrams to assess
Verdict
Worth a look if you’re already TypeScript-native and tired of prompt fragility. Skip it if you need deep control over the prompt itself or if your schema changes so frequently that maintaining types becomes its own burden.