用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/carrot-foundation/schemas --skill rule-json-schema命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | rule-json-schema |
| description | Generated JSON Schema structure — required fields, validation patterns, and $ref usage |
Apply this rule whenever work touches:
schemas/**/*.schema.jsonJSON Schema files in the schemas/ directory are generated artifacts — they are produced from Zod schemas via pnpm generate-ipfs-schemas. Never edit them manually. If a JSON Schema has an issue, fix it in the Zod source schema.
# Build the project, then generate JSON schemas from Zod definitions
pnpm generate-ipfs-schemas
# Validate all generated schemas
pnpm validate-schemas
The generation pipeline:
tsup into dist/schemas/ directory organized by typeEvery generated JSON Schema must include these top-level fields:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/carrot-foundation/schemas/refs/tags/v{version}/schemas/ipfs/{type}/{type}.schema.json",
"title": "Human-Readable Schema Title",
"description": "Comprehensive description of what this schema validates",
"type": "object",
"properties": { ... },
"required": ["field1", "field2"],
"additionalProperties": false
}
If any of these fields are missing in the output, the issue is in the Zod source — fix the .meta() and schema structure there.
$id URL formatSchema $id values follow a strict URL format using GitHub raw content URLs with git tags:
https://raw.githubusercontent.com/carrot-foundation/schemas/refs/tags/v{version}/schemas/ipfs/{type}/{type}.schema.json
Where:
{version} — the schema version (from SCHEMA_VERSION env var or package.json){type} — the schema type in kebab-case (e.g., mass-id, certificate)The version is injected at build time — see the schema-versioning rule for details.
Every property in the generated JSON Schema must have a description. This comes from the Zod schema's .meta({ description: '...' }). If a property lacks a description in the output, add .meta() to the Zod source field.
{
"properties": {
"waste_type": {
"type": "string",
"description": "Category or type of waste material",
"minLength": 1,
"maxLength": 100
}
}
}
Use JSON Schema format for well-known string formats. These are generated from Zod's built-in validators:
| Zod validator (Zod 4.x) | JSON Schema format |
|---|---|
z.email() | "email" |
z.url() | "uri" |
z.uuidv4() | "uuid" |
z.iso.datetime() | "date-time" |
z.iso.date() | "date" |
z.ipv4() / z.ipv6() | "ipv4" / "ipv6" |
$defs and $refCommon structures should be defined in $defs and referenced via $ref:
{
"$defs": {
"Coordinates": {
"type": "object",
"properties": {
"latitude": { "type": "number", "minimum": -90, "maximum": 90 },
"longitude": { "type": "number", "minimum": -180, "maximum": 180 }
},
"required": ["latitude", "longitude"],
"additionalProperties": false
This is driven by schema extraction in Zod — when you extract a named Zod schema, it becomes an entry under $defs in the generated output.
ISO 8601 datetime strings use "format": "date-time":
"created_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the record was created"
}
IDs referencing external systems use UUID format:
"external_id": {
"type": "string",
"format": "uuid",
"description": "UUID identifier for external system references"
}
SHA-256 hashes use pattern validation:
"id_hash": {
"type": "string",
"pattern": "^[a-f0-9]{64}$",
"description": "SHA-256 hash identifier"
}
Attributes follow the OpenSea metadata standard with trait_type, value, and optional display_type:
"attributes": {
"type": "array",
"items": { "$ref": "#/$defs/NftAttribute" },
"description": "NFT metadata attributes following OpenSea standard"
}
Run pnpm validate-schemas after generation to verify all schemas are structurally correct. This checks:
$ref targets resolve correctlyadditionalProperties: false is set on all objectsWhen a generated JSON Schema has a problem:
.schema.ts file.meta(), fix validation, adjust structurepnpm generate-ipfs-schemaspnpm validate-schemasNever manually patch the JSON output. It will be overwritten on the next generation.