Metadata Schema Generator 标志

Metadata Schema Generator

社区
murphytrueman
metadata-schema-generator

Generate per-component JSON metadata files (.ai/metadata/) from source: props, behaviour, composition, a11y contract, prohibited prop combinations. Triggers: component metadata schema, machine-readable component JSON, manifest for MCP/codegen. Prose for Figma: use ai-component-description.

Add to TypingMind

概览

发布者murphytrueman
代码仓库design-system-ops
技能名称metadata-schema-generator
星标数
211
复刻数
7
附带文件
仅含指令
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 murphytrueman 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Metadata Schema Generator AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/murphytrueman/design-system-ops/tree/main/skills/metadata-schema-generator
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/murphytrueman/design-system-ops.git /tmp/design-system-ops
mkdir -p .claude/skills
cp -r /tmp/design-system-ops/skills/metadata-schema-generator .claude/skills/metadata-schema-generator
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Metadata Schema Generator,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Metadata Schema Generator。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Metadata Schema Generator 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Metadata schema generator

A skill for generating structured JSON metadata schemas for design system components. These schemas encode everything an AI agent, MCP server, code generator, or testing framework needs to work with a component programmatically — props, behavioural rules, composition constraints, accessibility contracts, and (where the team supplies it) business context — in a format that does not require natural language parsing.

Before you begin: verify references

Confirm that every path in this skill's frontmatter references: exists relative to this SKILL.md. If any is missing, stop: the install is incomplete, usually because a flattening installer (for example npx skills install) dropped the repo-root knowledge-notes/ directory. Tell the user to reinstall by a method in 1-INSTALL.md and run verify-install.sh from the install root. Proceed without the references only if the user explicitly says to, and then say in the output that it was produced without the pack's reference material.

Context

Component documentation serves humans. Component metadata serves machines. The distinction matters because the information needs are different, the format requirements are different, and the failure modes are different.

A human reading a component's documentation can infer that "this button triggers the primary action" means it should be visually prominent and placed in the expected location. A code generation agent reading that same string cannot infer any of that — it needs explicit data: { "role": "primary_action", "visual_weight": "high", "placement": ["form_footer", "dialog_footer", "page_header"] }.

Most design systems have one layer of machine-readable data: TypeScript interfaces or PropTypes declarations that define prop names and types. This is necessary but insufficient. A TypeScript interface tells a tool that a Button accepts a variant prop of type "primary" | "secondary" | "ghost" — but it does not tell the tool when to use primary vs secondary, which combinations of props are prohibited, where the component can be placed in a layout, or what accessibility contract it must honour.

Structured metadata fills this gap. It encodes the knowledge layer between "what the component accepts" (TypeScript) and "how the component should be used" (documentation) as machine-readable data that tooling consumes directly.

The ai-component-description skill produces text descriptions optimised for LLM consumption. This skill produces structured data optimised for programmatic consumption. Together they serve the two modes of AI interaction: conversational (descriptions) and deterministic (metadata).

Boundaries

This skill is the pack's one extraction of component facts. It generates structured JSON metadata for tooling — not human-readable documentation (usage-guidelines, pattern-documentation) or LLM-facing prose (ai-component-description); those two read .ai/metadata/ when it exists and render from it, so the props and accessibility contract are derived once. If the system has no component inventory yet, run codebase-index first. If no component source is in reach, stop and ask for it: metadata can't be extracted from a description. If the team has no consumer for the files yet (no AGENTS.md pointing at them, no MCP server, no lint integration), say so and suggest agent-instructions as the first consumer rather than generating files nothing reads.


Configuration

If .ds-ops-config.yml exists, follow the configuration-and-recurring knowledge note (../../knowledge-notes/configuration-and-recurring.md) for loading, integration fallbacks and recurring runs. This skill reads:

  • system.framework — determines prop extraction approach (React, Vue, Svelte, etc.)
  • system.component_paths — directs scanning to component source files
  • integrations.* — component data (see below)
  • metadata.schema_version — locks the output schema version for compatibility
  • metadata.output_directory — overrides default output location
  • metadata.include_business_context — toggles the business context layer (default: false; see Step 4)

Auto-pull integrations

Figma MCP (integrations.figma.enabled: true):

  • Read component properties, variant structures, and descriptions from integrations.figma.file_key
  • Cross-reference Figma component properties against code props to detect mismatches
  • Extract accessibility annotations if present

Storybook (integrations.storybook.enabled: true):

  • Fetch prop tables and arg types from story metadata
  • Extract documented states and control definitions
  • Pull interaction test definitions if available

Source (always attempted, with the tool that fits):

  • React with TypeScript: react-docgen-typescript gives name, type, required, default and description per prop; hand-read only what it can't resolve (complex generics), and say so
  • Vue: vue-component-meta
  • Web Components: the Custom Elements Manifest (npx custom-elements-manifest analyze, or an existing custom-elements.json)
  • Anything else: read the interfaces, PropTypes and JSDoc by hand, and note under Scope that extraction was manual

Step 1: Select components and assess existing metadata

Ask for or confirm (skip questions already answered by auto-pull):

  • Which components need metadata schemas? (Specific components, a category, or the full library)
  • Where do component source files live?
  • Is there existing structured metadata in any format (JSON, YAML, Custom Elements Manifest)?

For each component, scan for existing metadata sources:

  • TypeScript interface or PropTypes declaration
  • JSDoc/TSDoc annotations
  • Storybook arg types and controls
  • Existing metadata files (.metadata.json, .metadata.ts)
  • Figma component description

Produce a source assessment per component:

ComponentTS interfaceJSDocStorybookFigmaExisting metadataGaps
Buttoncompletepartialcompleteyesnonecomposition, behaviour
Cardcompletenonepartialyesnoneall semantic layers

Step 2: Generate the base schema from source

For each component, extract the prop layer automatically from TypeScript or equivalent:

Illustrative Button (a real run uses the component's actual source):

json
{
  "$schema": "./schema.json",
  "component": "Button",
  "version": "1.0.0",
  "status": "stable",
  "props": [
    {
      "name": "variant",
      "type": "enum",
      "values": ["primary", "secondary", "ghost"],
      "default": "primary",
      "required": false,
      "description": "Visual weight of the button",
      "semantic": {
        "primary": "Use for the single most important action on the page or in a section",
        "secondary": "Use for supporting actions alongside a primary action",
        "ghost": "Use for tertiary actions or actions within dense UI"
      }
    },
    {
      "name": "size",
      "type": "enum",
      "values": ["sm", "md", "lg"],
      "default": "md",
      "required": false,
      "description": "Controls button height and text size"
    },
    {
      "name": "disabled",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Prevents interaction and applies disabled styling"
    },
    {
      "name": "loading",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Shows a spinner in place of the label and prevents interaction"
    },
    {
      "name": "aria-label",
      "type": "string",
      "required": false,
      "description": "Accessible name when the button has no visible text"
    },
    {
      "name": "children",
      "type": "ReactNode",
      "required": true,
      "description": "Button label content"
    }
  ]
}

Build on the standard, don't invent one. For Web Components the metadata file is the Custom Elements Manifest with a dsops object added to each declaration for the semantic layers (CEM allows additional properties, and every CEM consumer keeps reading it). For React and Vue, the props array keeps docgen's field names (name, type, required, defaultValue, description) so anything that reads docgen output reads this too, and the semantic layers sit beside it.

Extraction rules:

  • Every prop in the TypeScript interface must appear in the schema
  • Keep the raw type string in type.raw; add type.kind normalised to string, number, boolean, enum, ReactNode, function, object, array, so generics and non-literal unions aren't lost
  • Enum values must be listed explicitly, not as a type reference
  • Take default from the source's declared default. Omit default when source declares none
  • If a prop has JSDoc, use it as the description. If not, flag the prop for manual description.
  • Per-value semantic text comes from JSDoc or the team's docs. If neither has it, leave semantic out and flag the prop rather than writing plausible guidance

Step 3: Add the semantic layer

The semantic layer encodes meaning that TypeScript types cannot express. For each component, add the three blocks below.

Provenance rule. Every behaviour, composition and accessibility block carries a provenance value: source (read from the component code), docs (from the team's documentation or the user), or proposed (anything not traced to either). A block that mixes sources takes the weakest. Never present a proposed rule as the system's actual behaviour or policy: tools and agents read this file as ground truth. See "Every figure and fact needs a source" in the output-discipline knowledge note.

The examples below continue the illustrative Button.

Behavioural rules

json
{
  "behaviour": {
    "states": ["default", "hover", "active", "focus", "disabled", "loading"],
    "transitions": {
      "default_to_loading": {
        "trigger": "Form submission or async action",
        "visual": "Replace label with spinner, disable interaction",
        "duration": "Until async operation completes or times out"
      }
    },
    "constraints": [
      "At most one primary variant Button per form",
      "Loading state must disable all sibling interactive elements",
      "Icon-only buttons must have an aria-label prop"
    ],
    "provenance": "docs"
  }
}

The first two constraints stand in for team rules: record rules like these only when the team's docs or the user state them.

Composition rules

json
{
  "composition": {
    "valid_parents": ["Form", "Card", "Dialog", "Toolbar", "PageHeader"],
    "valid_children": ["Icon", "text"],
    "prohibited_nesting": ["Button may not contain another Button"],
    "slot_contract": {
      "children": {
        "accepts": ["string", "Icon"],
        "max_elements": 2,
        "pattern": "Optional leading Icon + text label"
      }
    },
    "common_combinations": [
      { "pattern": "Primary + Secondary pair", "context": "Dialog footer, form actions" },
      { "pattern": "Icon-only in Toolbar", "context": "Dense action bars" }
    ],
    "provenance": "proposed"
  }
}

Accessibility contract

json
{
  "accessibility": {
    "role": "button",
    "aria_required": [],
    "aria_conditional": [
      { "prop": "aria-label", "when": "children is Icon only (no visible text)" },
      { "prop": "aria-expanded", "when": "button controls a collapsible region" },
      { "prop": "aria-haspopup", "when": "button opens a menu or dialog" }
    ],
    "keyboard": {
      "Enter": "Activate button",
      "Space": "Activate button"
    },
    "focus": {
      "receives_focus": true,
      "focus_visible": "Required — uses system focus ring token",
      "tab_order": "Follows DOM order unless explicitly managed"
    },
    "screen_reader": {
      "announcement": "Button label + role",
      "state_changes": "Announces disabled state change"
    },
    "provenance": "source"
  }
}

Step 4: Add the business context layer

The business context layer connects the component to product outcomes. It is off by default (metadata.include_business_context: false). Include it only when the user or the team's docs supply the metrics and rules, and give every entry a source (file path, URL, or user). Never infer a component's business function, metrics or traffic from its name.

Illustrative shape:

json
{
  "business_context": {
    "function": { "value": "conversion", "source": "user" },
    "metrics": [
      { "name": "Click-through rate", "role": "primary", "source": "docs/analytics/cta-tracking.md" },
      { "name": "Form completion rate", "role": "secondary", "source": "user" }
    ],
    "experimentation": {
      "safe_to_test": ["label text", "variant within brand palette"],
      "never_test": ["removing disabled state logic", "removing aria attributes"],
      "requires_review": ["changing size scale", "adding new variants"],
      "source": "user"
    },
    "usage_analytics": {
      "custom_events": [
        { "event": "cta_click", "data": ["variant", "page", "position"], "source": "src/analytics/events.ts" }
      ]
    }
  }
}

Step 5: Add prohibited combinations

Encode prop combinations that are technically valid but semantically wrong. Each entry carries a provenance value, as in Step 3:

json
{
  "prohibited_combinations": [
    {
      "combination": { "variant": "ghost", "size": "lg" },
      "reason": "Ghost buttons at large size create false visual hierarchy — they appear as primary actions despite being tertiary",
      "severity": "warning",
      "provenance": "proposed"
    },
    {
      "combination": { "disabled": true, "loading": true },
      "reason": "Redundant states — loading already prevents interaction. Use loading alone.",
      "severity": "error",
      "provenance": "docs"
    }
  ]
}

Severity levels:

  • error — this combination is prohibited and tools should refuse to generate it
  • warning — this combination is discouraged and tools should flag it for review
  • info — this combination has nuances the developer should be aware of

Step 6: Produce the complete schema

Assemble all layers into the complete metadata schema per component.

Output structure

.ai/metadata/
  schema.json          # JSON Schema definition for validation
  Button.metadata.json
  Card.metadata.json
  Modal.metadata.json
  ...
  manifest.json        # Index of all metadata files

Base schema (schema.json)

Write a JSON Schema alongside the metadata files so validation (Step 7) and CI have something to check against. A minimal version:

json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Component metadata",
  "type": "object",
  "required": ["component", "props"],
  "properties": {
    "component": { "type": "string" },
    "version": { "type": "string" },
    "status": { "enum": ["alpha", "beta", "stable", "deprecated"] },
    "props": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "type", "required"],
        "properties": {
          "name": { "type": "string" },
          "type": { "enum": ["string", "number", "boolean", "enum", "ReactNode", "function", "object", "array"] },
          "values": { "type": "array" },
          "default": {},
          "required": { "type": "boolean" },
          "description": { "type": "string" },
          "semantic": { "type": "object" }
        }
      }
    },
    "behaviour": { "$ref": "#/$defs/layer" },
    "composition": { "$ref": "#/$defs/layer" },
    "accessibility": { "$ref": "#/$defs/layer" },
    "business_context": { "type": "object" },
    "prohibited_combinations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["combination", "reason", "severity", "provenance"],
        "properties": {
          "severity": { "enum": ["error", "warning", "info"] },
          "provenance": { "$ref": "#/$defs/provenance" }
        }
      }
    }
  },
  "$defs": {
    "provenance": { "enum": ["source", "docs", "proposed"] },
    "layer": {
      "type": "object",
      "required": ["provenance"],
      "properties": { "provenance": { "$ref": "#/$defs/provenance" } }
    }
  }
}

Manifest format

Illustrative values; coverage figures are counted from the files actually generated.

json
{
  "generated": "[date]",
  "system": "[design system name]",
  "component_count": 55,
  "coverage": {
    "props": "100%",
    "semantic": "85%",
    "accessibility": "90%",
    "business_context": "40%",
    "prohibited_combinations": "60%"
  },
  "components": [
    { "name": "Button", "file": "Button.metadata.json", "status": "stable" },
    { "name": "Card", "file": "Card.metadata.json", "status": "stable" }
  ]
}

Step 7: Validate the schemas

Run validation checks on the generated schemas:

Structural validation:

  • Every schema is valid JSON
  • Every schema conforms to schema.json: run npx ajv validate -s .ai/metadata/schema.json -d ".ai/metadata/*.metadata.json" (ajv-cli) and report its output. If ajv isn't available and can't be installed, say validation wasn't run; don't report the files as valid
  • Every behaviour, composition and accessibility block, and every prohibited combination, has a provenance value
  • Every prop in the TypeScript interface appears in the schema (no missing props)
  • Every enum value listed in the schema exists in the TypeScript type (no phantom values)

Semantic validation:

  • Every prop has a description (not just a type)
  • Every enum prop either has per-value semantic descriptions from a source, or is listed under "Needs a human" (never filled with plausible guidance)
  • Composition rules reference components that exist in the system (no broken references)
  • Accessibility contracts are complete for all interactive components

Cross-reference validation:

  • Component names in metadata match component names in code
  • Prop names and types match TypeScript interfaces
  • Where both sides declare composition, they agree (Card lists Button as a child and Button lists Card as a parent); a one-sided declaration is listed for review, not treated as an error
  • Status fields are consistent with the component's actual lifecycle status

Coverage reporting:

  • What percentage of components have complete metadata schemas?
  • What percentage of props have semantic descriptions beyond the TypeScript type?
  • What percentage of interactive components have accessibility contracts?
  • What percentage of conversion-related components have business context?

Step 8: Summarise in chat

End with a short chat summary:

  • Headline: how many component files were written and how many are complete
  • Files written: paths under .ai/metadata/ (or the configured metadata.output_directory), including schema.json and manifest.json
  • Needs a human: props flagged for manual description, and every block or combination marked proposed
  • Scope: the block from the output-discipline knowledge note, including components and sources not scanned

Recommend to the user

  • Co-locate metadata files with component source files or in a dedicated .ai/metadata/ directory
  • Automate prop extraction from TypeScript interfaces to keep the base layer in sync
  • Treat semantic, accessibility, and composition layers as authored knowledge: entries generated without a source stay proposed until someone on the team confirms them
  • Run validation as part of CI to catch metadata drift from source
  • Use the manifest as the entry point for all tooling that consumes component metadata
  • Regenerate after adding components, changing props, or updating accessibility contracts

Quality checks

  • Every generated schema is valid JSON and was validated with ajv, or the summary says validation didn't run
  • Props came from docgen, component-meta or a Custom Elements Manifest where one applies, keep the raw type alongside the normalised kind, and the Scope block names the extraction method
  • Semantic descriptions add information beyond what the prop name and type convey
  • Composition rules form a consistent graph (no contradictions between parent and child declarations)
  • Accessibility contracts cover all interactive components, not just the most common ones
  • Prohibited combinations cite specific reasons, not generic advice
  • The manifest accurately reflects the actual set of generated schema files
  • Business context appears only where the user or docs supplied it, and every entry has a source
  • Nothing traced to neither source nor docs is presented without a proposed marker

常见问题

Metadata Schema Generator AI 技能有什么作用?

Generate per-component JSON metadata files (.ai/metadata/) from source: props, behaviour, composition, a11y contract, prohibited prop combinations. Triggers: component metadata schema, machine-readable component JSON, manifest for MCP/codegen. Prose for Figma: use ai-component-description.

为什么在 TypingMind 中使用 Metadata Schema Generator?

因为您只需安装一次,就能搭配任何模型使用。Metadata Schema Generator 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Metadata Schema Generator?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/murphytrueman/design-system-ops/tree/main/skills/metadata-schema-generator。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Metadata Schema Generator?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Metadata Schema Generator 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Metadata Schema Generator 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Metadata Schema Generator AI 技能免费吗?

是的。murphytrueman 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇