headless-ecommerce
Use when the user asks about headless commerce, Shopify Hydrogen, Storefront API, Oxygen, composable commerce or caching a commerce frontend. Produces a…
от j4flmao★ 47 звёзд на GitHub
Установить headless-ecommerce в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Headless E-commerce
Purpose
Build a custom storefront on top of a commerce backend (Shopify, commercetools, BigCommerce, Saleor, Medusa) while keeping catalog pages fast and cacheable and keeping personalized data (cart, customer) uncached and correct. Checkout usually stays on the platform's hosted checkout.
Agent Protocol
Trigger
"headless commerce", "hydrogen", "storefront api", "oxygen", "composable commerce", "headless shopify", "storefront caching".
Input Context
- Commerce platform and plan; whether hosted checkout is required.
- Frontend framework preference (Hydrogen on React Router, Next.js, Astro).
- Catalog size, update frequency, markets/currencies.
Output Artifact
Architecture + data-fetching/caching plan; route loader code on request.
Response Format
Platform: {backend} Frontend: {framework} Hosting: {Oxygen|Vercel|Cloudflare|...}
Data -> cache: {products: long, collections: short, cart/customer: none}
Checkout: {hosted|custom}
Risks: {list}
When Headless Is Worth It
| Situation | Recommendation |
|---|---|
| Standard store, theme customization enough | Stay on platform themes (Shopify Online Store 2.0) |
| Custom UX, content-heavy storytelling, multiple frontends (web/app/kiosk) | Headless |
| Small team without frontend ops capacity | Avoid — you now own SEO, performance, analytics, a11y |
| Many markets/brands on one catalog | Headless with shared component library |
Caching by Data Type
| Data | Cache | Why |
|---|---|---|
| Product details, collections, menus | CacheLong() / CDN with stale-while-revalidate |
Changes rarely; revalidate via webhook-driven purge if available |
| Inventory/price-sensitive listings | CacheShort() |
Minutes of staleness acceptable |
| Cart, customer account, buyer-specific pricing | CacheNone() |
Personalized; caching leaks data between users |
| Search results | Short or none | High cardinality |
Hydrogen Loader (React Router based)
Hydrogen queries use template strings tagged with #graphql (enables codegen and editor support). Cache strategy is passed per query.
import { CacheLong } from '@shopify/hydrogen';
import type { LoaderFunctionArgs } from 'react-router';
const PRODUCT_QUERY = `#graphql
query Product($handle: String!, $country: CountryCode, $language: LanguageCode)
@inContext(country: $country, language: $language) {
product(handle: $handle) {
id
title
descriptionHtml
selectedOrFirstAvailableVariant {
id
availableForSale
price { amount currencyCode }
}
}
}
` as const;
export async function loader({ params, context }: LoaderFunctionArgs) {
if (!params.handle) throw new Response('Missing product handle', { status: 400 });
const { product } = await context.storefront.query(PRODUCT_QUERY, {
variables: { handle: params.handle },
cache: CacheLong(),
});
if (!product) throw new Response(`Product not found: ${params.handle}`, { status: 404 });
return { product };
}
Older Hydrogen versions import loader types from @shopify/remix-oxygen; check the project's package.json before generating imports.
Cart
- Use the Storefront API Cart object (
cartCreate,cartLinesAdd,cartLinesUpdate); persist cart ID in a cookie. Hydrogen'screateCartHandlerwraps this. - Never cache cart reads; perform cart mutations in actions (POST), not loaders.
- Send the shopper to
cart.checkoutUrlfor hosted checkout.
Query Discipline
- Colocate GraphQL fragments with the components that render them; request only rendered fields.
- Paginate with
first/aftercursors; avoidfirst: 250everywhere. - Storefront API rate limits are generous but not infinite — cache at the edge and avoid N+1 per product card (fetch lists in one query).
- Use
@inContext(country, language)for market-specific pricing/translations.
Deployment
- Hydrogen deploys to Oxygen (Shopify's hosting) or any Workers-compatible/Node host.
- Set
Cache-Controlheaders deliberately on documents; personalized routesprivate, no-store. - Preserve SEO: canonical URLs,
hreflangfor markets, structured data (Product,Offer), sitemap generation.
Anti-Patterns
| Anti-pattern | Consequence |
|---|---|
| Caching responses that include cart/customer data | Data leak across users |
| Client-side fetching of all catalog data | Poor LCP and SEO |
| Rebuilding the whole site on every price change (pure SSG) | Stale prices; use SSR + cache or ISR-style revalidation |
| Rebuilding checkout from scratch | Loses platform fraud, tax, payments compliance |
| Exposing private Admin API tokens in the frontend | Store compromise; only public Storefront tokens client-side |
Checklist
- Cache strategy defined for every query
- No personalized data in cached responses
- Product/collection 404s handled
- Market/locale context passed to queries
- Structured data + can
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл headless-ecommerce?
Use when the user asks about headless commerce, Shopify Hydrogen, Storefront API, Oxygen, composable commerce or caching a commerce frontend. Produces a headless storefront design: data fetching, cache per data type, cart handling and deployment. Not for checkout and order backends (use ecommerce-checkout-cart) or payments (use ecommerce-payment-processing).
Как установить скилл headless-ecommerce?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл headless-ecommerce запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…