基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill openapi-types命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
LLM token logprobs and calibration. Per-decision confidence, ECE, Brier, reliability diagrams, low-confidence triage.
Analyze LLM token logprobs and calibration. Use for per-decision confidence, ECE, Brier scores, reliability diagrams, and low-confidence triage.
回顾最近 N 天的 Claude Code 使用记录——扫描原始会话数据,按主题分组汇总"我都做了什么",并从个人操作系统视角输出模式、风险与增删建议。当用户说 /recap、"看看我这几天做了什么"、"回顾一下我最近的会话"、"这两天我用 claude 干了啥"、"活动回顾" 时使用。
| name | openapi-types |
| description | Generate TypeScript types and client SDKs from OpenAPI specs |
| disable-model-invocation | true |
I'll generate TypeScript types, client SDKs, and Zod schemas from OpenAPI 3.0 specifications.
Arguments: $ARGUMENTS - path to OpenAPI spec file
Features:
/api-docs-generateThis skill uses code generation-specific patterns to minimize token usage:
Pattern: Cache parsed OpenAPI specification structure
.openapi-types-cache (1 hour TTL)Pattern: Use openapi-generator-cli or swagger-cli for validation
swagger-cli validate spec.yaml (200 tokens)Pattern: Use openapi-typescript or openapi-generator templates
openapi-typescript spec.yaml -o types.ts (300 tokens)Pattern: Detect if types already generated and current
Pattern: Analyze first 20 schemas for patterns
Pattern: Generate only changed schemas
Pattern: Cache openapi-typescript installation status
Pattern: Use openapi-typescript tool directly
Typical operation patterns:
Expected per-generation: 2,000-3,000 tokens (50% reduction from 4,000-6,000 baseline) Real-world average: 900 tokens (due to cached specs, early exit, tool-based generation)
#!/bin/bash
# Detect OpenAPI specifications
echo "=== Detecting OpenAPI Specifications ==="
echo ""
# Find OpenAPI spec files
find_openapi_specs() {
find . -type f \( \
-name "openapi*.yaml" -o \
-name "openapi*.yml" -o \
-name "swagger*.json" -o \
-name "swagger*.yaml" -o \
-name "api-spec*.yaml" \
\) ! -path "*/node_modules/*" 2>/dev/null
}
SPECS=$(find_openapi_specs)
if [ -z "$SPECS" ]; then
echo "❌ No OpenAPI specifications found"
echo ""
echo "Looking for files like:"
echo " - openapi.yaml"
echo " - swagger.json"
echo " - docs/api-spec.yaml"
echo ""
echo "💡 Generate OpenAPI spec with: claude \"/api-docs-generate\""
exit 1
fi
echo "✓ Found OpenAPI specifications:"
echo "$SPECS" | sed 's/^/ /'
echo ""
# Select spec file
if [ -n "" ];
SPEC_FILE=
SPEC_FILE=$( | -1)
[ ! -f ];
1
() {
-v swagger-cli &> /dev/null;
npx swagger-cli validate
}
validate_spec
// Generated TypeScript types from OpenAPI spec
// Auto-generated - do not edit manually
/**
* OpenAPI spec: ${SPEC_FILE}
* Generated: ${DATE}
*/
export namespace API {
/**
* Common types
*/
export type UUID = string;
export type ISODate = string;
export type Email = string;
/**
* User schema
*/
export interface User {
/** Unique user identifier */
id: UUID;
/** User's email address */
email: Email;
/** User's display name */
name: string;
/** User role for authorization */
role: 'admin' | 'user' | 'guest';
/** Account creation timestamp */
createdAt: ISODate;
/** Last update timestamp */
updatedAt: ISODate;
/** Optional user profile */
profile?: UserProfile;
}
/**
* User profile schema
*/
export {
?: ;
?: ;
?: ;
?: {
?: ;
?: ;
?: ;
};
}
{
: ;
: ;
: ;
?: | ;
}
{
?: ;
?: <>;
}
{
: ;
: ;
}
{
: ;
?: ;
}
{
: [];
: ;
}
{
: ;
: ;
: ;
}
{
: {
: ;
: ;
?: <, >;
};
: ;
}
{
: ;
: ;
: ;
: ;
: ;
: ;
}
{
?: ;
?: ;
?: ;
?: | | ;
?: | ;
}
{
: ;
}
{
= ;
= ;
= ;
= ;
= ;
= ;
= ;
}
}
// Zod schemas for runtime validation
import { z } from 'zod';
/**
* User schema
*/
export const UserSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
name: z.string().min(1).max(255),
role: z.enum(['admin', 'user', 'guest']),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
profile: z
.object({
bio: z.string().optional(),
avatarUrl: z.string().url().optional(),
location: z.string().optional(),
socialLinks: z
.object({
twitter: z.string().url().optional(),
github: z.().().(),
: z.().().(),
})
.(),
})
.(),
});
= z.< >;
= z.({
: z.().(),
: z.().().(),
: z.().().(),
: z.([, ]).(),
});
= z.< >;
= z.({
: z.().().().(),
: z
.({
: z.().(),
: z.().().(),
: z.().(),
})
.()
.(),
});
= z.< >;
= z.({
: z.().(),
: z.().(),
});
= z.< >;
= z.({
: ,
: z.().(),
});
= z.< >;
= z.({
: z.(),
: z.({
: z.().().(),
: z.().().(),
: z.().().(),
: z.().().(),
: z.(),
: z.(),
}),
});
= z.< >;
= z.({
: z.({
: z.(),
: z.(),
: z.(z.()).(),
}),
: z.().(),
});
= z.< >;
(): {
.(data);
}
(): {
.(data);
}
(): data is {
.(data).;
}
// Type-safe fetch client SDK
import type { API } from './types';
/**
* API client configuration
*/
export interface ClientConfig {
baseURL: string;
headers?: Record<string, string>;
timeout?: number;
}
/**
* API client error
*/
export class APIError extends Error {
constructor(
public status: number,
public code: string,
message: string,
public details?: unknown
) {
super(message);
this.name = 'APIError';
}
}
/**
* Type-safe API client
*/
export class APIClient {
private baseURL: string;
private headers: Record<string, string>;
: ;
() {
. = config..(, );
. = {
: ,
...config.,
};
. = config. || ;
}
(: ): {
.[] = ;
}
(): {
.[];
}
request<T>(
: ,
: ,
?: {
?: <, >;
?: ;
?: <, >;
}
): <T> {
url = ();
(options?.) {
.(options.).( {
(value !== && value !== ) {
url..(key, (value));
}
});
}
controller = ();
timeoutId = ( controller.(), .);
{
response = (url.(), {
method,
: { ...., ...options?. },
: options?. ? .(options.) : ,
: controller.,
});
(timeoutId);
(!response.) {
error = response.().( ({}));
(
response.,
error.?. || ,
error.?. || response.,
error.?.
);
}
(response. === ) {
T;
}
response.();
} (error) {
(timeoutId);
(error ) {
error;
}
(error && error. === ) {
(, , );
}
(
,
,
error ? error. :
);
}
}
users = {
:
.<.>(, , { params }),
:
.<.>(, ),
:
.<.>(, , { : data }),
:
.<.>(, , {
: data,
}),
:
.<>(, ),
};
auth = {
:
.<.>(, , {
: data,
}),
: .<>(, ),
};
}
(): {
(config);
}
apiClient = ({
: process.. || ,
});
// React hooks for data fetching
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import type { API } from './types';
import { apiClient } from './client';
/**
* Hook to list users
*/
export function useUsers(params?: API.ListUsersParams) {
return useQuery({
queryKey: ['users', params],
queryFn: () => apiClient.users.list(params),
});
}
/**
* Hook to get user by ID
*/
export function useUser(userId: string) {
return useQuery({
queryKey: ['users', userId],
queryFn: () => apiClient.users.get(userId),
enabled: !!userId,
});
}
/**
* Hook to create user
*/
export function useCreateUser() {
const queryClient = useQueryClient();
return ({
:
apiClient..(data),
: {
queryClient.({ : [] });
},
});
}
() {
queryClient = ();
({
: apiClient..(userId, data),
: {
queryClient.({ : [, variables.] });
queryClient.({ : [] });
},
});
}
() {
queryClient = ();
({
: apiClient..(userId),
: {
queryClient.({ : [] });
},
});
}
() {
({
: apiClient..(data),
: {
apiClient.(response.);
.(, response.);
},
});
}
() {
queryClient = ();
({
: apiClient..(),
: {
apiClient.();
.();
queryClient.();
},
});
}
// Example: Using the generated client in a React component
import { useUsers, useCreateUser } from './api/hooks';
export function UsersPage() {
const { data, isLoading, error } = useUsers({ page: 1, limit: 10 });
const createUser = useCreateUser();
const handleCreateUser = async () => {
try {
await createUser.mutateAsync({
email: 'user@example.com',
name: 'John Doe',
password: 'secure-password',
});
alert('User created!');
} catch (error) {
console.error('Failed to create user:', error);
}
};
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
Users
Create User
{data?.data.map((user) => (
{user.name}
))}
);
}
// Example: Using the client directly (non-React)
import { apiClient } from './api/client';
async function fetchUsers() {
try {
const response = await apiClient.users.list({ page: 1, limit: 10 });
console.log('Users:', response.data);
console.log('Pagination:', response.pagination);
} catch (error) {
if (error instanceof APIError) {
console.error(`API Error (${error.status}):`, error.message);
} else {
console.error('Unknown error:', error);
}
}
}
echo ""
echo "=== ✓ OpenAPI Type Generation Complete ==="
echo ""
echo "📁 Generated files:"
echo " - src/api/types.ts # TypeScript types"
echo " - src/api/schemas.ts # Zod validation schemas"
echo " - src/api/client.ts # Fetch client SDK"
echo " - src/api/hooks.ts # React hooks"
echo ""
echo "📦 Install dependencies:"
echo " npm install zod @tanstack/react-query"
echo ""
echo "🚀 Usage:"
echo ""
echo "# In React components:"
echo "import { useUsers, useCreateUser } from './api/hooks';"
echo ""
echo "# Direct client usage:"
echo "import { apiClient } from './api/client';"
echo "const users = await apiClient.users.list();"
echo ""
echo "💡 Integration points:"
echo " - /api-docs-generate - Generate OpenAPI spec"
echo " - /api-test-generate - Generate API tests"
echo
Type Safety:
Client SDK:
Integration Points:
/api-docs-generate - OpenAPI spec generation/api-test-generate - API tests/mock-generate - Mock dataImportant: I will NEVER add AI attribution.
Credits: Based on openapi-typescript, Zod, React Query, and API client patterns from tRPC, GraphQL clients, and REST API best practices.