dist/codex/salesforce-commerce/skills/sf-b2c-sfra/SKILL.md
Build B2C Commerce storefronts with SFRA (Storefront Reference Architecture) — cartridge overlay system, MVC pattern, app_storefront_base, module.superModule inheritance, middleware chain, and site-specific customizations. Use when developing SFRA-based storefronts.
npx skillsauth add orcaqubits/agentic-commerce-claude-plugins sf-b2c-sfraInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fetch live docs:
github.com/SalesforceCommerceCloud/storefront-reference-architecture for SFRA sourcesite:developer.salesforce.com SFRA architecture MVC for MVC patternssite:developer.salesforce.com SFRA cartridge overlay for overlay best practicessite:developer.salesforce.com module.superModule for extension patternssite:developer.salesforce.com SFRA getting started for latest docsSFRA (Storefront Reference Architecture) is the reference implementation for B2C Commerce storefronts:
| Principle | Rule |
|-----------|------|
| Overlay | Never modify app_storefront_base -- create custom cartridges that layer on top |
| Extend | Use module.superModule to inherit and augment, not replace |
| Hooks | Use commerce hooks for order, payment, and shipping customization |
| Services | Use the Service Framework for external integrations (payment gateways, ERP) |
The cartridge path (configured in Business Manager) resolves files left-to-right. The leftmost cartridge wins.
Example path: app_custom:app_storefront_base
controllers/Product.js checks app_custom first, falls back to app_storefront_baseapp_custom/cartridge/
├── controllers/ # Route handlers
├── models/ # Data models
├── scripts/ # Helpers, services
├── templates/ # ISML templates
├── experience/ # Page Designer
└── client/default/ # JS + SCSS source (Webpack)
module.superModule resolves to the next cartridge in the path that provides the same module. This is how you extend without duplicating:
var base = module.superModule; server.extend(base); then use append/prepend/replacebase.call(this, apiProduct, options), then add properties| Layer | Location | Role |
|-------|----------|------|
| Controller | controllers/*.js | Route handling via server module |
| Model | models/**/*.js | Transform API data to view-friendly objects |
| View | templates/default/**/*.isml | ISML templates for HTML rendering |
| Client JS | client/default/js/ | Browser-side behavior (Webpack bundled) |
| SCSS | client/default/scss/ | Styles (compiled to CSS) |
| Approach | When | Trade-off |
|----------|------|-----------|
| server.extend(base) + append | Adding data, logging, analytics | Keeps base logic; auto-receives base updates |
| server.replace('Route', fn) | Fundamentally different logic | You own the entire implementation; no base updates |
Prefer extend + append in nearly all cases. Only replace when the base logic is wrong for your use case.
SFRA uses Webpack to build client assets from client/default/js/ and client/default/scss/. Output goes to cartridge/static/default/. Client JS can extend base modules:
// Pattern: Extend base client module
var base = require('base/product/detail');
// Fetch live docs for base module API
Site.getCurrent().getCustomPreferenceValue('prefName') -- store-level configurationCustomObjectMgr.getCustomObject('Type', 'key') -- custom data structuresdw.* APIapp_storefront_baseapp_custom_[sitename] or int_custom_[feature]module.superModule to extend -- avoid code duplicationserver.extend() to inherit base routesnext() in middleware chain<isinclude> for reusable componentsResource.msg('key', 'bundle', null)Transaction.wrap() for all database writesCacheMgrFetch the SFRA GitHub repository, developer documentation, and module.superModule guide for exact patterns, API references, and best practices before implementing.
development
Build with Spree's headless Next.js storefront — the official `spree/storefront` repo (Next.js 16 App Router with Server Actions and Turbopack, React 19 Server Components, Tailwind CSS 4, TypeScript 5, `@spree/sdk`, Sentry), server-only auth (httpOnly JWT cookies + publishable key), MeiliSearch faceted catalog, one-page checkout with Apple/Google Pay/Klarna/Affirm/SEPA, multi-region market routing, GA4 + JSON-LD SEO, and Vercel/Docker deployment. Use when forking or customizing the storefront, or evaluating headless adoption.
tools
Build Spree extensions as Rails engines — gem scaffolding, `bin/rails g spree:extension`, mounting routes/migrations/assets, the modern `prepend` decorator pattern (`*_decorator.rb` with `self.prepended(base)`), generators (`spree:model_decorator`, `spree:controller_decorator`), the four customization surfaces in preference order (Events > Webhooks > Dependencies > Decorators), Spree::Dependencies for swapping service objects, gem release/versioning, and the deprecated Deface engine. Use when building a reusable Spree extension or adding non-trivial customization to an app.
development
Build with Spree's event bus and Webhooks 2.0 — `Spree::Events` publication, `Spree::Subscriber` DSL with `subscribes_to` and `on`, wildcard matching, lifecycle events (`{model}.created/.updated/.deleted` via `publishes_lifecycle_events`), the canonical event catalog (order.*, payment.*, shipment.*, product.*), Webhooks 2.0 endpoints, HMAC-SHA256 signing (`X-Spree-Webhook-Signature`), exponential-backoff retries, and Sidekiq job orchestration. Use when wiring event-driven business logic, building webhook consumers, or replacing ActiveSupport callback chains.
tools
Cross-cutting Spree development patterns — the customization preference hierarchy (Events > Webhooks > Dependencies > Decorators), `Spree::Dependencies` service-object swapping, the `_decorator.rb` + `prepend` + `self.prepended` idiom, idempotent subscribers and webhook receivers, multi-store scoping discipline, prefixed IDs, calculator polymorphism (shipping/promotion/tax share the base), service-object composition with `dry-monads` or simple results, why to avoid `class_eval` reopening and Deface, and Spree-on-Rails idioms (Hotwire/Turbo Stimulus, ActiveStorage, Action Cable, Sidekiq). Use when designing the architecture of a Spree extension or solving cross-cutting concerns.