codegen-over-complex-types

Generates TypeScript types from OpenAPI, GraphQL, and database schemas instead of complex type-level code.

Updated Sep 5, 2026
One-click install
npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill codegen-over-complex-types-pohlai88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: codegen-over-complex-types
Source: https://github.com/pohlai88/afenda-xforge-v5/tree/main/.agents/skills/codegen-over-complex-types
Command: npx skills add https://github.com/pohlai88/afenda-xforge-v5 --skill codegen-over-complex-types-pohlai88

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Complex type-level TypeScript code becomes unmaintainable when it mirrors external schemas or requires extensive conditional type logic, and manually written types drift out of sync with APIs and databases. ## Core Features & Use Cases - Schema-Driven Generation: Generate TypeScript types from OpenAPI specs, GraphQL schemas, databases via Prisma, JSON Schema, and Protobuf definitions. - Decision Framework: Provides clear criteria for choosing code generation versus type-level programming based on complexity, source of truth, and team expertise. - Sync Enforcement: Shows how to wire generation into build scripts and CI checks so types never drift from their external sources. - Use Case: Your team maintains 100+ field API response types by hand and every backend change breaks the frontend. Use this Skill to generate types from the OpenAPI schema and add a CI check that fails when generated types are stale. ## Quick Start Ask the AI to replace my hand-written API response types with types generated from my OpenAPI schema using openapi-typescript.

Frequently Asked Questions about codegen-over-complex-types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate TypeScript types from an OpenAPI schema?

Install openapi-typescript as a dev dependency and run npx openapi-typescript schema.yaml -o src/api-types.ts. The generated file contains typed paths, request bodies, and response schemas that stay in sync with your API definition.

When should I use code generation instead of type-level TypeScript?

Choose code generation when types mirror an external source of truth like an API or database, when type-level logic exceeds comfortable complexity, or when synchronization matters. Use type-level code for simple transformations of your own internal types.

How do I generate TypeScript types from a GraphQL schema?

Install @graphql-codegen/cli with the typescript and typescript-operations plugins, then configure a codegen.yml pointing at your schema file. Running npx graphql-codegen produces typed queries, mutations, and schema types.

How do I keep generated types in sync with my API?

Add generation commands to your package.json build and predev scripts, then add a CI step that regenerates types and runs git diff --exit-code on the output file. The build fails whenever committed types drift from the schema.

Can I combine generated types with hand-written TypeScript types?

Yes, use a hybrid approach: import generated base types from the schema, extend them with application-specific fields via interfaces, and derive variants with utility types like Omit and Partial for inputs and updates.