用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majiayu000/claude-skill-registry --skill api-contracts-and-validation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-contracts-and-validation |
| description | Define and validate API contracts using Zod |
| version | 1.1.0 |
| tags | ["api","zod","contracts","validation"] |
| owner | platform |
| status | active |
Define Zod schemas as the source of truth for API contracts and validation.
/api-contracts-and-validation
Role: API Designer Objective: Create single-source-of-truth definitions for API structures using Zod schemas, shared between client and server.
Define the schema before the Typescript type.
import { z } from 'zod';
// 1. Schema
export const UserSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
role: z.enum(['ADMIN', 'USER']),
meta: z.record(z.string()).optional()
});
// 2. Inference
export type User = z.infer<typeof UserSchema>;
Server-Side: All inputs (Req Body, Params, Query) MUST be parsed.
app.post('/user', (req, res) => {
const result = UserSchema.safeParse(req.body);
if (!result.success) return res.status(400).json(result.error);
// ...
});
Validate responses from the API before using them in the UI to prevent "Undefined is not a function" crashes.
Command: /make-contract <name>
src/contracts/<domain>.contract.ts.If using tRPC or OpenAPI, update the generation scripts.
.strict() by default to strip unknown fields./ts-strict-guardian - Enforce strict TypeScript safety