用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/carrot-foundation/schemas --skill update-examples命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Schema version injection, $id format, and SCHEMA_VERSION environment variable
Generated JSON Schema structure — required fields, validation patterns, and $ref usage
Use when a task is complete and needs the full check, commit, and PR workflow
基于 SOC 职业分类
正在显示 SKILL.md
| name | update-examples |
| description | Use when schemas have changed and example JSON files need regeneration and validation |
Regenerate all JSON schema artifacts, examples, and hashes after modifying Zod source schemas.
Never edit generated files manually. All JSON schemas, examples, and hashes under schemas/ipfs/ are generated from the Zod source schemas. If the output is wrong, fix the Zod source.
Run each step in order. Each step depends on the previous one.
Compile TypeScript to JavaScript so the generation scripts can import the schemas:
pnpm build
Expected outcome: dist/ directory is created with ESM and CJS output.
If it fails: Fix TypeScript compilation errors first (see debug skill).
Convert Zod schemas to JSON Schema format:
pnpm generate-schemas
This runs pnpm build as a prerequisite (via pregenerate-ipfs-schemas), then executes node scripts/generate-ipfs-schemas.js.
Expected outcome: JSON schema files appear or update under schemas/ipfs/{type}/.
If it fails:
.meta() -- missing metadata causes empty descriptionssrc/index.tsz.transform may not convert cleanly)Compute content hashes for all generated JSON schemas:
pnpm hash-schemas
This runs node scripts/hash-schemas.js.
Expected outcome: Hash files are updated alongside JSON schemas.
If it fails: Usually means a schema file is malformed JSON -- check the previous step's output.
Regenerate example JSON files from the schemas:
pnpm update-examples
This runs node scripts/update-examples.js.
Expected outcome: Example JSON files are created or updated under schemas/ipfs/{type}/examples/.
If it fails: Check that the schema can produce valid example data. Some constraints (like strict regex patterns) may need example values in .meta().
Run AJV validation on all generated JSON schemas:
pnpm validate-schemas
This runs node scripts/validate-schemas.js.
Expected outcome: All schemas pass validation. Output shows each schema checked with a pass/fail status.
If it fails:
$id URLs match the expected pattern$ref pointers target existing schemasCheck that schema versions are consistent:
pnpm verify-schema-versions
This runs node scripts/verify-schema-versions.js.
Expected outcome: All schema versions are consistent between filenames and content.
If it fails: Update the version field in the Zod source schema to match the expected version.
Validate internal $ref pointers between schemas:
pnpm check-refs
This runs node scripts/check-refs.js.
Expected outcome: All $ref pointers resolve to existing schemas.
If it fails: Ensure referenced schemas exist and paths are correct.
Run validation specifically on example data files:
pnpm validate-examples
This runs node scripts/validate-schemas.js --data-only.
Expected outcome: All example files validate against their corresponding schemas.
If it fails: Example data doesn't conform to the schema. Since examples are generated, this usually means the generation script has a bug. Fix the script or the Zod source.
If you want to run steps 2-8 in a single command:
pnpm validate-all
This runs: generate-schemas -> hash-schemas -> update-examples -> validate-schemas -> verify-schema-versions -> check-refs -> validate-examples.
This matches the canonical pipeline order used above.
After regeneration, review what changed:
# See which files changed
git diff --stat schemas/
# See the actual changes
git diff schemas/
# Check for new untracked files
git status schemas/
Expected changes:
schemas/ipfs/{type}/*.json files (schema definitions)schemas/ipfs/{type}/examples/*.json files (example data)Unexpected changes:
| Issue | Cause | Fix |
|---|---|---|
Empty description in JSON schema | Missing .meta() on the Zod field | Add .meta({ description: '...' }) |
Wrong $id URL | Schema name or version mismatch | Fix the schema name/version in Zod source |
| Missing schema in output | Not exported from src/index.ts | Add to barrel export |
| Stale hashes | Forgot to run hash-schemas after generation | Run pnpm hash-schemas |
| Example doesn't match schema | Schema changed but examples weren't regenerated | Run pnpm update-examples |
| Extra properties in example | Zod .default() or .transform() adding fields | Review the Zod schema for unintended defaults |
| Version mismatch | Schema version in code doesn't match filename | Align version in Zod source |
This skill is typically run as part of:
pnpm check includes all these stepsYou can also run it standalone when iterating on schema changes to verify output before committing.
When actively developing schemas, use this iterative workflow:
pnpm generate-schemas to see JSON outputcat schemas/ipfs/{type}/v*.json | head -50pnpm validate-allpnpm test