Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

hydrogen-cart-metafields

Skill by Shopify

Guides developers on reading and writing cart metafields with @shopify/hydrogen. It is for teams storing custom cart data such as delivery instructions or gift preferences in a Hydrogen app.

  • Score 87
  • 2.2k stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install hydrogen-cart-metafields

Built from the published package, never by AI.

git clone --depth 1 https://github.com/Shopify/hydrogen /tmp/hydrogen && mkdir -p ~/.claude/skills && cp -r /tmp/hydrogen/packages/hydrogen/skills/hydrogen-cart-metafields ~/.claude/skills/hydrogen-cart-metafields

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install hydrogen-cart-metafields in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This skill is a behavioral guide for reading and writing cart metafields with @shopify/hydrogen. Cart metafields store custom data on the cart, such as delivery instructions or a gift preference. The guide says they are server-only and are not supported by the Storefront cart ajax API, so they do not flow through Hydrogen's optimistic cart store.

The guide recommends three pieces: a custom CartFragment to read metafields, an app-owned POST route that calls cartMetafieldsSet or cartMetafieldDelete and returns only userErrors, and a refresh() call after a successful write. It is aimed at developers adding, modifying, or reviewing cart metafield reads or writes in a Hydrogen app. It also covers copying cart metafields to the order, which requires a store metafield definition with the cart-to-order copyable capability. The guide describes itself as framework agnostic.

Written from the project's SKILL.md and checked against it.

What it can do

  • Read cart metafieldsAdds a custom CartFragment so selected metafields appear in cart state.
  • App-owned write routeDescribes a custom POST route that calls cartMetafieldsSet and returns only userErrors.
  • Single-key deleteDescribes deleting one metafield per call with cartMetafieldDelete.
  • Re-sync after writeCalls refresh() after a successful write to reconcile the CartFragment fields.
  • Copy to orderExplains the cart-to-order copyable capability needed for copying metafields at checkout.
  • Review rulesLists rules such as server-side ownerId injection and validating the request body.

What you need

  • @shopify/hydrogen
  • A Hydrogen app with cart server handlers and custom route registration
  • Storefront API client access in the route handler
  • Store metafield definitions with the cart-to-order copyable capability, if copying to orders

Try asking

  • Add a delivery instructions cart metafield with a POST route and refresh.
  • Review my cart metafield write route for ownerId and validation issues.
  • Explain how to copy a cart metafield onto the order at checkout.

Good to know

  • Cart metafields are server-only and do not go through Standard Actions or the optimistic cart store.
  • Metafields cannot be added to the core cart action model.
  • The write route rejects requests when no cart cookie exists and does not create carts.
  • Each delete call removes one metafield key.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: packages/hydrogen/skills/hydrogen-cart-metafields/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

  • SKILL.md6 KB

Alternatives to hydrogen-cart-metafields

All alternatives →
openclaw-github-repo-commandersickn33
94

Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.

AAA Skill 50k
gradiogradio-app
94

Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.

AAA Skill 44k
hig-components-menussickn33
94

Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.

AAA Skill 50k
fastapi-templateswshobson
94

Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.

AAA Skill 43k
appfunctionsandroid
94

Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.

AAA Skill 11k
agent-qa-authoringsickn33
94

Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.

AAA Skill 50k

Compare with openclaw-github-repo-commander, gradio or hig-components-menus

hydrogen-cart-metafields: common questions

Do cart metafields work with the Hydrogen optimistic cart store?

No. The source says the Storefront cart ajax API does not support cart metafields, so they never flow through Hydrogen's optimistic cart store.

Why does the write route not return the refreshed cart?

The source says the mutation route returns only userErrors so a failed re-sync cannot be reported as a failed save. Re-syncing is a separate refresh() call.

What is needed for a cart metafield to reach the order?

The store must define the metafield with the cart-to-order copyable capability. Without the definition, the cart write succeeds but nothing is copied to the order.

How do I install hydrogen-cart-metafields?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is hydrogen-cart-metafields free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is hydrogen-cart-metafields safe to use?

It scores 87 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to hydrogen-cart-metafields?

Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.

hydrogen-cart-metafields Install

Add to stack

Loading.