What problem does it solve?
Many TypeScript projects split type declarations and runtime validators, causing drift between compile-time types and runtime behavior that leads to crashes and unhandled cases. This Skill codifies a discipline to derive runtime validation and TypeScript types from the same Zod schema, use discriminated unions for multi-variant outputs, and enforce DeepImmutable AppState to prevent accidental mutation.
Core Features & Use Cases
- Schema-as-source-of-truth: define inputSchema with Zod and derive TypeScript types with z.infer to avoid duplicate, diverging definitions.
- Discriminated union outputs: use z.discriminatedUnion for tool outputs so TypeScript exhaustiveness and narrowing eliminate missing-case bugs.
- Immutable AppState: wrap AppState in DeepImmutable to force immutable updates via setAppState and make state transitions explicit.
- Use Case: migrating a codebase where manual validators and interfaces disagree, or adding a new tool that must validate LLM JSON output and provide multiple result shapes.
Quick Start
Convert this tool's manual validation and interfaces into a Zod inputSchema, derive the TypeScript type with z.infer, add an outputSchema as a discriminated union if the tool can return multiple result kinds, and make AppState DeepImmutable.