codegen-over-complex-types
Installation
SKILL.md
Consider Codegen as an Alternative to Complex Types
Overview
Sometimes the best type-level code is no type-level code at all. When types become extremely complex, when they mirror external schemas (APIs, databases, protocols), or when they need to stay synchronized with changing external sources, code generation is often a better solution than sophisticated type-level programming.
Code generation trades compile-time complexity for build-time generation, often resulting in simpler, more maintainable code that stays in sync with its source of truth.
When to Use This Skill
- Types mirror external schemas (OpenAPI, GraphQL, database)
- Type-level logic becomes extremely complex
- Types need to stay synchronized with external sources
- Type maintenance cost exceeds value
- Team struggles with complex type-level code
The Iron Rule
When types become too complex or must stay synchronized with external sources, generate them from schemas rather than writing sophisticated type-level code.