$npx -y skills add jackspace/ClaudeSkillz --skill api-integration-builderGenerates production-ready API clients with TypeScript types, retry logic, rate limiting, authentication (OAuth, API keys), error handling, and mock responses. Use when user says "integrate API", "API client", "connect to service", or requests third-party service integration.
| 1 | # API Integration Builder |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Generates complete, production-ready API clients with all the boilerplate handled: TypeScript types, authentication, retry logic, rate limiting, and error handling. |
| 6 | |
| 7 | **For ADHD users**: Instant integration - no need to read API docs and implement everything manually. |
| 8 | **For all users**: Saves hours of boilerplate code, type-safe, production-ready from day one. |
| 9 | |
| 10 | ## Activation Triggers |
| 11 | |
| 12 | - User says: "integrate API", "API client", "connect to service", "create SDK" |
| 13 | - Requests for: Stripe integration, SendGrid, Twilio, any third-party API |
| 14 | - "Set up OAuth" or "implement API authentication" |
| 15 | |
| 16 | ## Core Workflow |
| 17 | |
| 18 | ### 1. Gather Requirements |
| 19 | |
| 20 | Ask user for: |
| 21 | ```javascript |
| 22 | { |
| 23 | api_name: "Stripe", |
| 24 | api_base_url: "https://api.stripe.com/v1", |
| 25 | auth_type: "api_key|oauth|bearer|basic", |
| 26 | endpoints: [ |
| 27 | { method: "GET", path: "/customers", description: "List customers" }, |
| 28 | { method: "POST", path: "/customers", description: "Create customer" } |
| 29 | ], |
| 30 | rate_limit: { requests: 100, per: "minute" } // optional |
| 31 | } |
| 32 | ``` |
| 33 | |
| 34 | **If user provides API documentation URL**, fetch it and extract this information automatically. |
| 35 | |
| 36 | ### 2. Generate TypeScript Client |
| 37 | |
| 38 | **File structure**: |
| 39 | ``` |
| 40 | api-client/ |
| 41 | ├── client.ts # Main client class |
| 42 | ├── types.ts # TypeScript types |
| 43 | ├── auth.ts # Authentication handler |
| 44 | ├── errors.ts # Custom error classes |
| 45 | ├── retry.ts # Retry logic |
| 46 | ├── rate-limiter.ts # Rate limiting |
| 47 | └── mocks.ts # Mock responses for testing |
| 48 | ``` |
| 49 | |
| 50 | ### 3. Client Template |
| 51 | |
| 52 | ```typescript |
| 53 | // client.ts |
| 54 | import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; |
| 55 | import { AuthHandler } from './auth'; |
| 56 | import { RateLimiter } from './rate-limiter'; |
| 57 | import { RetryHandler } from './retry'; |
| 58 | import { APIError, RateLimitError, AuthenticationError } from './errors'; |
| 59 | import type { ClientConfig, APIResponse } from './types'; |
| 60 | |
| 61 | export class {APIName}Client { |
| 62 | private axios: AxiosInstance; |
| 63 | private auth: AuthHandler; |
| 64 | private rateLimiter: RateLimiter; |
| 65 | private retryHandler: RetryHandler; |
| 66 | |
| 67 | constructor(config: ClientConfig) { |
| 68 | this.auth = new AuthHandler(config.apiKey); |
| 69 | this.rateLimiter = new RateLimiter(config.rateLimit); |
| 70 | this.retryHandler = new RetryHandler(config.retryConfig); |
| 71 | |
| 72 | this.axios = axios.create({ |
| 73 | baseURL: config.baseURL, |
| 74 | timeout: config.timeout || 30000, |
| 75 | headers: { |
| 76 | 'Content-Type': 'application/json', |
| 77 | 'User-Agent': '{APIName}-Client/1.0.0', |
| 78 | ...config.defaultHeaders, |
| 79 | }, |
| 80 | }); |
| 81 | |
| 82 | // Request interceptor for auth |
| 83 | this.axios.interceptors.request.use( |
| 84 | async (config) => { |
| 85 | await this.rateLimiter.wait(); |
| 86 | return this.auth.addAuthHeaders(config); |
| 87 | }, |
| 88 | (error) => Promise.reject(error) |
| 89 | ); |
| 90 | |
| 91 | // Response interceptor for retry logic |
| 92 | this.axios.interceptors.response.use( |
| 93 | (response) => response, |
| 94 | async (error) => { |
| 95 | if (this.retryHandler.shouldRetry(error)) { |
| 96 | return this.retryHandler.retry(error); |
| 97 | } |
| 98 | return Promise.reject(this.handleError(error)); |
| 99 | } |
| 100 | ); |
| 101 | } |
| 102 | |
| 103 | private handleError(error: any): Error { |
| 104 | if (error.response?.status === 401) { |
| 105 | return new AuthenticationError('Invalid API credentials'); |
| 106 | } |
| 107 | if (error.response?.status === 429) { |
| 108 | return new RateLimitError('Rate limit exceeded'); |
| 109 | } |
| 110 | if (error.response?.data?.message) { |
| 111 | return new APIError(error.response.data.message, error.response.status); |
| 112 | } |
| 113 | return new APIError('Unknown API error', error.response?.status); |
| 114 | } |
| 115 | |
| 116 | // Generated methods for each endpoint |
| 117 | async listCustomers(params?: ListCustomersParams): Promise<APIResponse<Customer[]>> { |
| 118 | const response = await this.axios.get('/customers', { params }); |
| 119 | return response.data; |
| 120 | } |
| 121 | |
| 122 | async createCustomer(data: CreateCustomerData): Promise<APIResponse<Customer>> { |
| 123 | const response = await this.axios.post('/customers', data); |
| 124 | return response.data; |
| 125 | } |
| 126 | |
| 127 | // ... more generated methods |
| 128 | } |
| 129 | ``` |
| 130 | |
| 131 | ### 4. Authentication Handler |
| 132 | |
| 133 | ```typescript |
| 134 | // auth.ts |
| 135 | import { AxiosRequestConfig } from 'axios'; |
| 136 | |
| 137 | export type AuthConfig = |
| 138 | | { type: 'api_key'; key: string; header?: string } |
| 139 | | { type: 'bearer'; token: string } |
| 140 | | { type: 'oauth'; clientId: string; clientSecret: string; tokenUrl: string } |
| 141 | | { type: 'basic'; username: string; password: string }; |
| 142 | |
| 143 | export class AuthHandler { |
| 144 | private config: AuthConfig; |
| 145 | private accessToken?: string; |
| 146 | private tokenExpiry?: Date; |
| 147 | |
| 148 | constructor(config: AuthConfig) { |
| 149 | this.config = config; |
| 150 | } |
| 151 | |
| 152 | async addAuthHeaders(axiosConfig: AxiosRequestConfig): Promise<AxiosR |