schema-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSchema Creator Skill
Schema Creator Skill
WARNING: DO NOT WRITE DIRECTLY TO .claude/schemas/Schema files are protected by(Gate 4 in CLAUDE.md). Direct writes bypass post-creation steps (catalog updates, consumer assignment, integration verification). Always use theunified-creator-guard.cjsskill workflow for creating schemas. Direct writes create "invisible artifacts" that no validator or agent can discover.schema-creator
Creates JSON Schema validation files for the Claude Code Enterprise Framework. Schemas enforce type safety, input validation, and structural consistency across skills, agents, hooks, workflows, and custom data structures.
警告:请勿直接写入 .claude/schemas/ 目录Schema文件受保护(详见CLAUDE.md中的第4关)。 直接写入会跳过创建后的步骤(目录更新、消费者分配、集成验证)。 创建Schema时请始终使用unified-creator-guard.cjsSkill工作流。 直接写入会创建“不可见工件”,导致验证器或Agent无法发现它们。schema-creator
为Claude Code Enterprise Framework创建JSON Schema验证文件。Schema可在Skill、Agent、Hook、工作流和自定义数据结构中强制执行类型安全、输入验证和结构一致性。
SYSTEM IMPACT ANALYSIS (CRITICAL - DO NOT SKIP)
系统影响分析(关键步骤 - 请勿跳过)
After creating ANY schema, you MUST:
- Register in appropriate location (global vs skill-local)
- Update related validators to use the new schema
- Add schema reference to CLAUDE.md if globally significant
Verification:
bash
undefined创建任何Schema后,您必须执行以下操作:
- 在适当位置注册(全局或Skill本地)
- 更新相关验证器以使用新Schema
- 如果具有全局重要性,将Schema引用添加到CLAUDE.md中
验证操作:
bash
undefinedVerify schema is valid JSON
验证Schema是否为合法JSON
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/<schema-name>.json'))"
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/<schema-name>.json'))"
Check schema exists
检查Schema是否存在
ls .claude/schemas/<schema-name>.json || ls .claude/skills/<skill>/schemas/<schema-name>.json
**WHY**: Invalid schemas cause silent validation failures. Unregistered schemas are never used.
---ls .claude/schemas/<schema-name>.json || ls .claude/skills/<skill>/schemas/<schema-name>.json
**原因**:无效Schema会导致静默验证失败,未注册的Schema永远不会被使用。
---Purpose
用途
Schemas provide structured validation for:
- Skill Inputs/Outputs - Validate data passed to and from skills
- Agent Definitions - Validate agent YAML frontmatter and structure
- Hook Definitions - Validate hook configuration and registration
- Workflow Definitions - Validate workflow steps and configuration
- Custom Data Structures - Validate project-specific data formats
Schema为以下内容提供结构化验证:
- Skill输入/输出 - 验证传入和传出Skill的数据
- Agent定义 - 验证Agent的YAML前置内容和结构
- Hook定义 - 验证Hook的配置和注册信息
- 工作流定义 - 验证工作流步骤和配置
- 自定义数据结构 - 验证项目特定的数据格式
Schema Types
Schema类型
| Type | Location | Purpose |
|---|---|---|
| Skill Input | | Validate skill invocation inputs |
| Skill Output | | Validate skill execution outputs |
| Agent Definition | | Validate agent YAML frontmatter |
| Skill Definition | | Validate skill YAML frontmatter |
| Hook Definition | | Validate hook configuration |
| Workflow Definition | | Validate workflow structure |
| Custom | | Project-specific validation |
| 类型 | 位置 | 用途 |
|---|---|---|
| Skill输入 | | 验证Skill调用输入 |
| Skill输出 | | 验证Skill执行输出 |
| Agent定义 | | 验证Agent的YAML前置内容 |
| Skill定义 | | 验证Skill的YAML前置内容 |
| Hook定义 | | 验证Hook配置和注册信息 |
| 工作流定义 | | 验证工作流结构 |
| 自定义Schema | | 项目特定验证 |
Reference Schema
参考Schema
Use as the canonical reference schema.
.claude/schemas/agent-definition.schema.jsonBefore finalizing any schema, compare against reference:
- Follows JSON Schema draft-07 or later (draft-2020-12 preferred)
- Has $schema, $id, title, description, type fields
- Required fields are documented in "required" array
- All properties have description fields
- Includes examples where helpful
- Uses proper patterns (kebab-case names, semver versions)
请将作为标准参考Schema。
.claude/schemas/agent-definition.schema.json在最终确定任何Schema之前,请与参考Schema进行对比:
- 遵循JSON Schema draft-07或更高版本(推荐使用draft-2020-12)
- 包含$schema、$id、title、description、type字段
- 必填字段已在"required"数组中记录
- 所有属性都有description字段
- 在需要时包含示例
- 使用正确的格式(短横线命名法、语义化版本号)
CLAUDE.md Registration (MANDATORY)
CLAUDE.md注册(强制要求)
After creating a schema, update CLAUDE.md if the schema enables new capabilities:
- New artifact type schema - Add to relevant section (Section 3 for agents, Section 8.5 for skills)
- Agent/skill/workflow validation schema - Document in Section 4 (Self-Evolution)
- Framework-wide schema - Add to Existing Schemas Reference table in this skill
Verification:
bash
grep "schema-name" .claude/CLAUDE.md || echo "WARNING: Schema not registered in CLAUDE.md"BLOCKING: Schema without documentation may not be discovered by other agents.
创建Schema后,如果该Schema支持新功能,请更新CLAUDE.md:
- 新工件类型Schema - 添加到相关章节(Agent相关内容见第3节,Skill相关内容见第8.5节)
- Agent/Skill/工作流验证Schema - 在第4节(自我演进)中记录
- 框架级Schema - 添加到本Skill的现有Schema参考表格中
验证操作:
bash
grep "schema-name" .claude/CLAUDE.md || echo "警告:Schema未在CLAUDE.md中注册"阻塞项:未记录的Schema可能无法被其他Agent发现。
Workflow
工作流
Step 0: Research Synthesis (MANDATORY - ALWAYS FIRST)
步骤0:研究综合(强制要求 - 必须首先执行)
BEFORE creating ANY schema, invoke research-synthesis:
javascript
Skill({ skill: 'research-synthesis' });Research Requirements:
- Minimum 3 Exa searches for JSON Schema best practices
- Review existing schemas in for patterns
.claude/schemas/ - Check schema catalog at
.claude/context/artifacts/catalogs/schema-catalog.md - Identify similar schemas that can be used as references
- Document research findings before proceeding
Why: Research-synthesis ensures schemas follow industry best practices and maintain consistency with existing framework schemas.
在创建任何Schema之前,请调用research-synthesis:
javascript
Skill({ skill: 'research-synthesis' });研究要求:
- 至少进行3次关于JSON Schema最佳实践的Exa搜索
- 查看中的现有Schema以了解格式模式
.claude/schemas/ - 检查中的Schema目录
.claude/context/artifacts/catalogs/schema-catalog.md - 识别可作为参考的类似Schema
- 在继续之前记录研究结果
原因:研究综合确保Schema遵循行业最佳实践,并与现有框架Schema保持一致性。
Step 1: Existence Check and Updater Delegation (MANDATORY - SECOND STEP)
步骤1:存在性检查与更新器委托(强制要求 - 第二步)
BEFORE creating any schema file, check if it already exists:
-
Check if schema already exists:bash
test -f .claude/schemas/<schema-name>.json && echo "EXISTS" || echo "NEW" -
If schema EXISTS:
-
DO NOT proceed with creation
-
Invoke artifact-updater workflow instead:javascript
Skill({ skill: 'artifact-updater', args: { name: '<schema-name>', changes: '<description of requested changes>', justification: 'Update requested via schema-creator', }, }); -
Return updater result and STOP
-
-
If schema is NEW:
- Continue with Step 1.5 below
在创建任何Schema文件之前,请检查它是否已存在:
-
检查Schema是否已存在:bash
test -f .claude/schemas/<schema-name>.json && echo "已存在" || echo "新Schema" -
如果Schema已存在:
-
请勿继续创建
-
请改为调用artifact-updater工作流:javascript
Skill({ skill: 'artifact-updater', args: { name: '<schema-name>', changes: '<所需更改的描述>', justification: '通过schema-creator请求更新', }, }); -
返回更新器结果并停止操作
-
-
如果Schema是新的:
- 继续以下步骤1.5
Step 1.5: Companion Check
步骤1.5:配套检查
Before proceeding with creation, run the ecosystem companion check:
- Use from
companion-check.cjs.claude/lib/creators/companion-check.cjs - Call to identify companion artifacts
checkCompanions("schema", "{schema-name}") - Review the companion checklist — note which required/recommended companions are missing
- Plan to create or verify missing companions after this artifact is complete
- Include companion findings in post-creation integration notes
This step is informational (does not block creation) but ensures the full artifact ecosystem is considered.
在开始创建之前,请运行生态系统配套检查:
- 使用中的
.claude/lib/creators/companion-check.cjscompanion-check.cjs - 调用以识别配套工件
checkCompanions("schema", "{schema-name}") - 查看配套清单 - 记录缺少的必填/推荐配套项
- 计划在完成此工件后创建或验证缺失的配套项
- 在创建后集成说明中包含配套检查结果
此步骤为信息性步骤(不会阻止创建),但确保考虑了完整的工件生态系统。
Step 2: Gather Schema Requirements
步骤2:收集Schema需求
Before creating a schema, understand:
1. WHAT data structure are you validating?
- Skill input/output
- Agent/skill/hook/workflow definition
- Custom data format
2. WHERE should the schema live?
- Global: .claude/schemas/ (framework-wide)
- Local: .claude/skills/{skill}/schemas/ (skill-specific)
3. WHAT are the required vs optional fields?
- Required: Must be present for valid data
- Optional: Enhance but not required
4. WHAT are the validation rules?
- Types (string, number, boolean, object, array)
- Patterns (regex for strings)
- Ranges (min/max for numbers)
- Enums (allowed values)
- Lengths (min/max for strings/arrays)在创建Schema之前,请明确:
1. 您要验证的数据结构是什么?
- Skill输入/输出
- Agent/Skill/Hook/工作流定义
- 自定义数据格式
2. Schema应存放在哪里?
- 全局位置:.claude/schemas/(框架级)
- 本地位置:.claude/skills/{skill}/schemas/(Skill特定)
3. 必填字段与可选字段分别是什么?
- 必填字段:数据有效必须包含的字段
- 可选字段:增强功能但非必须的字段
4. 验证规则有哪些?
- 类型(字符串、数字、布尔值、对象、数组)
- 模式(字符串的正则表达式)
- 范围(数字的最小值/最大值)
- 枚举(允许的值)
- 长度(字符串/数组的最小/最大长度)Step 3: Determine Schema Type and Location
步骤3:确定Schema类型和位置
| Creating For | Schema Location | Example |
|---|---|---|
| New skill inputs | | |
| New skill outputs | | |
| Global definition | | |
| Reusable component | | |
| 创建目标 | Schema位置 | 示例 |
|---|---|---|
| 新Skill输入 | | |
| 新Skill输出 | | |
| 全局定义 | | |
| 可复用组件 | | |
Step 4: Analyze Data Structure
步骤4:分析数据结构
Examine existing data or specify expected structure:
javascript
// Example: Analyzing skill output structure
const exampleOutput = {
success: true,
result: {
filesCreated: ['src/test.ts'],
testsGenerated: 5,
coverage: 85.2,
},
metadata: {
duration: 1234,
skill: 'test-generator',
},
};
// Extract schema from example:
// - success: boolean (required)
// - result: object (optional)
// - metadata: object (optional)检查现有数据或指定预期结构:
javascript
// 示例:分析Skill输出结构
const exampleOutput = {
success: true,
result: {
filesCreated: ['src/test.ts'],
testsGenerated: 5,
coverage: 85.2,
},
metadata: {
duration: 1234,
skill: 'test-generator',
},
};
// 从示例中提取Schema:
// - success:布尔值(必填)
// - result:对象(可选)
// - metadata:对象(可选)Step 5: Generate JSON Schema
步骤5:生成JSON Schema
Use the schema template and customize:
json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/{schema-name}",
"title": "{Schema Title}",
"description": "{What this schema validates}",
"type": "object",
"required": ["field1", "field2"],
"properties": {
"field1": {
"type": "string",
"description": "Description of field1",
"minLength": 1,
"maxLength": 100
},
"field2": {
"type": "number",
"description": "Description of field2",
"minimum": 0,
"maximum": 100
},
"optionalField": {
"type": "boolean",
"description": "Optional boolean field",
"default": false
}
},
"additionalProperties": false
}使用Schema模板并自定义:
json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/{schema-name}",
"title": "{Schema标题}",
"description": "{此Schema验证的内容}",
"type": "object",
"required": ["field1", "field2"],
"properties": {
"field1": {
"type": "string",
"description": "field1的描述",
"minLength": 1,
"maxLength": 100
},
"field2": {
"type": "number",
"description": "field2的描述",
"minimum": 0,
"maximum": 100
},
"optionalField": {
"type": "boolean",
"description": "可选布尔字段",
"default": false
}
},
"additionalProperties": false
}Step 6: Add Descriptions and Examples
步骤6:添加描述和示例
Every property MUST have a description:
json
{
"properties": {
"name": {
"type": "string",
"description": "The unique identifier for the resource in lowercase-with-hyphens format",
"pattern": "^[a-z][a-z0-9-]*$",
"examples": ["my-skill", "test-generator", "code-reviewer"]
}
}
}Add top-level examples:
json
{
"examples": [
{
"name": "example-skill",
"description": "An example skill for demonstration",
"version": "1.0.0"
}
]
}每个属性必须包含描述:
json
{
"properties": {
"name": {
"type": "string",
"description": "资源的唯一标识符,采用小写短横线格式",
"pattern": "^[a-z][a-z0-9-]*$",
"examples": ["my-skill", "test-generator", "code-reviewer"]
}
}
}添加顶级示例:
json
{
"examples": [
{
"name": "example-skill",
"description": "用于演示的示例Skill",
"version": "1.0.0"
}
]
}Step 7: Create Validation Test
步骤7:创建验证测试
Write a simple test to verify the schema works:
javascript
// validate-schema-test.cjs
const Ajv = require('ajv');
const schema = require('./.claude/schemas/my-schema.schema.json');
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
// Test valid data
const validData = {
/* valid example */
};
console.log('Valid:', validate(validData));
// Test invalid data
const invalidData = {
/* invalid example */
};
console.log('Invalid:', validate(invalidData));
console.log('Errors:', validate.errors);编写简单测试以验证Schema是否有效:
javascript
// validate-schema-test.cjs
const Ajv = require('ajv');
const schema = require('./.claude/schemas/my-schema.schema.json');
const ajv = new Ajv({ allErrors: true });
const validate = ajv.compile(schema);
// 测试有效数据
const validData = {
/* 有效示例 */
};
console.log('有效:', validate(validData));
// 测试无效数据
const invalidData = {
/* 无效示例 */
};
console.log('无效:', validate(invalidData));
console.log('错误:', validate.errors);Step 8: Post-Creation Schema Registration (Phase 1 Integration)
步骤8:创建后Schema注册(第一阶段集成)
This step is CRITICAL. After creating the schema artifact, you MUST register it in the schema discovery system.
Phase 1 Context: Phase 1 is responsible for discovering and cataloging schemas for validation. Schemas created without registration are invisible to validators and other systems that need them for data validation.
After schema file is written and validated:
-
Create/Update Schema Registry Entry in appropriate location:If registry doesn't exist, create:
.claude/context/artifacts/schema-catalog.mdjson{ "schemas": [ { "name": "{schema-name}", "id": "{schema-name}", "$id": "https://claude.ai/schemas/{schema-name}", "type": "{input|output|definition|global|component}", "description": "{What this schema validates}", "version": "1.0.0", "filePath": ".claude/schemas/{schema-name}.schema.json", "validatesFor": ["{artifact-type-1}", "{artifact-type-2}"], "relatedSchemas": [], "usedBy": ["{validator-hook}", "{creator-skill}"] } ] } -
Register with Validators:Update any validation hooks that should use this schema:
- Check for relevant validators
.claude/hooks/validation/ - Add schema to schemaMap in validators that need it
Example:javascriptconst schemaMap = { '.claude/agents/': '.claude/schemas/agent-definition.schema.json', '.claude/schemas/{schema-name}.schema.json': require('./.claude/schemas/{schema-name}.schema.json'), }; - Check
-
Document in:
.claude/context/artifacts/catalogs/schema-catalog.mdAdd entry to the schema catalog:markdown### {Schema Title} (`{schema-name}.schema.json`) **$id:** `https://claude.ai/schemas/{schema-name}` **Purpose:** {Detailed description of what this schema validates} **Used by:** - {Validator/hook 1} - {Creator skill 1} **Root properties:** - {property-1}: {description} - {property-2}: {description} **Example valid data:** ```json { "example": "value" } ```Required fields: {List required fields}Validation: When data matches this schema, {describe what is validated}undefined -
Updateif Schema Enables New Capabilities:
.claude/CLAUDE.mdIf this schema supports new artifact types or validation:- Add to relevant section (Section 4.1 for creator schemas, Section 9.7 for schemas directory)
- Add to "Existing Schemas Reference" table in Step 7 of this skill
Example entry:markdown| `{schema-name}` | `.claude/schemas/` | {Purpose} | -
Update Memory:Append to:
.claude/context/memory/learnings.mdmarkdown## Schema: {schema-name} - **Type:** {input|output|definition|global|component} - **Validates:** {What artifact/data type} - **Purpose:** {Detailed purpose} - **$id:** https://claude.ai/schemas/{schema-name} - **Validators:** {Which hooks/validators use it} - **Related Schemas:** {Any $ref references}
Why this matters: Without schema registration:
- Validators cannot discover and use schemas
- Data validation doesn't occur system-wide
- Invalid artifacts are created without detection
- "Invisible artifact" pattern emerges
Phase 1 Integration: Schema registry is the discovery mechanism for Phase 1, enabling validators to find and apply schemas consistently across the system.
此步骤至关重要。创建Schema工件后,您必须在Schema发现系统中注册它。
第一阶段背景:第一阶段负责发现和编目Schema以进行验证。未注册的Schema对验证器和其他需要它们进行数据验证的系统是不可见的。
Schema文件编写并验证完成后:
-
在适当位置创建/更新Schema注册表条目:如果注册表不存在,请创建:
.claude/context/artifacts/schema-catalog.mdjson{ "schemas": [ { "name": "{schema-name}", "id": "{schema-name}", "$id": "https://claude.ai/schemas/{schema-name}", "type": "{input|output|definition|global|component}", "description": "{此Schema验证的内容}", "version": "1.0.0", "filePath": ".claude/schemas/{schema-name}.schema.json", "validatesFor": ["{artifact-type-1}", "{artifact-type-2}"], "relatedSchemas": [], "usedBy": ["{validator-hook}", "{creator-skill}"] } ] } -
向验证器注册:更新任何应使用此Schema的验证Hook:
- 检查中的相关验证器
.claude/hooks/validation/ - 将Schema添加到需要它的验证器的schemaMap中
示例:javascriptconst schemaMap = { '.claude/agents/': '.claude/schemas/agent-definition.schema.json', '.claude/schemas/{schema-name}.schema.json': require('./.claude/schemas/{schema-name}.schema.json'), }; - 检查
-
在中记录:
.claude/context/artifacts/catalogs/schema-catalog.md向Schema目录添加条目:markdown### {Schema标题} (`{schema-name}.schema.json`) **$id:** `https://claude.ai/schemas/{schema-name}` **用途:** {此Schema验证的详细描述} **使用者:** - {验证Hook 1} - {创建器Skill 1} **根属性:** - {property-1}: {描述} - {property-2}: {描述} **有效数据示例:** ```json { "example": "value" } ```必填字段: {必填字段列表}验证规则: 当数据匹配此Schema时,{描述验证内容} -
如果Schema支持新功能,请更新:
.claude/CLAUDE.md如果此Schema支持新的工件类型或验证功能:- 添加到相关章节(创建器Schema见第4.1节,Schemas目录见第9.7节)
- 添加到本Skill步骤7中的现有Schema参考表格
示例条目:markdown| `{schema-name}` | `.claude/schemas/` | {用途} | -
更新记忆:追加到:
.claude/context/memory/learnings.mdmarkdown## Schema: {schema-name} - **类型:** {input|output|definition|global|component} - **验证对象:** {工件/数据类型} - **用途:** {详细用途} - **$id:** https://claude.ai/schemas/{schema-name} - **验证器:** {使用此Schema的Hook/验证器} - **相关Schema:** {任何$ref引用}
为什么这很重要:没有Schema注册:
- 验证器无法发现和使用Schema
- 系统范围内不会进行数据验证
- 会创建无效工件而未被检测到
- 出现“不可见工件”模式
第一阶段集成:Schema注册表是第一阶段的发现机制,使验证器能够在整个系统中一致地查找和应用Schema。
Step 9: System Impact Analysis (MANDATORY)
步骤9:系统影响分析(强制要求)
Before marking schema creation complete, verify ALL items:
[ ] Schema file created in correct location
[ ] Schema is valid JSON (parseable)
[ ] Schema has $schema, $id, title, description
[ ] All required fields defined in "required" array
[ ] All properties have descriptions
[ ] Examples included for complex schemas
[ ] Schema registry entry created (Step 7)
[ ] Validators registered with schema (if applicable)
[ ] SCHEMA_CATALOG.md updated (Step 7)
[ ] Related documentation updatedVerification Commands:
bash
undefined在标记Schema创建完成之前,请验证所有项:
[ ] Schema文件已创建在正确位置
[ ] Schema是有效的JSON(可解析)
[ ] Schema包含$schema、$id、title、description
[ ] 所有必填字段已在"required"数组中定义
[ ] 所有属性都有描述
[ ] 复杂Schema已包含示例
[ ] 已创建Schema注册表条目(步骤7)
[ ] 验证器已注册Schema(如适用)
[ ] SCHEMA_CATALOG.md已更新(步骤7)
[ ] 相关文档已更新验证命令:
bash
undefinedValidate JSON syntax
验证JSON语法
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/{name}.schema.json'))"
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/{name}.schema.json'))"
Check required fields
检查必填字段
node -e "const s = require('.claude/schemas/{name}.schema.json'); console.log('title:', s.title); console.log('description:', s.description);"
node -e "const s = require('.claude/schemas/{name}.schema.json'); console.log('title:', s.title); console.log('description:', s.description);"
Check schema registry
检查Schema注册表
grep "{schema-name}" .claude/context/artifacts/schema-catalog.md
grep "{schema-name}" .claude/context/artifacts/schema-catalog.md
List all schemas
列出所有Schema
ls -la .claude/schemas/*.schema.json
**BLOCKING**: If any item fails, schema creation is INCOMPLETE. All items must pass.ls -la .claude/schemas/*.schema.json
**阻塞项**:如果任何项失败,Schema创建即为未完成。所有项必须通过。System Impact Analysis (MANDATORY)
系统影响分析(强制要求)
After creating a schema, complete ALL of the following:
创建Schema后,请完成以下所有操作:
1. CLAUDE.md Update
1. 更新CLAUDE.md
- Add to appropriate section if schema enables new capability
- Section 3 for agent-related schemas
- Section 4.1 for creator ecosystem schemas
- Section 8.5 for skill-related schemas
- 如果Schema支持新功能,请添加到相应章节
- Agent相关Schema见第3节
- 创建器生态系统Schema见第4.1节
- Skill相关Schema见第8.5节
2. Validator Integration
2. 验证器集成
- Check if hooks should validate against new schema
- Update if schema affects validation
.claude/hooks/ - Add to in relevant validators
schemaMap
- 检查Hook是否应根据新Schema进行验证
- 如果Schema影响验证,请更新
.claude/hooks/ - 将Schema添加到相关验证器的中
schemaMap
3. Related Schemas
3. 相关Schema
- Update related schemas if needed ($ref links)
- Check for circular dependencies
- Ensure $id values are unique
- 如果需要,请更新相关Schema($ref链接)
- 检查循环依赖
- 确保$id值唯一
4. Documentation
4. 文档更新
- Update if schema documents new pattern
.claude/docs/ - Add schema to Existing Schemas Reference table
- Update skill-catalog.md if schema is for a new skill
Verification Checklist:
bash
undefined- 如果Schema记录了新模式,请更新
.claude/docs/ - 将Schema添加到现有Schema参考表格
- 如果Schema是为新Skill创建的,请更新skill-catalog.md
验证清单:
bash
undefinedCheck CLAUDE.md registration
检查CLAUDE.md注册情况
grep "{schema-name}" .claude/CLAUDE.md
grep "{schema-name}" .claude/CLAUDE.md
Check for $ref usage in other schemas
检查其他Schema中是否使用了$ref
grep -r "{schema-name}" .claude/schemas/
grep -r "{schema-name}" .claude/schemas/
Verify no duplicate $id
验证无重复$id
grep -h "$id" .claude/schemas/*.json | sort | uniq -d
**BLOCKING**: Schema creation is NOT complete until all impact analysis items are verified.grep -h "$id" .claude/schemas/*.json | sort | uniq -d
**阻塞项**:直到所有影响分析项都验证通过,Schema创建才视为完成。Schema Templates
Schema模板
Basic Input Schema
基础输入Schema
json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/skill-name-input",
"title": "Skill Name Input Schema",
"description": "Input validation schema for skill-name skill",
"type": "object",
"required": [],
"properties": {
"target": {
"type": "string",
"description": "Target file or directory path"
},
"options": {
"type": "object",
"description": "Optional configuration",
"properties": {
"verbose": {
"type": "boolean",
"default": false
}
}
}
},
"additionalProperties": false
}json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/skill-name-input",
"title": "Skill名称输入Schema",
"description": "skill-name Skill的输入验证Schema",
"type": "object",
"required": [],
"properties": {
"target": {
"type": "string",
"description": "目标文件或目录路径"
},
"options": {
"type": "object",
"description": "可选配置",
"properties": {
"verbose": {
"type": "boolean",
"default": false
}
}
}
},
"additionalProperties": false
}Basic Output Schema
基础输出Schema
json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/skill-name-output",
"title": "Skill Name Output Schema",
"description": "Output validation schema for skill-name skill",
"type": "object",
"required": ["success"],
"properties": {
"success": {
"type": "boolean",
"description": "Whether the skill executed successfully"
},
"result": {
"type": "object",
"description": "The skill execution result",
"additionalProperties": true
},
"error": {
"type": "string",
"description": "Error message if execution failed"
}
},
"additionalProperties": false
}json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/skill-name-output",
"title": "Skill名称输出Schema",
"description": "skill-name Skill的输出验证Schema",
"type": "object",
"required": ["success"],
"properties": {
"success": {
"type": "boolean",
"description": "Skill是否执行成功"
},
"result": {
"type": "object",
"description": "Skill执行结果",
"additionalProperties": true
},
"error": {
"type": "string",
"description": "执行失败时的错误消息"
}
},
"additionalProperties": false
}Definition Schema (for agents, skills, hooks)
定义Schema(适用于Agent、Skill、Hook)
json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/entity-definition",
"title": "Entity Definition Schema",
"description": "Schema for validating entity definition files",
"type": "object",
"required": ["name", "description"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "Entity name in lowercase-with-hyphens format"
},
"description": {
"type": "string",
"minLength": 20,
"maxLength": 500,
"description": "Clear description of the entity purpose"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+(\\.\\d+)?$",
"default": "1.0.0",
"description": "Semantic version number"
}
},
"additionalProperties": true,
"examples": [
{
"name": "my-entity",
"description": "A sample entity for demonstration purposes",
"version": "1.0.0"
}
]
}json
{
"$schema": "https://json-schema.org/draft-07/schema#",
"$id": "https://claude.ai/schemas/entity-definition",
"title": "实体定义Schema",
"description": "用于验证实体定义文件的Schema",
"type": "object",
"required": ["name", "description"],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "实体名称,采用小写短横线格式"
},
"description": {
"type": "string",
"minLength": 20,
"maxLength": 500,
"description": "实体用途的清晰描述"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+(\\.\\d+)?$",
"default": "1.0.0",
"description": "语义化版本号"
}
},
"additionalProperties": true,
"examples": [
{
"name": "my-entity",
"description": "用于演示的示例实体",
"version": "1.0.0"
}
]
}Common JSON Schema Patterns
常见JSON Schema模式
String Patterns
字符串模式
json
{
"kebab-case": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$"
},
"semver": {
"type": "string",
"pattern": "^\\d+\\.\\d+(\\.\\d+)?$"
},
"file-path": {
"type": "string",
"pattern": "^[\\w./-]+$"
},
"email": {
"type": "string",
"format": "email"
},
"url": {
"type": "string",
"format": "uri"
}
}json
{
"kebab-case": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$"
},
"semver": {
"type": "string",
"pattern": "^\\d+\\.\\d+(\\.\\d+)?$"
},
"file-path": {
"type": "string",
"pattern": "^[\\w./-]+$"
},
"email": {
"type": "string",
"format": "email"
},
"url": {
"type": "string",
"format": "uri"
}
}Enum Patterns
枚举模式
json
{
"model": {
"type": "string",
"enum": ["sonnet", "opus", "haiku", "inherit"]
},
"priority": {
"type": "string",
"enum": ["lowest", "low", "medium", "high", "highest"]
},
"status": {
"type": "string",
"enum": ["pending", "in_progress", "completed", "failed", "blocked"]
}
}json
{
"model": {
"type": "string",
"enum": ["sonnet", "opus", "haiku", "inherit"]
},
"priority": {
"type": "string",
"enum": ["lowest", "low", "medium", "high", "highest"]
},
"status": {
"type": "string",
"enum": ["pending", "in_progress", "completed", "failed", "blocked"]
}
}Array Patterns
数组模式
json
{
"tools": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true,
"description": "List of available tools"
},
"skills": {
"type": "array",
"items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
"description": "List of skill names"
}
}json
{
"tools": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true,
"description": "可用工具列表"
},
"skills": {
"type": "array",
"items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
"description": "Skill名称列表"
}
}Object Patterns
对象模式
json
{
"config": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": { "type": "boolean", "default": true },
"timeout": { "type": "integer", "minimum": 0 }
}
},
"metadata": {
"type": "object",
"additionalProperties": true,
"description": "Arbitrary metadata"
}
}json
{
"config": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": { "type": "boolean", "default": true },
"timeout": { "type": "integer", "minimum": 0 }
}
},
"metadata": {
"type": "object",
"additionalProperties": true,
"description": "任意元数据"
}
}Conditional Patterns
条件模式
json
{
"if": {
"properties": {
"type": { "const": "mcp" }
}
},
"then": {
"required": ["server", "command"]
},
"else": {
"required": ["handler"]
}
}json
{
"if": {
"properties": {
"type": { "const": "mcp" }
}
},
"then": {
"required": ["server", "command"]
},
"else": {
"required": ["handler"]
}
}Using $ref for Reusability
使用$ref实现复用
json
{
"$defs": {
"namePattern": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "Lowercase with hyphens"
},
"toolsList": {
"type": "array",
"items": { "type": "string" },
"minItems": 1
}
},
"properties": {
"name": { "$ref": "#/$defs/namePattern" },
"tools": { "$ref": "#/$defs/toolsList" }
}
}json
{
"$defs": {
"namePattern": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$",
"description": "小写短横线格式"
},
"toolsList": {
"type": "array",
"items": { "type": "string" },
"minItems": 1
}
},
"properties": {
"name": { "$ref": "#/$defs/namePattern" },
"tools": { "$ref": "#/$defs/toolsList" }
}
}CLI Usage
CLI使用方法
Create Schema from Template
从模板创建Schema
bash
undefinedbash
undefinedCreate skill input schema
创建Skill输入Schema
node .claude/skills/schema-creator/scripts/main.cjs
--type input
--skill my-skill
--type input
--skill my-skill
node .claude/skills/schema-creator/scripts/main.cjs
--type input
--skill my-skill
--type input
--skill my-skill
Create skill output schema
创建Skill输出Schema
node .claude/skills/schema-creator/scripts/main.cjs
--type output
--skill my-skill
--type output
--skill my-skill
node .claude/skills/schema-creator/scripts/main.cjs
--type output
--skill my-skill
--type output
--skill my-skill
Create global schema
创建全局Schema
node .claude/skills/schema-creator/scripts/main.cjs
--type global
--name my-data-format
--type global
--name my-data-format
node .claude/skills/schema-creator/scripts/main.cjs
--type global
--name my-data-format
--type global
--name my-data-format
Create definition schema
创建定义Schema
node .claude/skills/schema-creator/scripts/main.cjs
--type definition
--entity workflow
--type definition
--entity workflow
undefinednode .claude/skills/schema-creator/scripts/main.cjs
--type definition
--entity workflow
--type definition
--entity workflow
undefinedValidate Schema
验证Schema
bash
undefinedbash
undefinedValidate a schema file
验证Schema文件
node .claude/skills/schema-creator/scripts/main.cjs
--validate .claude/schemas/my-schema.schema.json
--validate .claude/schemas/my-schema.schema.json
node .claude/skills/schema-creator/scripts/main.cjs
--validate .claude/schemas/my-schema.schema.json
--validate .claude/schemas/my-schema.schema.json
Validate data against schema
验证数据是否符合Schema
node .claude/skills/schema-creator/scripts/main.cjs
--validate-data data.json
--schema .claude/schemas/my-schema.schema.json
--validate-data data.json
--schema .claude/schemas/my-schema.schema.json
undefinednode .claude/skills/schema-creator/scripts/main.cjs
--validate-data data.json
--schema .claude/schemas/my-schema.schema.json
--validate-data data.json
--schema .claude/schemas/my-schema.schema.json
undefinedGenerate Schema from Example
从示例生成Schema
bash
undefinedbash
undefinedGenerate schema from JSON example
从JSON示例生成Schema
node .claude/skills/schema-creator/scripts/main.cjs
--from-example example.json
--output .claude/schemas/generated.schema.json
--from-example example.json
--output .claude/schemas/generated.schema.json
undefinednode .claude/skills/schema-creator/scripts/main.cjs
--from-example example.json
--output .claude/schemas/generated.schema.json
--from-example example.json
--output .claude/schemas/generated.schema.json
undefinedIntegration with Validators
与验证器集成
Using Ajv for Runtime Validation
使用Ajv进行运行时验证
javascript
const Ajv = require('ajv');
const addFormats = require('ajv-formats');
const ajv = new Ajv({ allErrors: true });
addFormats(ajv);
// Load and compile schema
const schema = require('./.claude/schemas/skill-definition.schema.json');
const validate = ajv.compile(schema);
// Validate data
function validateSkillDefinition(data) {
const valid = validate(data);
if (!valid) {
return {
valid: false,
errors: validate.errors.map(e => `${e.instancePath} ${e.message}`),
};
}
return { valid: true };
}javascript
const Ajv = require('ajv');
const addFormats = require('ajv-formats');
const ajv = new Ajv({ allErrors: true });
addFormats(ajv);
// 加载并编译Schema
const schema = require('./.claude/schemas/skill-definition.schema.json');
const validate = ajv.compile(schema);
// 验证数据
function validateSkillDefinition(data) {
const valid = validate(data);
if (!valid) {
return {
valid: false,
errors: validate.errors.map(e => `${e.instancePath} ${e.message}`),
};
}
return { valid: true };
}Pre-commit Validation Hook
提交前验证Hook
javascript
// .claude/hooks/schema-validator.js
const fs = require('fs');
const path = require('path');
const Ajv = require('ajv');
const schemaMap = {
'.claude/agents/': '.claude/schemas/agent-definition.schema.json',
'.claude/skills/': '.claude/schemas/skill-definition.schema.json',
'.claude/hooks/': '.claude/schemas/hook-definition.schema.json',
};
function validateFile(filePath) {
// Find matching schema
for (const [pattern, schemaPath] of Object.entries(schemaMap)) {
if (filePath.includes(pattern)) {
const schema = JSON.parse(fs.readFileSync(schemaPath));
const ajv = new Ajv();
const validate = ajv.compile(schema);
// Parse and validate file
// ...
}
}
}javascript
// .claude/hooks/schema-validator.js
const fs = require('fs');
const path = require('path');
const Ajv = require('ajv');
const schemaMap = {
'.claude/agents/': '.claude/schemas/agent-definition.schema.json',
'.claude/skills/': '.claude/schemas/skill-definition.schema.json',
'.claude/hooks/': '.claude/schemas/hook-definition.schema.json',
};
function validateFile(filePath) {
// 查找匹配的Schema
for (const [pattern, schemaPath] of Object.entries(schemaMap)) {
if (filePath.includes(pattern)) {
const schema = JSON.parse(fs.readFileSync(schemaPath));
const ajv = new Ajv();
const validate = ajv.compile(schema);
// 解析并验证文件
// ...
}
}
}Workflow Integration
工作流集成
This skill is part of the unified artifact lifecycle. For complete multi-agent orchestration:
Router Decision:
.claude/workflows/core/router-decision.md- How the Router discovers and invokes this skill's artifacts
Artifact Lifecycle:
.claude/workflows/core/skill-lifecycle.md- Discovery, creation, update, deprecation phases
- Version management and registry updates
- CLAUDE.md integration requirements
External Integration:
.claude/workflows/core/external-integration.md- Safe integration of external artifacts
- Security review and validation phases
此Skill是统一工件生命周期的一部分。如需完整的多Agent编排:
路由器决策:
.claude/workflows/core/router-decision.md- 路由器如何发现并调用此Skill的工件
工件生命周期:
.claude/workflows/core/skill-lifecycle.md- 发现、创建、更新、弃用阶段
- 版本管理和注册表更新
- CLAUDE.md集成要求
外部集成:
.claude/workflows/core/external-integration.md- 外部工件的安全集成
- 安全审查和验证阶段
Cross-Reference: Creator Ecosystem
交叉参考:创建器生态系统
This skill is part of the Creator Ecosystem. Use companion creators for related artifacts:
| Creator | When to Use | Invocation |
|---|---|---|
| agent-creator | Creating agents that use schemas | |
| skill-creator | Creating skills with input/output schemas | |
| hook-creator | Creating hooks with validation | |
| workflow-creator | Creating workflows with step schemas | |
| template-creator | Creating templates with data schemas | |
此Skill是创建器生态系统的一部分。请使用配套创建器处理相关工件:
| 创建器 | 使用场景 | 调用方式 |
|---|---|---|
| agent-creator | 创建使用Schema的Agent | |
| skill-creator | 创建带输入/输出Schema的Skill | |
| hook-creator | 创建带验证功能的Hook | |
| workflow-creator | 创建带步骤Schema的工作流 | |
| template-creator | 创建带数据Schema的模板 | |
Integration Chain
集成链
text
[SKILL-CREATOR] Creating new skill with validation...
-> Calls schema-creator for input/output schemas
-> Schemas created in .claude/skills/{skill}/schemas/
[AGENT-CREATOR] Creating agent with strict validation...
-> Agent uses agent-definition.schema.json for self-validation
-> Agent validates inputs using custom schemas
[WORKFLOW-CREATOR] Creating workflow with typed steps...
-> Each step output validates against schema
-> Workflow uses workflow-definition.schema.jsontext
[SKILL-CREATOR] 创建带验证功能的新Skill...
-> 调用schema-creator创建输入/输出Schema
-> Schema创建于.claude/skills/{skill}/schemas/
[AGENT-CREATOR] 创建带严格验证的Agent...
-> Agent使用agent-definition.schema.json进行自我验证
-> Agent使用自定义Schema验证输入
[WORKFLOW-CREATOR] 创建带类型化步骤的工作流...
-> 每个步骤输出都经过Schema验证
-> 工作流使用workflow-definition.schema.jsonExisting Schemas Reference
现有Schema参考
Total Active Schemas: 27 (25 archived - see )
Actively Validated (Ajv): 8 schemas with runtime validation
Documentation Reference: 16 schemas as structural templates
Optional Validation: 3 schemas with paths defined but validation skipped
.claude/schemas/_archive/Complete catalog:
.claude/context/artifacts/catalogs/schema-catalog.md活跃Schema总数: 27个(25个已归档 - 详见)
已启用运行时验证(Ajv): 8个Schema
文档参考: 16个Schema作为结构模板
可选验证: 3个Schema已定义路径但跳过验证
.claude/schemas/_archive/完整目录:
.claude/context/artifacts/catalogs/schema-catalog.mdActive Schemas by Category
按类别划分的活跃Schema
Agent Schemas (5)
Agent Schema(5个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| WIRED | generate-agent-registry |
| WIRED | agent-config.cjs |
| WIRED | agent-parser.cjs |
| WIRED | agent-parser.cjs |
| DOCS ONLY | Spawn prompt reference |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 已连接 | generate-agent-registry |
| 已连接 | agent-config.cjs |
| 已连接 | agent-parser.cjs |
| 已连接 | agent-parser.cjs |
| 仅文档 | 生成提示参考 |
Skill Schemas (4)
Skill Schema(4个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| WIRED | skill-creator/create.cjs |
| SOFT-WIRED | diagram-generator skill |
| SOFT-WIRED | repo-rag skill |
| SOFT-WIRED | test-generator skill |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 已连接 | skill-creator/create.cjs |
| 软连接 | diagram-generator skill |
| 软连接 | repo-rag skill |
| 软连接 | test-generator skill |
Workflow & Hook Schemas (2)
工作流与Hook Schema(2个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| DOCS ONLY | No workflow-creator scripts |
| DOCS ONLY | No hook-creator scripts |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 仅文档 | 无workflow-creator脚本 |
| 仅文档 | 无hook-creator脚本 |
Evolution & Project Schemas (2)
演进与项目Schema(2个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| WIRED | self-healing/validator.cjs |
| DOCS ONLY | TaskCreate metadata field |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 已连接 | self-healing/validator.cjs |
| 仅文档 | TaskCreate元数据字段 |
Tool & Template Schemas (3)
工具与模板Schema(3个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| WIRED | generate-tool-manifest.cjs |
| WIRED | spawn/prompt-assembler.cjs |
| DOCS ONLY | ADR documentation structure |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 已连接 | generate-tool-manifest.cjs |
| 已连接 | spawn/prompt-assembler.cjs |
| 仅文档 | ADR文档结构 |
Planning Schemas (5)
规划Schema(5个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| DOCS ONLY | Planning phase reference |
| DOCS ONLY | Implementation planning |
| DOCS ONLY | Phase planning reference |
| DOCS ONLY | Requirements gathering |
| DOCS ONLY | Project initialization |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 仅文档 | 规划阶段参考 |
| 仅文档 | 实施规划 |
| 仅文档 | 阶段规划参考 |
| 仅文档 | 需求收集 |
| 仅文档 | 项目初始化 |
Testing Schemas (2)
测试Schema(2个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| DOCS ONLY | Test planning reference |
| DOCS ONLY | Test execution output |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 仅文档 | 测试规划参考 |
| 仅文档 | 测试执行输出 |
Architecture Schemas (3)
架构Schema(3个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| DOCS ONLY | Specification documents |
| DOCS ONLY | Architecture documentation |
| DOCS ONLY | UX specification documents |
| Schema | 连接状态 | 消费者 |
|---|---|---|
| 仅文档 | 规范文档 |
| 仅文档 | 架构文档 |
| 仅文档 | UX规范文档 |
Project Schemas (1)
项目Schema(1个)
| Schema | Wiring Status | Consumer |
|---|---|---|
| DOCS ONLY | Project analyzer output |
Note: All schemas located at unless otherwise specified. See schema catalog for full details on consumers, validation methods, and integration status.
.claude/schemas/| Schema | 连接状态 | 消费者 |
|---|---|---|
| 仅文档 | 项目分析器输出 |
注意: 所有Schema默认位于,除非另有说明。有关消费者、验证方法和集成状态的完整详情,请参阅Schema目录。
.claude/schemas/File Placement & Standards
文件放置与标准
Output Location Rules
输出位置规则
This skill outputs to:
.claude/schemas/For skill-specific schemas:
.claude/skills/<skill-name>/schemas/Schema naming convention:
- Global schemas:
<name>.schema.json - Skill input:
input.schema.json - Skill output:
output.schema.json - Components:
components/<name>.schema.json
此Skill输出至:
.claude/schemas/Skill特定Schema输出至:
.claude/skills/<skill-name>/schemas/Schema命名规范:
- 全局Schema:
<name>.schema.json - Skill输入Schema:
input.schema.json - Skill输出Schema:
output.schema.json - 组件Schema:
components/<name>.schema.json
Mandatory References
强制参考
- File Placement: See
.claude/docs/FILE_PLACEMENT_RULES.md - Developer Workflow: See
.claude/docs/DEVELOPER_WORKFLOW.md - Artifact Naming: See
.claude/docs/ARTIFACT_NAMING.md - Workspace Conventions: See (output placement, naming, provenance)
.claude/rules/workspace-conventions.md
- 文件放置: 详见
.claude/docs/FILE_PLACEMENT_RULES.md - 开发者工作流: 详见
.claude/docs/DEVELOPER_WORKFLOW.md - 工件命名: 详见
.claude/docs/ARTIFACT_NAMING.md - 工作区规范: 详见(输出放置、命名、来源)
.claude/rules/workspace-conventions.md
Enforcement
强制执行
File placement is enforced by hook.
Invalid placements will be blocked in production mode.
file-placement-guard.cjs文件放置规则由 Hook强制执行。
生产模式下会阻止无效放置。
file-placement-guard.cjsMemory Protocol (MANDATORY)
记忆协议(强制要求)
Before starting:
bash
cat .claude/context/memory/learnings.mdCheck for:
- Previously created schemas
- Known validation issues
- Schema naming conventions
After completing:
- New schema created -> Append to
.claude/context/memory/learnings.md - Validation issue found -> Append to
.claude/context/memory/issues.md - Architecture decision -> Append to
.claude/context/memory/decisions.md
ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
开始前:
bash
cat .claude/context/memory/learnings.md检查以下内容:
- 之前创建的Schema
- 已知验证问题
- Schema命名规范
完成后:
- 新Schema已创建 → 追加到
.claude/context/memory/learnings.md - 发现验证问题 → 追加到
.claude/context/memory/issues.md - 架构决策 → 追加到
.claude/context/memory/decisions.md
假设会被中断:您的上下文可能会重置。如果未记录在记忆中,就相当于从未发生过。
Iron Laws of Schema Creation
Schema创建的铁律
These rules are INVIOLABLE. Breaking them causes validation failures.
1. NO SCHEMA WITHOUT $schema FIELD
- Every schema MUST declare its JSON Schema version
- Use draft-07 or later: "$schema": "https://json-schema.org/draft-07/schema#"
2. NO SCHEMA WITHOUT title AND description
- Every schema MUST be self-documenting
- title: Short name of what it validates
- description: Detailed explanation of purpose
3. NO PROPERTY WITHOUT description
- Every property MUST have a description
- Readers should understand field purpose without external docs
4. NO REQUIRED FIELD WITHOUT DEFINITION
- If field is in "required" array, it MUST be in "properties"
- Undefined required fields cause silent validation failures
5. NO ADDITIONALPROPERTIES: true WITHOUT REASON
- Default to additionalProperties: false for strict validation
- Only allow additional properties when explicitly needed
6. NO SCHEMA WITHOUT VALIDATION TEST
- Test schema with valid AND invalid examples
- Schema that passes everything validates nothing
7. NO CREATION WITHOUT SYSTEM IMPACT ANALYSIS
- Check if related validators need updating
- Check if documentation needs updating
- Check if related schemas need cross-references
8. NO SCHEMA WITHOUT CLAUDE.MD REGISTRATION
- If schema enables new capabilities, update CLAUDE.md
- Section 4 (Self-Evolution) for agent/skill/workflow schemas
- Verify with: grep "schema-name" .claude/CLAUDE.md这些规则不可违反。违反会导致验证失败。
1. 任何Schema必须包含$schema字段
- 每个Schema必须声明其JSON Schema版本
- 使用draft-07或更高版本:"$schema": "https://json-schema.org/draft-07/schema#"
2. 任何Schema必须包含title和description
- 每个Schema必须具备自文档性
- title:验证对象的简短名称
- description:用途的详细说明
3. 任何属性必须包含description
- 每个属性必须有描述
- 读者无需外部文档即可理解字段用途
4. 任何必填字段必须已定义
- 如果字段在"required"数组中,必须在"properties"中定义
- 未定义的必填字段会导致静默验证失败
5. 除非有合理理由,否则不允许additionalProperties: true
- 默认使用additionalProperties: false进行严格验证
- 仅在明确需要时才允许额外属性
6. 任何Schema必须包含验证测试
- 使用有效和无效示例测试Schema
- 能通过所有测试的Schema相当于没有验证功能
7. 任何创建必须完成系统影响分析
- 检查相关验证器是否需要更新
- 检查文档是否需要更新
- 检查相关Schema是否需要交叉引用
8. 任何Schema必须在CLAUDE.md中注册
- 如果Schema支持新功能,请更新CLAUDE.md
- Agent/Skill/工作流Schema见第4节(自我演进)
- 验证方式:grep "schema-name" .claude/CLAUDE.mdValidation Checklist (Run After Every Creation)
验证清单(每次创建后运行)
bash
undefinedbash
undefinedVerify schema is valid JSON
验证Schema是否为合法JSON
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/{name}.schema.json'))"
node -e "JSON.parse(require('fs').readFileSync('.claude/schemas/{name}.schema.json'))"
Check required fields exist
检查必填字段是否存在
node -e "const s = require('.claude/schemas/{name}.schema.json'); console.log('Has $schema:', !!s.$schema); console.log('Has title:', !!s.title); console.log('Has description:', !!s.description);"
node -e "const s = require('.claude/schemas/{name}.schema.json'); console.log('包含$schema:', !!s.$schema); console.log('包含title:', !!s.title); console.log('包含description:', !!s.description);"
Check all required properties are defined
检查所有必填属性是否已定义
node -e "const s = require('.claude/schemas/{name}.schema.json'); const r = s.required || []; const p = Object.keys(s.properties || {}); console.log('Missing:', r.filter(x => !p.includes(x)));"
node -e "const s = require('.claude/schemas/{name}.schema.json'); const r = s.required || []; const p = Object.keys(s.properties || {}); console.log('缺失:', r.filter(x => !p.includes(x)));"
List all schemas
列出所有Schema
ls -la .claude/schemas/*.schema.json
**Completion Checklist** (all must be checked):
[ ] Schema file created with .schema.json extension
[ ] $schema field present (draft-07 or later)
[ ] title and description present
[ ] All properties have descriptions
[ ] required array matches defined properties
[ ] examples included for complex schemas
[ ] Schema validated with test data
[ ] System impact analysis completed
[ ] CLAUDE.md updated if schema enables new capabilities
[ ] Related schemas updated if needed ($ref links)
**BLOCKING**: If ANY item fails, schema creation is INCOMPLETE. All items must pass before proceeding.
---ls -la .claude/schemas/*.schema.json
**完成清单**(所有项必须已勾选):
[ ] Schema文件已以.schema.json扩展名创建
[ ] 已包含$schema字段(draft-07或更高版本)
[ ] 已包含title和description
[ ] 所有属性都有描述
[ ] required数组与已定义属性匹配
[ ] 复杂Schema已包含示例
[ ] 已使用测试数据验证Schema
[ ] 已完成系统影响分析
[ ] 如果Schema支持新功能,已更新CLAUDE.md
[ ] 如需要,已更新相关Schema($ref链接)
**阻塞项**:如果任何项失败,Schema创建即为未完成。在继续之前,所有项必须通过。
---Post-Creation Integration
创建后集成
After creation completes, run the ecosystem integration checklist:
- Call from
runIntegrationChecklist(artifactType, artifactPath).claude/lib/creators/creator-commons.cjs - Call from
queueCrossCreatorReview(artifactType, artifactPath).claude/lib/creators/creator-commons.cjs - Review the impact report — address all items before marking task complete
mustHave - Log any items as follow-up tasks
shouldHave
Integration verification:
- Schema added to schema-catalog.md
- Schema validator wired (if applicable)
- Schema referenced by consuming artifacts
- Schema has test data examples
创建完成后,请运行生态系统集成清单:
- 调用中的
.claude/lib/creators/creator-commons.cjsrunIntegrationChecklist(artifactType, artifactPath) - 调用中的
.claude/lib/creators/creator-commons.cjsqueueCrossCreatorReview(artifactType, artifactPath) - 查看影响报告 - 在标记任务完成前解决所有项
mustHave - 将任何项记录为后续任务
shouldHave
集成验证:
- Schema已添加到schema-catalog.md
- Schema验证器已连接(如适用)
- 消费工件已引用Schema
- Schema包含测试数据示例