msgspec
Installation
SKILL.md
msgspec Skill
msgspec is a high-performance Python library for serialization, deserialization, and typed
validation. This guidance targets the immutable 0.21.1 release.
Code Style Rules
- Use PEP 604 for unions:
T | None(notOptional[T]) from __future__ import annotationsrule — Library/shared modules that define runtime-introspectedmsgspec.Structsubclasses should avoid postponed annotations unless the consuming tool resolves them. Consumer modules that only use Structs MAY use future annotations.- Annotate every serialized field; only annotated attributes become Struct fields
- Use
kw_only=Truefor Structs with more than 2 fields - Put wire-name configuration on
msgspec.field(name=...)or the Struct'srename=option;msgspec.Metadefines constraints and JSON Schema metadata, not field aliases