.cursor/skills/api-defining/SKILL.md
Generate TypeScript API client code from cURL commands. Use when asked to create API functions, service endpoints, or define API calls from cURL examples.
npx skillsauth add hadat112/BASE-AI-FE-Template api-definingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate TypeScript API client code for a Next.js app project based on provided cURL commands.
IMPORTANT: This skill only applies when cURL command examples are provided. If no cURL example is available, inform the user that at least one valid cURL command is required and do not create any API functions.
src/services/ using the existing service style.src/interfaces/ per the interface guidelines.import { api } from "@/services";api from src/services.userService, authService).getX, listX, createX, updateX, deleteX.export const getUsers = () => api.get<User[]>("/users").api.get<T>(path, { params }) for GET with query params.api.post<T>(path, data, config?), api.put<T>, api.patch<T>, api.delete<T> for others.T using interfaces defined in the service file or from src/interfaces.data variable is typed).response.data directly via interceptors, so the generic T represents the actual response data.`/users/${id}` (not `users/${id}`).`/users/${id}`.{ params } on GET (as inferred from the cURL command URL).config argument.FormData and set Content-Type: multipart/form-data in headers (as shown in the cURL command).api call directly. Do not wrap in extra try/catch unless a header/timeout is required or clear error handling is present in the cURL usage.*.service.ts file (e.g., user.service.ts, auth.service.ts).export * from "./<feature>.service"; to src/services/index.ts if new service files are created.// Option 1: Individual exports (preferred, matches current codebase)
import { api } from "@/services";
import type { User, CreateUserRequest } from "@/interfaces";
// GET all resources
export const getUsers = () => api.get<User[]>("/users");
// GET single resource with path parameter
export const getUser = (id: number) => api.get<User>(`/users/${id}`);
// GET with query parameters
export const searchUsers = (params: { q: string; page?: number }) =>
api.get<User[]>("/users/search", { params });
// POST with typed body
export const createUser = (data: CreateUserRequest) =>
api.post<User>("/users", data);
// PUT with path parameter and partial data
export const updateUser = (id: number, data: Partial<User>) =>
api.put<User>(`/users/${id}`, data);
// DELETE with path parameter
export const deleteUser = (id: number) => api.delete(`/users/${id}`);
// Option 2: Grouped exports (also acceptable)
export const userService = {
getUsers: () => api.get<User[]>("/users"),
getUser: (id: number) => api.get<User>(`/users/${id}`),
createUser: (data: CreateUserRequest) => api.post<User>("/users", data),
updateUser: (id: number, data: Partial<User>) =>
api.put<User>(`/users/${id}`, data),
deleteUser: (id: number) => api.delete(`/users/${id}`),
};
src/interfaces/.token.ts, trade.ts, profile.ts, etc.), add new interfaces there. Otherwise create a new file with a descriptive name.CreateItemRequest, ItemResponse, ItemsResponse).src/interfaces/index.ts.string, number, boolean).? when not guaranteed by the API.status: "active" | "disabled").string for ISO dates unless otherwise guaranteed.IPaginationParams if appropriate and define a corresponding ...Response shape that matches fields shown in the cURL command result.// src/interfaces/item.ts
export interface CreateItemRequest {
name: string;
description?: string;
}
export interface Item {
id: string;
name: string;
description?: string;
createdAt: string;
}
export interface CreateItemResponse {
item: Item;
}
export interface ListItemsResponse {
items: Item[];
total: number;
}
And update the barrel:
// src/interfaces/index.ts
export * from "./item";
import { api } from '@/services'; in service files.api calls./users, /tokens/${address}, etc.IPaginationParams, IResponse<T>, etc., when applicable.response.data directly, so type the generic T as the actual response data structure.For each endpoint in the provided cURL command(s):
src/services/*.service.ts file.src/interfaces/ with proper exports (and re-export in src/interfaces/index.ts).NEXT_PUBLIC_API_BASE_URL.src/lib/ApiClient.ts and exported from src/services/index.ts.localStorage.getItem("accessToken").BEFORE PROCEEDING: Verify that at least one clear and valid cURL command is provided. If no example is available:
After generating all functions and interfaces, double-check imports/exports and that function signatures reference the correct types from src/interfaces.
Note: API functions will only be defined based on provided cURL command examples. No endpoints will be created without clear cURL samples describing path, method, headers, and payload.
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
development
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
tools
Add responsive support to an existing component. Use when asked to make a component responsive, add mobile/tablet support, or adapt layout for different screen sizes.
tools
Generate React components from multiple Figma design links sequentially using Figma MCP. Use when given a list of Figma links to convert to components.