hydrogen-money
Skill218 starsChanged 4 days agoMITView on GitHub
Guide for formatting Shopify money values in Hydrogen storefronts. Use when rendering product prices, compare-at prices, cart totals, collection price ranges, Shop Pay prices, or any MoneyV2 amount/currencyCode values.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- Shopify/hydrogenedited, first seen Oct 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Shopify/hydrogen★ 2.2k99% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- hydrogen-analyticsSkill
- hydrogen-cart-drawerSkill
- hydrogen-cart-metafieldsSkill
- hydrogen-cart-uiSkill
- hydrogen-collection-browserSkill
- hydrogen-customer-accountSkill
- hydrogen-imageSkill
- hydrogen-local-httpsSkill
- hydrogen-marketsSkill
- hydrogen-oxygenSkill
- hydrogen-predictive-searchSkill
- hydrogen-request-handlersSkill
- hydrogen-robots-txtSkill
- hydrogen-routingSkill
- hydrogen-setupSkill
- hydrogen-shop-paySkill
- hydrogen-smoke-testSkill
- hydrogen-storefront-clientSkill
- hydrogen-variant-formSkill
- migrate-to-hydrogen-2026-10Skill
- remix-storeSkill
- testing-practicesSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Use Hydrogen's formatMoney() for Storefront API MoneyV2 values.
- Distinctive: line 30
Do not multiply quantity by unit price in the browser.
- Very specific: line 31
Use the active market locale when the app has markets.
- Very specific: line 32
Prefer a small app wrapper such as formatPrice() so locale and display options are consistent.
- Very specific: line 33
Use withoutTrailingZeros only for presentation choices, never by editing amount strings manually.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Money Formatting
Use Hydrogen's formatMoney() for Storefront API MoneyV2 values. Never build money strings by concatenating currency symbols or computing totals client-side.
import { formatMoney, type MoneyV2 } from "@shopify/hydrogen";
// `locale` should come from the resolved market. Default only in
// single-market storefronts; market-aware stores must pass the active locale.
export function formatPrice(money: MoneyV2, locale = "en-US"): string {
return formatMoney(money, { locale }).toString();
}Rules
- Display server-provided money fields:
variant.price,variant.compareAtPrice,product.priceRange.minVariantPrice,line.cost.totalAmount,cart.cost.subtotalAmount, etc. - Do not multiply quantity by unit price in the browser. Cart totals are affected by discounts, duties, tax, rounding, and selling plans.
- Use the active market locale when the app has markets. Do not hardcode
en-USin market-aware storefronts. - Prefer a small app wrapper such as
formatPrice()so locale and display options are consistent. - Use
withoutTrailingZerosonly for presentation choices, never by editing amount strings manually. - For price ranges, pass a readonly array of
MoneyV2values toformatMoney([...]).
Structured Output
formatMoney() returns an object that stringifies to the localized price. Use
toString() or template literals for normal UI. Call formatMoney() directly
or add an object-returning wrapper when the design needs split markup:
localizedString- full display string, same astoString().amount- localized numeric portion without currency.numericAmount- parsed number; do not use for cart totals or currency math.currencySymbol,currencyNarrowSymbol,currencyName- currency display variants.parts-Intl.NumberFormatPart[]for custom markup.withoutTrailingZeros,withoutTrailingZerosAndCurrency- presentation-only variants.
For ranges, formatMoney([min, max], options) returns an object that stringifies
to the localized range and exposes min, max, and currencyCode. Range
inputs must share one currency.
Examples
<p>{formatPrice(selectedVariant?.price ?? product.priceRange.minVariantPrice, locale)}</p>const range = formatMoney(
[product.priceRange.minVariantPrice, product.priceRange.maxVariantPrice],
{ locale, withoutTrailingZeros: true },
).toString();Anti-Patterns
"$" + amountNumber(amount).toFixed(2)line.quantity * Number(line.merchandise.price.amount)- Showing cart totals at full opacity while a related cart mutation is pending.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

