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.
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-metafieldsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install hydrogen-cart-metafields in Claude Code
git clone --depth 1 https://github.com/Shopify/hydrogen /tmp/hydrogen && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/hydrogen/packages/hydrogen/skills/hydrogen-cart-metafields ~/.gemini/antigravity-cli/skills/hydrogen-cart-metafieldsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install hydrogen-cart-metafields in Antigravity CLI
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
ANo 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 →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.
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.
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.
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.
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.
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.
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.
