$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-agentic-metafields-setupDefine and populate agentic-commerce metafields (material, attributes, key features, specs, sizing) so AI agents can filter and match products to specific shopper requirements.
| 1 | ## Purpose |
| 2 | AI agents answer constrained queries — "squat-proof leggings under $60", "eucalyptus slip-ons", "machine-washable wool" — by filtering on structured attributes. If those attributes live only in prose (or nowhere), the agent can't filter and your products drop out of the result set. This skill establishes a small, standard set of **agentic metafield definitions** (material, key features, care, fit, specs) and populates them across the catalog from existing product signals, so agents can match products to requirements. Fixes `listing-metafields`, `variant-metadata`, and `sizing-specs-structured`. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session (`shopify auth login --store <domain>`) |
| 6 | - Required API scopes: `read_products`, `write_products`, `read_metaobject_definitions`, `write_metaobject_definitions` (for definitions) |
| 7 | |
| 8 | ## Parameters |
| 9 | All skills accept these universal parameters: |
| 10 | |
| 11 | | Parameter | Type | Required | Default | Description | |
| 12 | |-----------|--------|----------|---------|-------------| |
| 13 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 14 | | format | string | no | human | Output format: `human` (default) or `json` | |
| 15 | | dry_run | bool | no | false | Preview mutations without executing | |
| 16 | |
| 17 | Skill-specific parameters: |
| 18 | |
| 19 | | Parameter | Type | Required | Default | Description | |
| 20 | |-----------|------|----------|---------|-------------| |
| 21 | | namespace | string | no | agentic | Metafield namespace to create/populate under | |
| 22 | | keys | string | no | material,features,care,fit,specs | Comma list of metafield keys to ensure exist | |
| 23 | | collection_id | string | no | — | Limit population to a collection GID | |
| 24 | | tag | string | no | — | Limit population to a product tag | |
| 25 | | populate_from | string | no | tags,options,description | Sources to infer values from (no fabrication beyond these) | |
| 26 | |
| 27 | ## Safety |
| 28 | |
| 29 | > ⚠️ Step 2 (`metafieldDefinitionCreate`) and Step 4 (`metafieldsSet`) write store schema + product data. Definitions are cheap to add but clutter the admin if mis-namespaced; values written from inference can be wrong. Run `dry_run: true`, review the proposed definitions and the value preview, and only populate values inferred with high confidence — leave the rest blank for human fill. |
| 30 | |
| 31 | ## Workflow Steps |
| 32 | |
| 33 | 1. **OPERATION:** `metafieldDefinitions` — query |
| 34 | **Inputs:** `ownerType: PRODUCT`, `namespace: <namespace>` |
| 35 | **Expected output:** Which target keys already have definitions (skip those). |
| 36 | |
| 37 | 2. **OPERATION:** `metafieldDefinitionCreate` — mutation |
| 38 | **Inputs:** one per missing key: `{ namespace, key, name, ownerType: PRODUCT, type: "single_line_text_field" | "list.single_line_text_field" }` |
| 39 | **Expected output:** Created definitions; collect `userErrors` (e.g. already-taken). |
| 40 | |
| 41 | 3. **OPERATION:** `products` — query |
| 42 | **Inputs:** `first: 250`, optional filter; fields `tags`, `options`, `descriptionHtml`, existing `metafields(namespace)`; paginate. |
| 43 | **Expected output:** Products + the signals to infer attribute values from. |
| 44 | |
| 45 | 4. **OPERATION:** `metafieldsSet` — mutation |
| 46 | **Inputs:** batches of `{ ownerId, namespace, key, value, type }` for confidently-inferred, currently-empty values. |
| 47 | **Expected output:** Set metafields; collect `userErrors`. |
| 48 | |
| 49 | ## GraphQL Operations |
| 50 | |
| 51 | ```graphql |
| 52 | # metafieldDefinitions:query — validated against api_version 2025-01 |
| 53 | query AgenticMetafieldDefs($namespace: String!) { |
| 54 | metafieldDefinitions(first: 50, ownerType: PRODUCT, namespace: $namespace) { |
| 55 | edges { node { id namespace key name type { name } } } |
| 56 | } |
| 57 | } |
| 58 | ``` |
| 59 | |
| 60 | ```graphql |
| 61 | # metafieldDefinitionCreate:mutation — validated against api_version 2025-01 |
| 62 | mutation AgenticMetafieldDefCreate($definition: MetafieldDefinitionInput!) { |
| 63 | metafieldDefinitionCreate(definition: $definition) { |
| 64 | createdDefinition { id namespace key } |
| 65 | userErrors { field message code } |
| 66 | } |
| 67 | } |
| 68 | ``` |
| 69 | |
| 70 | ```graphql |
| 71 | # products:query — validated against api_version 2025-01 |
| 72 | query AgenticMetafieldProducts($first: Int!, $after: String, $query: String, $namespace: String!) { |
| 73 | products(first: $first, after: $after, query: $query) { |
| 74 | edges { |
| 75 | node { |
| 76 | id |
| 77 | title |
| 78 | tags |
| 79 | options { name values } |
| 80 | descriptionHtml |
| 81 | metafields(first: 20, namespace: $namespace) { |
| 82 | edges { node { key value } } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | pageInfo { hasNextPage endCursor } |
| 87 | } |