schema-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Schema Creator Skill

Schema Creator Skill

WARNING: DO NOT WRITE DIRECTLY TO .claude/schemas/
Schema files are protected by
unified-creator-guard.cjs
(Gate 4 in CLAUDE.md). Direct writes bypass post-creation steps (catalog updates, consumer assignment, integration verification). Always use the
schema-creator
skill workflow for creating schemas. Direct writes create "invisible artifacts" that no validator or agent can discover.
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文件受
unified-creator-guard.cjs
保护(详见CLAUDE.md中的第4关)。 直接写入会跳过创建后的步骤(目录更新、消费者分配、集成验证)。 创建Schema时请始终使用
schema-creator
Skill工作流。 直接写入会创建“不可见工件”,导致验证器或Agent无法发现它们。
为Claude Code Enterprise Framework创建JSON Schema验证文件。Schema可在Skill、Agent、Hook、工作流和自定义数据结构中强制执行类型安全、输入验证和结构一致性。

SYSTEM IMPACT ANALYSIS (CRITICAL - DO NOT SKIP)

系统影响分析(关键步骤 - 请勿跳过)

After creating ANY schema, you MUST:
  1. Register in appropriate location (global vs skill-local)
  2. Update related validators to use the new schema
  3. Add schema reference to CLAUDE.md if globally significant
Verification:
bash
undefined
创建任何Schema后,您必须执行以下操作:
  1. 在适当位置注册(全局或Skill本地)
  2. 更新相关验证器以使用新Schema
  3. 如果具有全局重要性,将Schema引用添加到CLAUDE.md中
验证操作:
bash
undefined

Verify 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:
  1. Skill Inputs/Outputs - Validate data passed to and from skills
  2. Agent Definitions - Validate agent YAML frontmatter and structure
  3. Hook Definitions - Validate hook configuration and registration
  4. Workflow Definitions - Validate workflow steps and configuration
  5. Custom Data Structures - Validate project-specific data formats
Schema为以下内容提供结构化验证:
  1. Skill输入/输出 - 验证传入和传出Skill的数据
  2. Agent定义 - 验证Agent的YAML前置内容和结构
  3. Hook定义 - 验证Hook的配置和注册信息
  4. 工作流定义 - 验证工作流步骤和配置
  5. 自定义数据结构 - 验证项目特定的数据格式

Schema Types

Schema类型

TypeLocationPurpose
Skill Input
.claude/skills/{name}/schemas/input.schema.json
Validate skill invocation inputs
Skill Output
.claude/skills/{name}/schemas/output.schema.json
Validate skill execution outputs
Agent Definition
.claude/schemas/agent-definition.schema.json
Validate agent YAML frontmatter
Skill Definition
.claude/schemas/skill-definition.schema.json
Validate skill YAML frontmatter
Hook Definition
.claude/schemas/hook-definition.schema.json
Validate hook configuration
Workflow Definition
.claude/schemas/workflow-definition.schema.json
Validate workflow structure
Custom
.claude/schemas/{name}.schema.json
Project-specific validation
类型位置用途
Skill输入
.claude/skills/{name}/schemas/input.schema.json
验证Skill调用输入
Skill输出
.claude/skills/{name}/schemas/output.schema.json
验证Skill执行输出
Agent定义
.claude/schemas/agent-definition.schema.json
验证Agent的YAML前置内容
Skill定义
.claude/schemas/skill-definition.schema.json
验证Skill的YAML前置内容
Hook定义
.claude/schemas/hook-definition.schema.json
验证Hook配置和注册信息
工作流定义
.claude/schemas/workflow-definition.schema.json
验证工作流结构
自定义Schema
.claude/schemas/{name}.schema.json
项目特定验证

Reference Schema

参考Schema

Use
.claude/schemas/agent-definition.schema.json
as the canonical reference schema.
Before 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)
请将
.claude/schemas/agent-definition.schema.json
作为标准参考Schema。
在最终确定任何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:
  1. New artifact type schema - Add to relevant section (Section 3 for agents, Section 8.5 for skills)
  2. Agent/skill/workflow validation schema - Document in Section 4 (Self-Evolution)
  3. 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:
  1. 新工件类型Schema - 添加到相关章节(Agent相关内容见第3节,Skill相关内容见第8.5节)
  2. Agent/Skill/工作流验证Schema - 在第4节(自我演进)中记录
  3. 框架级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
    .claude/schemas/
    for patterns
  • 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搜索
  • 查看
    .claude/schemas/
    中的现有Schema以了解格式模式
  • 检查
    .claude/context/artifacts/catalogs/schema-catalog.md
    中的Schema目录
  • 识别可作为参考的类似Schema
  • 在继续之前记录研究结果
原因:研究综合确保Schema遵循行业最佳实践,并与现有框架Schema保持一致性。

Step 1: Existence Check and Updater Delegation (MANDATORY - SECOND STEP)

步骤1:存在性检查与更新器委托(强制要求 - 第二步)

BEFORE creating any schema file, check if it already exists:
  1. Check if schema already exists:
    bash
    test -f .claude/schemas/<schema-name>.json && echo "EXISTS" || echo "NEW"
  2. 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
  3. If schema is NEW:
    • Continue with Step 1.5 below

在创建任何Schema文件之前,请检查它是否已存在:
  1. 检查Schema是否已存在:
    bash
    test -f .claude/schemas/<schema-name>.json && echo "已存在" || echo "新Schema"
  2. 如果Schema已存在:
    • 请勿继续创建
    • 请改为调用artifact-updater工作流:
      javascript
      Skill({
        skill: 'artifact-updater',
        args: {
          name: '<schema-name>',
          changes: '<所需更改的描述>',
          justification: '通过schema-creator请求更新',
        },
      });
    • 返回更新器结果并停止操作
  3. 如果Schema是新的:
    • 继续以下步骤1.5

Step 1.5: Companion Check

步骤1.5:配套检查

Before proceeding with creation, run the ecosystem companion check:
  1. Use
    companion-check.cjs
    from
    .claude/lib/creators/companion-check.cjs
  2. Call
    checkCompanions("schema", "{schema-name}")
    to identify companion artifacts
  3. Review the companion checklist — note which required/recommended companions are missing
  4. Plan to create or verify missing companions after this artifact is complete
  5. Include companion findings in post-creation integration notes
This step is informational (does not block creation) but ensures the full artifact ecosystem is considered.

在开始创建之前,请运行生态系统配套检查:
  1. 使用
    .claude/lib/creators/companion-check.cjs
    中的
    companion-check.cjs
  2. 调用
    checkCompanions("schema", "{schema-name}")
    以识别配套工件
  3. 查看配套清单 - 记录缺少的必填/推荐配套项
  4. 计划在完成此工件后创建或验证缺失的配套项
  5. 在创建后集成说明中包含配套检查结果
此步骤为信息性步骤(不会阻止创建),但确保考虑了完整的工件生态系统。

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 ForSchema LocationExample
New skill inputs
.claude/skills/{skill}/schemas/input.schema.json
tdd
skill parameters
New skill outputs
.claude/skills/{skill}/schemas/output.schema.json
tdd
skill results
Global definition
.claude/schemas/{name}.schema.json
test-results.schema.json
Reusable component
.claude/schemas/components/{name}.schema.json
task-status.schema.json
创建目标Schema位置示例
新Skill输入
.claude/skills/{skill}/schemas/input.schema.json
tdd
Skill参数
新Skill输出
.claude/skills/{skill}/schemas/output.schema.json
tdd
Skill结果
全局定义
.claude/schemas/{name}.schema.json
test-results.schema.json
可复用组件
.claude/schemas/components/{name}.schema.json
task-status.schema.json

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:
  1. Create/Update Schema Registry Entry in appropriate location:
    If registry doesn't exist, create
    .claude/context/artifacts/schema-catalog.md
    :
    json
    {
      "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}"]
        }
      ]
    }
  2. Register with Validators:
    Update any validation hooks that should use this schema:
    • Check
      .claude/hooks/validation/
      for relevant validators
    • Add schema to schemaMap in validators that need it
    Example:
    javascript
    const schemaMap = {
      '.claude/agents/': '.claude/schemas/agent-definition.schema.json',
      '.claude/schemas/{schema-name}.schema.json': require('./.claude/schemas/{schema-name}.schema.json'),
    };
  3. Document in
    .claude/context/artifacts/catalogs/schema-catalog.md
    :
    Add 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
  4. Update
    .claude/CLAUDE.md
    if Schema Enables New Capabilities:
    If 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} |
  5. Update Memory:
    Append to
    .claude/context/memory/learnings.md
    :
    markdown
    ## 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文件编写并验证完成后:
  1. 在适当位置创建/更新Schema注册表条目:
    如果注册表不存在,请创建
    .claude/context/artifacts/schema-catalog.md
    json
    {
      "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}"]
        }
      ]
    }
  2. 向验证器注册:
    更新任何应使用此Schema的验证Hook:
    • 检查
      .claude/hooks/validation/
      中的相关验证器
    • 将Schema添加到需要它的验证器的schemaMap中
    示例:
    javascript
    const schemaMap = {
      '.claude/agents/': '.claude/schemas/agent-definition.schema.json',
      '.claude/schemas/{schema-name}.schema.json': require('./.claude/schemas/{schema-name}.schema.json'),
    };
  3. .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时,{描述验证内容}
  4. 如果Schema支持新功能,请更新
    .claude/CLAUDE.md
    如果此Schema支持新的工件类型或验证功能:
    • 添加到相关章节(创建器Schema见第4.1节,Schemas目录见第9.7节)
    • 添加到本Skill步骤7中的现有Schema参考表格
    示例条目:
    markdown
    | `{schema-name}` | `.claude/schemas/` | {用途} |
  5. 更新记忆:
    追加到
    .claude/context/memory/learnings.md
    markdown
    ## 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 updated
Verification Commands:
bash
undefined
在标记Schema创建完成之前,请验证所有项:
[ ] Schema文件已创建在正确位置
[ ] Schema是有效的JSON(可解析)
[ ] Schema包含$schema、$id、title、description
[ ] 所有必填字段已在"required"数组中定义
[ ] 所有属性都有描述
[ ] 复杂Schema已包含示例
[ ] 已创建Schema注册表条目(步骤7)
[ ] 验证器已注册Schema(如适用)
[ ] SCHEMA_CATALOG.md已更新(步骤7)
[ ] 相关文档已更新
验证命令:
bash
undefined

Validate 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
    .claude/hooks/
    if schema affects validation
  • Add to
    schemaMap
    in relevant validators
  • 检查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
    .claude/docs/
    if schema documents new pattern
  • 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
undefined

Check 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
undefined
bash
undefined

Create skill input schema

创建Skill输入Schema

node .claude/skills/schema-creator/scripts/main.cjs
--type input
--skill my-skill
node .claude/skills/schema-creator/scripts/main.cjs
--type input
--skill my-skill

Create skill output schema

创建Skill输出Schema

node .claude/skills/schema-creator/scripts/main.cjs
--type output
--skill my-skill
node .claude/skills/schema-creator/scripts/main.cjs
--type output
--skill my-skill

Create global schema

创建全局Schema

node .claude/skills/schema-creator/scripts/main.cjs
--type global
--name my-data-format
node .claude/skills/schema-creator/scripts/main.cjs
--type global
--name my-data-format

Create definition schema

创建定义Schema

node .claude/skills/schema-creator/scripts/main.cjs
--type definition
--entity workflow
undefined
node .claude/skills/schema-creator/scripts/main.cjs
--type definition
--entity workflow
undefined

Validate Schema

验证Schema

bash
undefined
bash
undefined

Validate a schema file

验证Schema文件

node .claude/skills/schema-creator/scripts/main.cjs
--validate .claude/schemas/my-schema.schema.json
node .claude/skills/schema-creator/scripts/main.cjs
--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
undefined
node .claude/skills/schema-creator/scripts/main.cjs
--validate-data data.json
--schema .claude/schemas/my-schema.schema.json
undefined

Generate Schema from Example

从示例生成Schema

bash
undefined
bash
undefined

Generate schema from JSON example

从JSON示例生成Schema

node .claude/skills/schema-creator/scripts/main.cjs
--from-example example.json
--output .claude/schemas/generated.schema.json
undefined
node .claude/skills/schema-creator/scripts/main.cjs
--from-example example.json
--output .claude/schemas/generated.schema.json
undefined

Integration 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:
CreatorWhen to UseInvocation
agent-creatorCreating agents that use schemas
Skill({ skill: 'agent-creator' })
skill-creatorCreating skills with input/output schemas
Skill({ skill: 'skill-creator' })
hook-creatorCreating hooks with validation
Skill({ skill: 'hook-creator' })
workflow-creatorCreating workflows with step schemas
Skill({ skill: 'workflow-creator' })
template-creatorCreating templates with data schemas
Skill({ skill: 'template-creator' })
此Skill是创建器生态系统的一部分。请使用配套创建器处理相关工件:
创建器使用场景调用方式
agent-creator创建使用Schema的Agent
Skill({ skill: 'agent-creator' })
skill-creator创建带输入/输出Schema的Skill
Skill({ skill: 'skill-creator' })
hook-creator创建带验证功能的Hook
Skill({ skill: 'hook-creator' })
workflow-creator创建带步骤Schema的工作流
Skill({ skill: 'workflow-creator' })
template-creator创建带数据Schema的模板
Skill({ skill: 'template-creator' })

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.json
text
[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.json

Existing Schemas Reference

现有Schema参考

Total Active Schemas: 27 (25 archived - see
.claude/schemas/_archive/
) 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
Complete catalog:
.claude/context/artifacts/catalogs/schema-catalog.md
活跃Schema总数: 27个(25个已归档 - 详见
.claude/schemas/_archive/
已启用运行时验证(Ajv): 8个Schema 文档参考: 16个Schema作为结构模板 可选验证: 3个Schema已定义路径但跳过验证
完整目录:
.claude/context/artifacts/catalogs/schema-catalog.md

Active Schemas by Category

按类别划分的活跃Schema

Agent Schemas (5)

Agent Schema(5个)

SchemaWiring StatusConsumer
agent-capability-card
WIREDgenerate-agent-registry
agent-config
WIREDagent-config.cjs
agent-definition
WIREDagent-parser.cjs
agent-identity
WIREDagent-parser.cjs
agent-spawn-params
DOCS ONLYSpawn prompt reference
Schema连接状态消费者
agent-capability-card
已连接generate-agent-registry
agent-config
已连接agent-config.cjs
agent-definition
已连接agent-parser.cjs
agent-identity
已连接agent-parser.cjs
agent-spawn-params
仅文档生成提示参考

Skill Schemas (4)

Skill Schema(4个)

SchemaWiring StatusConsumer
skill-definition
WIREDskill-creator/create.cjs
skill-diagram-generator-output
SOFT-WIREDdiagram-generator skill
skill-repo-rag-output
SOFT-WIREDrepo-rag skill
skill-test-generator-output
SOFT-WIREDtest-generator skill
Schema连接状态消费者
skill-definition
已连接skill-creator/create.cjs
skill-diagram-generator-output
软连接diagram-generator skill
skill-repo-rag-output
软连接repo-rag skill
skill-test-generator-output
软连接test-generator skill

Workflow & Hook Schemas (2)

工作流与Hook Schema(2个)

SchemaWiring StatusConsumer
workflow-definition
DOCS ONLYNo workflow-creator scripts
hook-definition
DOCS ONLYNo hook-creator scripts
Schema连接状态消费者
workflow-definition
仅文档无workflow-creator脚本
hook-definition
仅文档无hook-creator脚本

Evolution & Project Schemas (2)

演进与项目Schema(2个)

SchemaWiring StatusConsumer
evolution-state
WIREDself-healing/validator.cjs
track-metadata
DOCS ONLYTaskCreate metadata field
Schema连接状态消费者
evolution-state
已连接self-healing/validator.cjs
track-metadata
仅文档TaskCreate元数据字段

Tool & Template Schemas (3)

工具与模板Schema(3个)

SchemaWiring StatusConsumer
tool-manifest
WIREDgenerate-tool-manifest.cjs
presets
WIREDspawn/prompt-assembler.cjs
adr-template
DOCS ONLYADR documentation structure
Schema连接状态消费者
tool-manifest
已连接generate-tool-manifest.cjs
presets
已连接spawn/prompt-assembler.cjs
adr-template
仅文档ADR文档结构

Planning Schemas (5)

规划Schema(5个)

SchemaWiring StatusConsumer
plan
DOCS ONLYPlanning phase reference
implementation-plan
DOCS ONLYImplementation planning
phase-models
DOCS ONLYPhase planning reference
product_requirements
DOCS ONLYRequirements gathering
project_brief
DOCS ONLYProject initialization
Schema连接状态消费者
plan
仅文档规划阶段参考
implementation-plan
仅文档实施规划
phase-models
仅文档阶段规划参考
product_requirements
仅文档需求收集
project_brief
仅文档项目初始化

Testing Schemas (2)

测试Schema(2个)

SchemaWiring StatusConsumer
test_plan
DOCS ONLYTest planning reference
test-results
DOCS ONLYTest execution output
Schema连接状态消费者
test_plan
仅文档测试规划参考
test-results
仅文档测试执行输出

Architecture Schemas (3)

架构Schema(3个)

SchemaWiring StatusConsumer
specification-template
DOCS ONLYSpecification documents
system_architecture
DOCS ONLYArchitecture documentation
ux_spec
DOCS ONLYUX specification documents
Schema连接状态消费者
specification-template
仅文档规范文档
system_architecture
仅文档架构文档
ux_spec
仅文档UX规范文档

Project Schemas (1)

项目Schema(1个)

SchemaWiring StatusConsumer
project-analysis
DOCS ONLYProject analyzer output
Note: All schemas located at
.claude/schemas/
unless otherwise specified. See schema catalog for full details on consumers, validation methods, and integration status.
Schema连接状态消费者
project-analysis
仅文档项目分析器输出
注意: 所有Schema默认位于
.claude/schemas/
,除非另有说明。有关消费者、验证方法和集成状态的完整详情,请参阅Schema目录。

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
    .claude/rules/workspace-conventions.md
    (output placement, naming, provenance)
  • 文件放置: 详见
    .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
file-placement-guard.cjs
hook. Invalid placements will be blocked in production mode.

文件放置规则由
file-placement-guard.cjs
Hook强制执行。 生产模式下会阻止无效放置。

Memory Protocol (MANDATORY)

记忆协议(强制要求)

Before starting:
bash
cat .claude/context/memory/learnings.md
Check 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.md

Validation Checklist (Run After Every Creation)

验证清单(每次创建后运行)

bash
undefined
bash
undefined

Verify 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:
  1. Call
    runIntegrationChecklist(artifactType, artifactPath)
    from
    .claude/lib/creators/creator-commons.cjs
  2. Call
    queueCrossCreatorReview(artifactType, artifactPath)
    from
    .claude/lib/creators/creator-commons.cjs
  3. Review the impact report — address all
    mustHave
    items before marking task complete
  4. Log any
    shouldHave
    items as follow-up tasks
Integration verification:
  • Schema added to schema-catalog.md
  • Schema validator wired (if applicable)
  • Schema referenced by consuming artifacts
  • Schema has test data examples
创建完成后,请运行生态系统集成清单:
  1. 调用
    .claude/lib/creators/creator-commons.cjs
    中的
    runIntegrationChecklist(artifactType, artifactPath)
  2. 调用
    .claude/lib/creators/creator-commons.cjs
    中的
    queueCrossCreatorReview(artifactType, artifactPath)
  3. 查看影响报告 - 在标记任务完成前解决所有
    mustHave
  4. 将任何
    shouldHave
    项记录为后续任务
集成验证:
  • Schema已添加到schema-catalog.md
  • Schema验证器已连接(如适用)
  • 消费工件已引用Schema
  • Schema包含测试数据示例