Generate a Typed API Client SDK from Your OpenAPI Spec with Claude
Code-generated API clients from OpenAPI often produce unwieldy, poorly named output — ask Claude to write a handcrafted client that's actually pleasant to use.
claude "Read openapi.yaml and generate a fully typed TypeScript API client in src/lib/api-client.ts. Use the fetch API, include request/response types for every endpoint, group methods by resource (users, posts, orders), handle errors with a custom ApiError class, and support an auth token passed via constructor."
Claude produces a real client — not a sprawling auto-gen dump — with clean method names derived from the operationIds, proper generic return types, and an interceptor pattern for retries and token refresh.
For a React project, ask Claude to wrap it in a set of TanStack Query hooks at the same time:
claude "Now wrap the API client in React Query hooks in src/hooks/api/. Generate useQuery hooks for GET endpoints and useMutation hooks for POST/PUT/DELETE. Include optimistic updates for mutation hooks where the response matches a cached query key."
You can target any language — Python, Go, PHP:
claude "Read openapi.yaml and generate a Python requests-based client with dataclass models for all request/response bodies. Group by tag, use snake_case method names, and raise a typed APIError on non-2xx responses."
A Claude-written SDK feels like it was written by a developer who knows your codebase — not generated by a tool that doesn't.
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.