codegen-api
Installation
SKILL.md
Typesafe API Codegen
Rule
Generate options, not hooks. Generate documents, not per-query types.
Both ecosystems converged in 2024-2025. REST and GraphQL codegens stopped emitting framework-specific hooks (useGetPet, useFilmsQuery) and started emitting framework-agnostic primitives that plug into the data-fetching library's existing hooks. Do not reach for legacy codegen plugins that emit hooks or per-query prop types.
This is the most common failure mode in LLM-generated API wiring: training data predates the shift and defaults to @graphql-codegen/typescript-react-apollo, typescript-react-query, or openapi-typescript-codegen hook output.
Step 1: Pick the path
| API source | Data fetching | Pick |
|---|---|---|
| OpenAPI / REST | TanStack Query (any framework) | @hey-api/openapi-ts with @tanstack/react-query plugin |
| GraphQL | Apollo Client or urql | graphql-codegen client preset, default documentMode (AST) |
| GraphQL | TanStack Query (custom fetch) | graphql-codegen client preset with documentMode: "string" |
| GraphQL, small schema, no build step | any | gql.tada (zero-codegen, TS inference) |
| OpenAPI / REST, existing Orval setup | TanStack Query | Stay on Orval until queryOptions ships. Do not migrate without cause. |