sir-chawakorn/power-ranger-toolkit/api-client-generator

Claude Code and agent skill by sir-chawakorn/power-ranger-toolkit

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install sir-chawakorn/power-ranger-toolkit/api-client-generator

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

🔌 API Client Generator Skill


name: api-client-generator description: Generate type-safe API clients from OpenAPI/Swagger specs or existing API endpoints


🎯 Purpose

สร้าง API client ที่ type-safe อัตโนมัติ จาก OpenAPI/Swagger specs หรือจาก API endpoints ที่มีอยู่

📋 When to Use

  • เชื่อมต่อกับ API ใหม่
  • อัพเดท API client หลัง spec เปลี่ยน
  • สร้าง SDK จาก OpenAPI
  • Generate types จาก API response

🔧 Generation Methods

1. From OpenAPI/Swagger Spec
bash
# Using openapi-typescript
npx openapi-typescript ./api-spec.yaml -o ./types/api.ts
# Using swagger-typescript-api
npx swagger-typescript-api -p ./swagger.json -o ./api -n api.ts
2. From Existing Endpoints
typescript
// Analyze endpoint and generate types
// GET /api/users →
interface User {
id: number;
name: string;
email: string;
}
// Generate client
async function getUsers(): Promise<User[]> {
const response = await fetch('/api/users');
return response.json();
}

📝 Generated Client Template

typescript
// api/client.ts
const BASE_URL = process.env.API_URL || 'http://localhost:3000';
interface RequestConfig {
headers?: Record<string, string>;
params?: Record<string, string>;
}
class ApiClient {
private baseUrl: string;
private defaultHeaders: Record<string, string>;
constructor(baseUrl: string = BASE_URL) {
this.baseUrl = baseUrl;
this.defaultHeaders = {
'Content-Type': 'application/json',
};
}
setAuthToken(token: string) {
this.defaultHeaders['Authorization'] = `Bearer ${token}`;
}
private async request<T>(
method: string,
endpoint: string,
data?: unknown,
config?: RequestConfig
): Promise<T> {
const url = new URL(endpoint, this.baseUrl);
if (config?.params) {
Object.entries(config.params).forEach(([key, value]) => {
url.searchParams.set(key, value);
});
}
const response = await fetch(url.toString(), {
method,
headers: { ...this.defaultHeaders, ...config?.headers },
body: data ? JSON.stringify(data) : undefined,
});
if (!response.ok) {
throw new ApiError(response.status, await response.text());
}
return response.json();
}
// Generated methods
users = {
getAll: () => this.request<User[]>('GET', '/api/users'),
getById: (id: string) => this.request<User>('GET', `/api/users/${id}`),
create: (data: CreateUserDto) => this.request<User>('POST', '/api/users', data),
update: (id: string, data: UpdateUserDto) => this.request<User>('PUT', `/api/users/${id}`, data),
delete: (id: string) => this.request<void>('DELETE', `/api/users/${id}`),
};
}
export const api = new ApiClient();

🔧 With React Query

typescript
// hooks/useUsers.ts
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { api } from '@/api/client';
export function useUsers() {
return useQuery({
queryKey: ['users'],
queryFn: () => api.users.getAll(),
});
}
export function useUser(id: string) {
return useQuery({
queryKey: ['users', id],
queryFn: () => api.users.getById(id),
enabled: !!id,
});
}
export function useCreateUser() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: api.users.create,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['users'] });
},
});
}

📊 OpenAPI to Types Mapping

OpenAPI TypeTypeScript Type
stringstring
integernumber
numbernumber
booleanboolean
arrayT[]
objectinterface
enumenum or union

🔄 Auto-Generation Workflow

1. GET OpenAPI spec
- Download from API endpoint
- Or use local file
2. PARSE spec
- Extract endpoints
- Extract schemas
- Extract parameters
3. GENERATE types
- Create interfaces
- Create enums
- Create DTOs
4. GENERATE client
- Create request methods
- Add type annotations
- Add error handling
5. ADD hooks (optional)
- React Query hooks
- SWR hooks
- Custom hooks

📋 Generated Files Structure

api/
├── client.ts # API client class
├── types/
│ ├── models.ts # Data models
│ ├── requests.ts # Request DTOs
│ └── responses.ts # Response DTOs
├── hooks/
│ ├── useUsers.ts # User hooks
│ └── usePosts.ts # Post hooks
└── index.ts # Exports

✅ Generation Checklist

  • [ ] All endpoints covered
  • [ ] Types match API spec
  • [ ] Error handling included
  • [ ] Auth handling included
  • [ ] Query params supported
  • [ ] Request body typed
  • [ ] Response typed
  • [ ] Hooks generated (if needed)

🔗 Related Skills

  • type-generator - Generate types from JSON
  • api-design - Design APIs
  • testing - Test API clients

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
33
Repository forks
6
7-day trend score
18

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 Mar 2026, 8 months ago.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/sir-chawakorn/power-ranger-toolkit/api-client-generator/badge)](https://verified-skill.com/skills/sir-chawakorn/power-ranger-toolkit/api-client-generator)

Something wrong with this skill or its page? Tell us.