agentleFS
remix-runremix-run/remix-store/.agents/skills/hydrogen-money/SKILL.md

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

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
  1. Very specific:

    Use Hydrogen's formatMoney() for Storefront API MoneyV2 values.

    line 15
  2. Distinctive:

    Do not multiply quantity by unit price in the browser.

    line 30
  3. Very specific:

    Use the active market locale when the app has markets.

    line 31
  4. Very specific:

    Prefer a small app wrapper such as formatPrice() so locale and display options are consistent.

    line 32
  5. Very specific:

    Use withoutTrailingZeros only for presentation choices, never by editing amount strings manually.

    line 33

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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-US in market-aware storefronts.
  • Prefer a small app wrapper such as formatPrice() so locale and display options are consistent.
  • Use withoutTrailingZeros only for presentation choices, never by editing amount strings manually.
  • For price ranges, pass a readonly array of MoneyV2 values to formatMoney([...]).

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 as toString().
  • 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

  • "$" + amount
  • Number(amount).toFixed(2)
  • line.quantity * Number(line.merchandise.price.amount)
  • Showing cart totals at full opacity while a related cart mutation is pending.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.