- Home
- Skills
- APIs & Backend
- api-client generator
Works with the AI Agents you already use
api-client generator
Generates typed TypeScript API clients, React Query hooks, and MSW mocks from OpenAPI specs or route definitions.
$6
api-client generator
Example session with this skill installed
Generate a TypeScript API client from ./docs/openapi.yaml for the 'Teams' resource. Include TanStack Query v5 hooks and MSW mocks. Use src/api/teams for output.
- Read your context and instructions
- Compiled the api-client generator
The API client for the Teams resource has been generated. This includes TypeScript interfaces, fetch wrappers with 401 refresh logic, TanStack Query hooks, and MSW handlers.
API Client: Teams Resource
// src/api/teams/types.ts
export interface Team {
id: string;
name: string;
memberCount: number;
}
export interface TeamPage {
items: Team[];
total: number;
}
// src/api/teams/client.ts
import { fetcher } from '../base';
import { Team, TeamPage } from './types';
export const teamsApi = {
listTeams: (page: number) =>
fetcher<TeamPage>(`/teams?page=${page}`, { method: 'GET' }),
getTeam: (id: string) =>
fetcher<Team>(`/teams/${id}`, { method: 'GET' }),
};
// src/api/teams/hooks.ts
import { useQuery } from '@tanstack/react-query';
import { teamsApi } from './client';
export const useTeams = (page: number) => {
return useQuery({
queryKey: ['teams', page],
queryFn: () => teamsApi.listTeams(page),
});
};
// src/api/teams/mocks.ts
import { http, HttpResponse } from 'msw';
export const teamHandlers = [
http.get('/teams', () => {
return HttpResponse.json({
items: [{ id: '1', name: 'Engineering', memberCount: 12 }],
total: 1
});
}),
];
Operation Map
| Operation | Method | Path | Input | Result | Auth |
|---|---|---|---|---|---|
| listTeams | GET | /teams | page: number | TeamPage | Bearer |
| getTeam | GET | /teams/:id | id: string | Team | Bearer |
Next steps
- Add
teamHandlersto your global MSW worker setup. - Export the new hooks from
src/api/teams/index.ts. - Run
tsc --noEmitto verify type alignment with the base fetcher.
Connects securely to your tools. The creator never sees your data.
About this skill
Manually writing API clients is a repetitive task prone to type mismatches and stale contracts. This skill automates the generation of fully typed TypeScript API clients directly from OpenAPI specs or backend route definitions.
What it does
- Type Generation creates TypeScript interfaces for request bodies, query parameters, and response schemas.
- Transport Layer builds typed fetch wrappers with consistent error handling and serialization logic.
- Hook Integration generates TanStack/React Query hooks for server state management.
- Test Mocking produces MSW (Mock Service Worker) handlers for unit and integration testing.
- Auth Handling implements interceptors for Bearer tokens, auto-refresh on 401s, and retry logic.
How it works
- Analyze Contract by inspecting OpenAPI documents or repository routes to map methods, status codes, and schemas.
- Audit Drift by comparing the current contract against existing client code to identify breaking changes.
- Generate Layers including types, transport wrappers, query hooks, and barrel exports.
- Verify Implementation by running typechecks and contract tests to ensure alignment with the source of truth.
Frameworks & tools
TypeScript, OpenAPI/Swagger, TanStack Query (React Query), MSW (Mock Service Worker), and native Fetch API or Axios.
Why this beats prompting it yourself
Generic prompts often ignore project-specific auth flows or pagination patterns. This skill enforces strict adherence to your repository's existing error shapes, retry policies, and nullability constraints without inventing fields.
Use cases
- Generating a client from a new OpenAPI/Swagger specification file.
- Updating an existing API client after backend contract changes.
- Replacing untyped fetch calls with a structured, hook-based architecture.
- Scaffolding test mocks that stay in sync with production API types.
Known limitations
Does not infer endpoints from UI labels or backend assumptions. Requires an explicit OpenAPI document or accessible route files as a source of truth.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Requires explicit OpenAPI docs or route files. Will not infer endpoints from UI. Retries are restricted to idempotent requests unless project policy explicitly allows otherwise.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 days ago