dist/codex/salesforce-commerce/skills/sf-b2c-cartridges/SKILL.md
Build B2C Commerce cartridges — cartridge directory structure (controllers/, models/, scripts/, templates/, static/), cartridge stacking, naming conventions (app_custom_*, plugin_*, int_*), cartridge path configuration, and certification requirements. Use when creating or modifying SFCC cartridges.
npx skillsauth add orcaqubits/agentic-commerce-claude-plugins sf-b2c-cartridgesInstall 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.
Build B2C Commerce cartridges following Salesforce Commerce Cloud architecture patterns.
Fetch live documentation FIRST:
Web-search for:
Web-fetch official sources:
Verify before coding:
app_custom_mysite/
├── cartridge/
│ ├── controllers/ # Route handlers
│ ├── models/ # Business logic
│ ├── scripts/ # Helpers, middleware
│ ├── templates/ # ISML + i18n resources
│ └── static/ # Compiled CSS/JS/images
└── cartridge.properties
| Directory | Contents | Notes |
|-----------|----------|-------|
| controllers/ | Server-side JS route handlers | Each file exports route actions (e.g., Product-Show) |
| models/ | Data models and business logic | Keep controllers thin; move logic here |
| scripts/ | Utility helpers, middleware, services | Subdirs: helpers/, middleware/, services/ |
| templates/default/ | ISML templates per locale | default/ is the fallback locale |
| templates/resources/ | i18n .properties files | Resource bundles for Resource.msg() |
| forms/default/ | XML form definitions | Server-side validation rules |
| static/default/ | Compiled CSS, JS, images | Built from client/default/ source |
| client/default/ | Source SCSS and JS | Input for webpack/sgmf-scripts build |
| experience/components/ | Page Designer components | Visual merchandising building blocks |
| Prefix | Purpose | Example |
|--------|---------|---------|
| app_custom_* | Site-specific customizations | app_custom_mysite |
| plugin_* | Reusable feature modules | plugin_wishlists |
| int_* | Third-party integrations | int_paypal, int_stripe |
| bm_* | Business Manager extensions | bm_custom_admin |
| app_storefront_base | Base SFRA cartridge | Core framework (do not modify) |
| modules/ | Shared modules (non-cartridge) | Utility libraries consumed by cartridges |
The cartridge path defines file resolution order (configured in Business Manager > Site Settings):
app_custom_mysite:plugin_wishlists:int_paypal:app_storefront_base
Resolution: Left to right. When SFCC resolves a file (e.g., controllers/Product.js), it searches each cartridge in path order and uses the first match. This enables non-destructive customization -- overlay specific files without modifying base cartridges.
Overlay constraints:
cartridge/ to overridemodule.superModule| Type | Contains | When to Use | |------|----------|-------------| | Storefront | Controllers, templates, static assets | Customer-facing site logic | | Integration | Service definitions, API clients | Third-party system connections | | Plugin | Self-contained feature | Reusable cross-site features | | Business Manager | BM extensions, custom modules | Admin panel customizations |
Controllers can extend base behavior using module.superModule:
// Pattern: extend base controller
// Fetch live docs for server.extend() API
var server = require('server');
server.extend(module.superModule);
// Add or override route actions here
This avoids duplicating the entire base controller when you only need to modify one action.
Required fields: cartridge ID and multi-language flag. Optional: version and compatibility version. Fetch live docs for the exact property key format (demandware.cartridges.<id>.*) before creating this file.
SFRA uses sgmf-scripts for compiling client-side SCSS and JS. Source files live in cartridge/client/default/ and compile to cartridge/static/default/. Webpack configuration maps entry points for JS bundles and SCSS compilation.
| Tool | Purpose |
|------|---------|
| sgmf-scripts --compile js | Compile client-side JavaScript |
| sgmf-scripts --compile css | Compile SCSS to CSS |
| sgmf-scripts --watch | Watch mode for development |
| sfcc-ci | CLI for code upload and deployment automation |
| Category | Key Requirements | |----------|-----------------| | Technical | Compatible with latest SFRA; no hardcoded credentials; passes code profiler | | Documentation | Installation guide, BM configuration steps, troubleshooting guide | | Security | Input validation, CSRF protection, secure credential storage | | Testing | Unit tests, integration tests, performance benchmarks, multi-site compatibility |
Pattern: upload cartridge code to a code version on the sandbox/instance, then activate that version in Business Manager. Use WebDAV upload or the sfcc-ci CLI tool for automation.
| Step | Action |
|------|--------|
| 1 | Upload code to a named code version via WebDAV or sfcc-ci |
| 2 | Set the active code version in BM > Administration > Code Deployment |
| 3 | Update cartridge path in BM > Site Settings if new cartridges were added |
| 4 | Clear caches and verify storefront behavior |
# Pattern: scaffold a new cartridge
# Fetch live docs for sgmf-scripts CLI options
mkdir -p app_custom_mysite/cartridge/{controllers,models,scripts,templates/default}
app_custom_*; reusable features in plugin_*.app_storefront_base directory layout for clean overlays.module.superModule to extend controllers rather than copying entire files.scripts/helpers/; keep controllers thin.<isinclude> components.cartridge.properties version on each release.sfcc-ci for CI/CD pipeline integration.Fetch the SFRA GitHub repo, B2C Commerce cartridge development docs, and LINK certification guidelines for exact directory conventions, build tool APIs, and deployment procedures 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.