/metaschema:metaschema-module-authoringfrom metaschema
Guides creation and modification of Metaschema modules in YAML or XML, covering module structure, definitions, header elements, and format-specific features.
Ships in metaschema. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill guides the creation and modification of Metaschema modules, which define information models that can be serialized to XML, JSON, or YAML.
Repository-specific conventions (file locations, namespaces, testing) are in .claude/rules/metaschema-authoring.md.
Metaschema modules can be authored in either XML or YAML format. These formats are semantically equivalent:
For example, a module written in YAML can parse XML documents and serialize to JSON, and vice versa. The authoring format is purely a developer preference.
---
METASCHEMA:
schema-name: Human-readable module name
short-name: module-short-name
namespace: http://example.com/ns/module
json-base-uri: http://example.com/ns/module
schema-version: 1.0.0
definitions:
- object-type: assembly
name: root-assembly
# ... definition content
<?xml version="1.0" encoding="UTF-8"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
<schema-name>Human-readable module name</schema-name>
<schema-version>1.0.0</schema-version>
<short-name>module-short-name</short-name>
<namespace>http://example.com/ns/module</namespace>
<json-base-uri>http://example.com/ns/module</json-base-uri>
<define-assembly name="root-assembly">
<!-- definition content -->
</define-assembly>
</METASCHEMA>
| Element | Description |
|---|---|
schema-name | Human-readable module name for documentation |
schema-version | Semantic version (e.g., 1.0.0) |
short-name | Unique identifier, used in artifact names |
namespace | XML namespace URI for elements |
json-base-uri | URI for JSON Schema $schema keyword |
| Element | Description |
|---|---|
@abstract | Set to yes for import-only modules (default: no) |
remarks | Additional documentation |
import | Import definitions from other modules |
Assemblies are structured containers with optional flags and a model (nested content).
YAML:
- object-type: assembly
name: user
formal-name: User
description: A system user account.
root-name:
name: user
flags:
- object-type: flag
name: id
formal-name: User ID
description: Unique identifier for the user.
as-type: uuid
required: "yes"
model:
instances:
- object-type: field-ref
ref: username
min-occurs: 1
- object-type: assembly-ref
ref: role
max-occurs: unbounded
group-as:
name: roles
in-json: ARRAY
XML:
<define-assembly name="user">
<formal-name>User</formal-name>
<description>A system user account.</description>
<root-name>user</root-name>
<define-flag name="id" as-type="uuid" required="yes">
<formal-name>User ID</formal-name>
<description>Unique identifier for the user.</description>
</define-flag>
<model>
<field ref="username" min-occurs="1"/>
<assembly ref="role" max-occurs="unbounded">
<group-as name="roles" in-json="ARRAY"/>
</assembly>
</model>
</define-assembly>
Fields contain typed values and optional flags.
YAML:
- object-type: field
name: email
formal-name: Email Address
description: User's email address.
as-type: email-address
XML:
<define-field name="email" as-type="email-address">
<formal-name>Email Address</formal-name>
<description>User's email address.</description>
</define-field>
Flags are leaf nodes representing simple typed values (attributes in XML, properties in JSON).
YAML:
- object-type: flag
name: status
formal-name: Status
description: The current status.
as-type: token
default: active
XML:
<define-flag name="status" as-type="token" default="active">
<formal-name>Status</formal-name>
<description>The current status.</description>
</define-flag>
See the Metaschema Data Types specification for complete details.
| Type | Description |
|---|---|
string | Unicode string (default for flags) |
token | Whitespace-normalized string |
boolean | true or false |
integer | Signed integer |
non-negative-integer | Zero or positive integer |
positive-integer | Positive integer (> 0) |
decimal | Decimal number |
uuid | UUID v4 or v5 |
uri | Absolute URI |
uri-reference | Absolute or relative URI |
date | ISO 8601 date |
date-time | ISO 8601 date-time |
date-with-timezone | Date with required timezone |
date-time-with-timezone | Date-time with required timezone |
email-address | RFC 5322 email |
hostname | Domain name |
ip-v4-address | IPv4 address |
ip-v6-address | IPv6 address |
base64 | Base64-encoded binary |
| Type | Description |
|---|---|
markup-line | Inline markup (no block elements) |
markup-multiline | Block-level markup content |
Use ref to reference global definitions. All three definition types can be referenced:
YAML:
# Flag reference (in assembly/field definition)
flags:
- object-type: flag-ref
ref: id
required: "yes"
# Assembly and field references (in model)
model:
instances:
- object-type: assembly-ref
ref: address
min-occurs: 0
max-occurs: 1
- object-type: field-ref
ref: description
XML:
<!-- Flag reference -->
<flag ref="id" required="yes"/>
<!-- Assembly and field references in model -->
<model>
<assembly ref="address" min-occurs="0" max-occurs="1"/>
<field ref="description"/>
</model>
Define and instantiate in one place (for single-use elements):
YAML:
model:
instances:
- object-type: assembly
name: metadata
formal-name: Metadata
description: Document metadata.
model:
instances:
- object-type: field
name: title
formal-name: Title
as-type: string
XML:
<model>
<define-assembly name="metadata">
<formal-name>Metadata</formal-name>
<description>Document metadata.</description>
<model>
<define-field name="title" as-type="string">
<formal-name>Title</formal-name>
</define-field>
</model>
</define-assembly>
</model>
The choice between inline definitions and global definitions with references affects how Java classes are generated:
| Approach | Generated Structure | Use When |
|---|---|---|
| Inline definitions | Nested inner classes | Single-use, tightly coupled structures |
| Global definitions + refs | Separate top-level classes | Reusable, shared across multiple parents |
# This YAML structure with inline definitions:
- object-type: assembly
name: parent
model:
instances:
- object-type: assembly
name: child
formal-name: Child
model:
instances:
- object-type: field
name: value
as-type: string
Generates:
public class Parent {
public static class Child {
// nested inside Parent
}
}
# This YAML structure with global definitions and refs:
definitions:
- object-type: assembly
name: parent
model:
instances:
- object-type: assembly-ref
ref: child
- object-type: assembly
name: child
formal-name: Child
Generates:
public class Parent { ... }
public class Child { ... } // separate file
Key insight: Use inline definitions when you want tightly coupled, nested class hierarchies (like binding configurations with deeply nested elements). Use global definitions with refs when the component is reused elsewhere.
| Attribute | Default | Description |
|---|---|---|
min-occurs | 0 | Minimum occurrences |
max-occurs | 1 | Maximum occurrences (use unbounded for unlimited) |
Required when max-occurs > 1. Controls collection representation:
YAML:
- object-type: assembly-ref
ref: item
max-occurs: unbounded
group-as:
name: items
in-json: ARRAY
in-xml: UNGROUPED
XML:
<assembly ref="item" max-occurs="unbounded">
<group-as name="items" in-json="ARRAY" in-xml="UNGROUPED"/>
</assembly>
| Value | Description |
|---|---|
WRAPPED | Field wrapped in element (default) |
UNWRAPPED | Field content appears directly (markup-multiline only) |
| Value | Description |
|---|---|
UNGROUPED | No wrapper element (default) |
GROUPED | Items wrapped in container element |
Use root-name on an assembly to designate it as a document root:
- object-type: assembly
name: catalog
root-name:
name: catalog
| Value | Description |
|---|---|
ARRAY | Always use array notation |
SINGLETON_OR_ARRAY | Single value or array (default) |
BY_KEY | Object with flag values as property names |
Used with in-json="BY_KEY" to group items as object properties instead of an array. The referenced flag's value becomes the property name.
YAML:
- object-type: assembly
name: parameter
flags:
- object-type: flag
name: id
as-type: token
required: "yes"
json-key:
flag-ref: id
# When used with group-as in-json: BY_KEY, produces:
# "parameters": { "param1": {...}, "param2": {...} }
# instead of: "parameters": [{...}, {...}]
XML:
<define-assembly name="parameter">
<json-key flag-ref="id"/>
<define-flag name="id" as-type="token" required="yes"/>
</define-assembly>
Control the property name for a field's value in JSON. Two forms are available:
Use a static property name for the field's value:
YAML:
- object-type: field
name: title
as-type: string
json-value-key: text
# Produces: { "text": "the value" }
XML:
<define-field name="title" as-type="string">
<json-value-key>text</json-value-key>
</define-field>
Use a flag's value as the property name for the field's value:
YAML:
- object-type: field
name: property
as-type: string
flags:
- object-type: flag
name: name
as-type: token
required: "yes"
json-value-key-flag:
flag-ref: name
# If flag value is "color", produces: { "color": "blue" }
XML:
<define-field name="property" as-type="string">
<json-value-key-flag flag-ref="name"/>
<define-flag name="name" as-type="token" required="yes"/>
</define-field>
Import definitions from other modules. Imports are cross-format compatible: a YAML module can import XML modules, and an XML module can import YAML modules. The authoring format of the imported module does not affect compatibility.
YAML importing both formats:
METASCHEMA:
# ... header elements
imports:
- href: ../common/common-types.yaml # YAML module
- href: ../legacy/old-definitions.xml # XML module works too
definitions:
# ... use imported definitions from either format
XML importing both formats:
<METASCHEMA>
<!-- header elements -->
<import href="../common/common-types.xml"/> <!-- XML module -->
<import href="../new/new-definitions.yaml"/> <!-- YAML module works too -->
<!-- definitions -->
</METASCHEMA>
The scope attribute controls definition visibility across module imports.
| Value | Description |
|---|---|
global | Available to importing modules (default) |
local | Only available within the defining module |
When a definition is referenced (via ref), the lookup follows this order:
global and local)global) definitions from imported modulesglobal definitions are exported to importing moduleslocal definitions are never exported; they can only be referenced within their defining moduleroot-name) are always exported regardless of scopeWhen multiple imported modules define the same name:
global scoped definitions are considered for importYAML:
# Module A - defines a local helper
- object-type: field
name: internal-helper
scope: local # Not exported
as-type: string
# Module A - defines a global type
- object-type: field
name: shared-type
scope: global # Exported (this is the default)
as-type: token
XML:
<!-- Local definition - only usable within this module -->
<define-field name="internal-helper" scope="local" as-type="string"/>
<!-- Global definition - available to importing modules -->
<define-field name="shared-type" scope="global" as-type="token"/>
local: Internal helper definitions, implementation details not meant for external useglobal: Reusable definitions intended to be shared across modulesFor mutually exclusive content:
XML:
<model>
<choice>
<field ref="inline-content"/>
<assembly ref="external-reference"/>
</choice>
</model>
formal-name and descriptionschema-version- object-type: flag
name: uuid
formal-name: Universally Unique Identifier
description: A unique identifier for this element.
as-type: uuid
required: "yes"
- object-type: flag
name: location
formal-name: Location
description: A URI reference to the resource location.
as-type: uri-reference
required: "yes"
- object-type: flag
name: format
formal-name: Format
description: The content format.
as-type: token
constraint:
rules:
- object-type: allowed-values
enums:
- value: XML
remark: XML format.
- value: JSON
remark: JSON format.
- value: YAML
remark: YAML format.
model:
instances:
- object-type: assembly-ref
ref: item
min-occurs: 1
max-occurs: unbounded
group-as:
name: items
in-json: ARRAY
model:
instances:
- object-type: field-ref
ref: description
min-occurs: 0
max-occurs: 1
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub metaschema-framework/claude-plugins --plugin metaschema4 skills in this plugin
/metapath-expressionsUse when writing Metapath expressions for constraints, queries, or traversals - covers path syntax, operators, functions, and data model based on XPath 3.1/metaschema-basicsUse as an introduction to Metaschema concepts - provides overview and routes to detailed skills/metaschema-constraints-authoringUse when creating or modifying Metaschema constraints - covers all constraint types, inline vs external constraints, Metapath expressions, and validation patterns