Skip to content

Commit 7a0e25d

Browse files
authored
Merge pull request #1 from CrystallizeAPI/feature/skills-hardening
enabled full modelling capabilities on variant components
2 parents b51bbd7 + f420b46 commit 7a0e25d

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

use-crystallize/skills/content-model/SKILL.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Product variants have additional built-ins: `sku`, `images`, `videos`, `price`,
6767

6868
**Components are the additional fields you define** beyond these built-ins. For product shapes, use `variantComponents` in the shape definition to add custom components directly to product variants (e.g., custom certifications, variant-level specs).
6969

70+
**`variantComponents` supports all component types**, including structured components: `contentChunk`, `componentChoice`, `componentMultipleChoice`, and `piece` references. This means you can add repeating field groups, polymorphic choices, or reusable pieces directly on variants — not just simple fields like `singleLine` or `numeric`. For example, a product variant can have a `contentChunk` for packaging dimensions, or a `componentChoice` for variant-specific technical specs.
71+
72+
**`variantComponents` require the same type discipline as product-level components** — apply the Component Selection Guide below. Measurable values (weight, voltage, length) → `numeric` with units. Controlled options (connection type, material) → `selection`. Free-form identifiers → `singleLine`. Do not default everything to `singleLine`.
73+
7074
**IMPORTANT:** Do NOT add components for price or stock - these are native properties managed through the product variant's built-in fields. Only create custom price/stock components for specific edge cases (e.g., tiered pricing models, subscription pricing, price modifiers for configurators).
7175

7276
**Product Identification:** The built-in `sku` field on product variants is the primary product identifier — use it for GTIN, EAN, ISBN, or any single identifier. Do NOT add a separate `gtin` or `ean` single-line component on the variant. If a product needs **multiple identifiers** (e.g., both ISBN-10 and ISBN-13, or a GTIN plus a legacy system ID), add an **identifiers chunk** with named fields to the shape:
@@ -773,6 +777,8 @@ Piece: "SEO" (not "SEO Metadata")
773777

774778
**Flat component lists** - Group related fields with Chunks for better structure
775779

780+
**Flat singleLine variant components** - `variantComponents` follow the same type rules as product-level components. Voltage, length, weight → `numeric` with units. Connection type, material, animal version → `selection` with options. Only use `singleLine` for genuinely free-form text (a color label, a custom code). A variant story full of `singleLine` is a modeling smell.
781+
776782
**Mixing variant data with product data** - Use variant attributes (built-in) for size/color/sku
777783

778784
**Adding GTIN/EAN/ISBN as a variant component** - The built-in `sku` field handles single product identifiers. For multiple identifiers, add a chunk with named single-line components (e.g., `isbn-10`, `isbn-13`, `gtin`, `ean`, `upc`, `legacy-id`) at the shape level, not on the variant.
@@ -900,7 +906,15 @@ Components can reference pieces (via `type: "piece"`) and shapes (via `itemRelat
900906
}
901907
}
902908
],
903-
"variantComponents": [{ "id": "gtin", "name": "GTIN", "type": "singleLine" }]
909+
"variantComponents": [
910+
{ "id": "weight", "name": "Weight", "type": "numeric", "config": { "numeric": { "units": ["g", "kg"], "discoverable": true } } },
911+
{
912+
"id": "color",
913+
"name": "Color",
914+
"type": "selection",
915+
"config": { "selection": { "options": [{ "key": "black", "value": "Black" }, { "key": "white", "value": "White" }] } }
916+
}
917+
]
904918
},
905919
{
906920
"intent": "shape/upsert",

use-crystallize/skills/content-model/references/shapes.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Use `variantComponents` when you need variant-level data beyond the built-in SKU
3232
- Variant-level specs that differ per variant (e.g., battery capacity per size)
3333
- Custom variant identifiers (e.g., manufacturer variant codes)
3434

35+
**`variantComponents` supports all component types**, including structured components: `contentChunk`, `componentChoice`, `componentMultipleChoice`, and `piece` references. You are not limited to simple fields — you can model rich, grouped, or polymorphic data directly on variants.
36+
3537
```graphql
3638
mutation {
3739
createShape(
@@ -49,7 +51,7 @@ mutation {
4951
}
5052
]
5153
variantComponents: [
52-
# Variant-level custom components
54+
# Simple variant-level components
5355
{
5456
id: "battery-capacity"
5557
name: "Battery Capacity"
@@ -62,6 +64,29 @@ mutation {
6264
type: singleLine
6365
config: { singleLine: { multilingual: true } }
6466
}
67+
# Structured variant-level component (contentChunk)
68+
{
69+
id: "packaging"
70+
name: "Packaging Dimensions"
71+
type: contentChunk
72+
config: {
73+
contentChunk: {
74+
components: [
75+
{ id: "width", name: "Width", type: numeric, config: { numeric: { units: ["cm", "in"] } } }
76+
{ id: "height", name: "Height", type: numeric, config: { numeric: { units: ["cm", "in"] } } }
77+
{ id: "depth", name: "Depth", type: numeric, config: { numeric: { units: ["cm", "in"] } } }
78+
{ id: "weight", name: "Weight", type: numeric, config: { numeric: { units: ["g", "kg"] } } }
79+
]
80+
}
81+
}
82+
}
83+
# Piece reference on a variant
84+
{
85+
id: "certifications"
86+
name: "Certifications"
87+
type: piece
88+
config: { piece: { identifier: "variant-certifications" } }
89+
}
6590
]
6691
}
6792
) {
@@ -74,6 +99,8 @@ mutation {
7499

75100
> **Note:** Do not use `variantComponents` for fields that are the same across all variants — those belong in `components` (product level).
76101
102+
> **Type discipline:** `variantComponents` follow the exact same component type rules as product-level components. Use `numeric` (with units) for measurable values like voltage, length, weight, or wattage. Use `selection` for controlled options like connection type, material, or animal version. Reserve `singleLine` for genuinely free-form text. A variant story full of `singleLine` components is a modeling smell — it loses queryability, unit awareness, and editor guardrails.
103+
77104
### Document Shape
78105

79106
Used for editorial and marketing content. **Documents are leaf nodes and cannot have children.**

0 commit comments

Comments
 (0)