/storefront-next:sfnext-scapifrom storefront-next
Extends SCAPI clients in Storefront Next projects: overrides built-in clients with typed custom attributes, adds custom APIs, and manages generated files via `b2c sfnext scapi` commands.
Ships in storefront-next. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The runtime (@salesforce/storefront-next-runtime/scapi) already ships typed clients for the standard shopper APIs (products, search, baskets, customers, orders, and so on). You do not "add" those. sfnext scapi add does one of two things on top:
shopperProducts) with a richer schema, typically your tenant's schema expanded with c_* custom attributes, so product.c_myAttr is typed.clients.loyalty).Which one you get is decided automatically from the client key. Deep dive: docs/README-SCAPI.md in your project.
Run as b2c sfnext scapi ..., or inside your project as pnpm sfnext scapi ... (the sfnext bin ships with the project). Add -d <dir> / --project-directory to target another directory.
| Command | What it does |
|---|---|
scapi available | Probes your tenant: for each of the built-in shopper APIs counts c_* attributes, lists tenant custom APIs, and prints the matching scapi add command. Needs OAuth. No filter flags. |
scapi add <apiFamily> <apiName> <apiVersion> | Pull mode: fetch the schema from the SCAPI Schemas API. Needs OAuth. |
scapi add --schema <file> --name <clientKey> | Local mode: use a YAML/JSON OpenAPI file. --name is required here. |
scapi list | Shows registered Overrides and Custom APIs (schema, base path, locale). |
scapi remove <clientKey> | Removes the registration and its generated files (one positional argument: the client key, for example loyalty). |
add flags: --name <key> (defaults to camelCase of the API name in pull mode), --base-path <path> (derived from the schema servers[].url if omitted), --supports-locale / --no-supports-locale (overrides inherit the built-in default), --expand-custom-properties (default on, pull mode only; include c_*, use --no-expand-custom-properties to skip). Re-running add regenerates; there is no --force and no --json. There is no install step after add.
Pull mode prerequisites: SCAPI short code (SFCC_SHORTCODE or --short-code), tenant id (SFCC_TENANT_ID or --tenant-id), and an Account Manager API client allowed the sfcc.scapi-schemas scope (SFCC_CLIENT_ID and SFCC_CLIENT_SECRET, or --client-id/--client-secret, or dw.json). The legacy names SFCC_OAUTH_CLIENT_ID / SFCC_OAUTH_CLIENT_SECRET are also accepted because the CLI resolves both. If the @salesforce/storefront-next-dev package is in the project, b2c uses that local version.
# Which built-in APIs have c_ attributes on my tenant? Which custom APIs exist?
b2c sfnext scapi available
# Type c_* attributes on products (override; pulls schema with custom properties)
b2c sfnext scapi add product shopper-products v1
# Register a custom API from the tenant, or from a local file
b2c sfnext scapi add custom loyalty v1
b2c sfnext scapi add --schema ./loyalty-api.yaml --name loyalty --base-path /custom/loyalty/v1
b2c sfnext scapi list
b2c sfnext scapi remove loyalty
For a schema-only look without touching the project use b2c scapi schemas get/list (see b2c-cli:b2c-scapi-schemas; both need --tenant-id).
src/scapi/
index.ts barrel (generated), the only SCAPI import surface for app code
custom-clients.ts registry of overrides and custom clients (generated)
schemas/ <name>-<ver>.yaml and .meta.json
generated/ <name>-<ver>.ts, .operations.ts, (.namespace.ts for overrides)
Never hand-edit these; rerun sfnext scapi add. Registry entries carry key, basePath, ops, locale, orgPrefix. Custom clients use orgPrefix: true (base /custom/<name>/v1/organizations/{orgId}); the shipped sfnextNotify entry is a working example.
Import types and clients from the barrel, not from the runtime package:
import { ApiError, type ShopperProducts } from '@/scapi'; // picks up overrides
// import { ShopperProducts } from '@salesforce/storefront-next-runtime/scapi'; // bypasses overrides, lint warns
Only src/scapi/** and src/lib/api-clients.server.ts may import the runtime path directly.
import { createApiClients } from '@/lib/api-clients.server';
export async function loader({ context }: LoaderFunctionArgs) {
const clients = createApiClients(context);
const { data: product } = await clients.shopperProducts.getProduct({
params: { path: { id: 'my-product-id' } },
});
const { data: rewards } = await clients.loyalty.getLoyaltyRewards(); // custom client
return { product, rewardTier: product?.c_loyaltyTier, rewards };
}
{ data } and throw ApiError on failure (wrap in NormalizedApiError from @/lib/api/normalized-api-error when you need a message/status).createApiClients automatically injects organizationId, siteId and (when the client supports it) locale. Do not pass siteId yourself.storefront-next:sfnext-authentication); do not read tokens to call SCAPI manually. Get the shopper via getAuth(context) only when you need customerId.src/lib/api/*.server.ts (search, products, basket, wishlist, order) for standard APIs, and put your own custom-API calls in a new src/lib/api/<thing>.server.ts.useScapiFetcher(client, method, options) goes through /resource/api/client/..., which only allows a short allow-list of operations (src/lib/scapi/resource-policy.ts), and siteId/locale/organizationId are server-owned. A new custom operation is not callable from the browser until you add it there; prefer a route loader/action. The 'helpers' overload is deprecated. See docs/README-PERFORMANCE.md and docs/README-REVALIDATION.md for fetcher lifecycle rules.rest-apis/<api-name>/ with api.json, schema.yaml, script) using b2c:b2c-custom-api-development. api.json maps endpoint to schema and implementation; auth is declared in schema.yaml (ShopperToken for storefront calls, with a c_ scope under security:). The shipped cartridges/app_storefrontnext_base/cartridge/rest-apis/sfnext-notify/ is a complete example.b2c code deploy <cartridge> --reload (reload toggles activation so endpoints re-register; see b2c-cli:b2c-code).b2c scapi custom status --tenant-id <id> (filter with --status not_registered). Use b2c-cli:b2c-scapi-custom for 404s and errorReason.b2c-cli:b2c-slas). The shopper token must carry it, otherwise calls get 401/403.b2c sfnext scapi add custom <api-name> v1 (or --schema with a local copy).import type request/response types from @/scapi.Storefront Next can add personalized=none to eligible GET requests through one central policy. Overrides and custom clients are left unclassified until you review and approve their exact transports in the policy module. Do not loosen it to () => true. See docs/README-SCAPI-NON-PERSONALIZED-RESPONSES.md before approving a client.
scapi add shopper-search ... to be needed: standard clients already exist.@salesforce/storefront-next-runtime/scapi and wondering why c_* is untyped.--reload after deploy, so the endpoint stays unregistered (404).siteId or locale in params.query: server-owned, stripped on the resource route and injected elsewhere.shopperProducts, shopperBasketsV2, ...) or you create an unrelated custom client.Worked example of a shipped custom API: references/WORKED-EXAMPLE.md.
b2c:b2c-custom-api-development - author the cartridge, api.json, schema.yaml, scriptsb2c-cli:b2c-scapi-custom - registration status and debugging 404sb2c-cli:b2c-scapi-schemas - browse SCAPI schemasb2c-cli:b2c-slas - add custom scopes to the SLAS clientstorefront-next:sfnext-data-fetching - loaders, actions, cachingstorefront-next:sfnext-authentication - getAuth, sessionsstorefront-next:sfnext-revalidation - fetcher revalidation rulesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
scapi, storefront-next, b2c-commerce, custom-api, client-override
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin storefront-next25 skills in this plugin
/sfnext-accessibilityBuild and fix accessible UI in a Storefront Next storefront (WCAG 2.1 AA): jsx-a11y lint findings, missing accessible names and labels, form error association, dialog focus management, aria-live status messages, keyboard behavior, color contrast, and verifying fixes with Storybook a11y/play() tests and the e2e axe scan with its baseline. Use for "accessibility", "a11y", "WCAG", "screen reader", "aria-label", "focus trap", "axe violation", pnpm lint:a11y, pnpm a11y, a11y-baseline.json, skip-a11y, STORYBOOK_A11Y_TEST_MODE, or an accessibility audit finding to fix. Do not use for general lint/typecheck gates (use `storefront-next:sfnext-quality-gates`), writing non-accessibility tests (use `storefront-next:sfnext-testing`), or color/token design (use `storefront-next:sfnext-theming`)./sfnext-analytics-consentStorefront Next analytics: engagement adapters (Einstein, Active Data, Data 360), adding a custom adapter, tracking consent gating, PageViewTracker, useAnalytics events, and first-touch attribution (dw_attribution). Use when configuring engagement.adapters in config.server.ts, writing an adapter with hasConsent, registering it in initializeEngagementAdapters, wiring the consent banner (trackingConsent, consentCategories, dw_dnt), firing trackViewProduct/trackCartItemAdd events, debugging why no analytics events are sent, or passing campaign attribution to orders. Do not use for general config loading or env vars (use `storefront-next:sfnext-configuration`), CSP/script allowlisting of third-party tags (use `storefront-next:sfnext-security`), or SEO meta/JSON-LD (use `storefront-next:sfnext-seo`)./sfnext-authenticationWork with Storefront Next's server-only authentication and session architecture (SLAS guest/registered tokens, httpOnly cookies, auth.server.ts middleware). Use for getAuth, useAuth, updateAuth, destroyAuth, protecting account routes, login/logout actions, guest-to-registered basket/wishlist merge, "session expired" redirects, 401 recovery loops, cc-at/cc-nx/usid/dwsid cookies, cookie names or expiry, passwordless login, social login, OTP email verification, passkeys, guest order lookup, or refresh-token lifetime settings. Do not use for Turnstile, CSP headers or cookie-domain config (use `storefront-next:sfnext-security`), calling SCAPI clients (use `storefront-next:sfnext-scapi`), or sharing sessions with SFRA (use `storefront-next:sfnext-hybrid-storefronts`)./sfnext-commerce-featuresCatalogue and router for optional Storefront Next commerce features: Shopper Context (qualifiers, source codes), Order Management returns/cancel/tracking (SOM/OMS), delivery estimates, feature stubs (@feature-stub), guest order lookup, the app_storefrontnext_base email cartridge, and the shipped extensions (bnpl, bopis, multiship, store-locator, ratings-reviews, customer-preferences, product-content, shipping-delivery, theme-switcher). For each: which flag, SLAS scope, Business Manager setting, cartridge, or extension registry entry it needs, and which in-project doc to read. Use when asked how to enable a feature, why a feature does not render, what prerequisites a feature has, or which stubs are mock data. Do not use for building a new extension (use `storefront-next:sfnext-extensions`), config loading (use `storefront-next:sfnext-configuration`), or SLAS login flows (use `storefront-next:sfnext-authentication`)./sfnext-componentsBuild and modify UI components in a Storefront Next storefront: page components with Suspense and use()/Await, createPage and withSuspense, Tailwind v4 token classes, shape tokens (rounded-ui, shadow-ui, border-ui), shadcn/ui primitives in src/components/ui (sync-shadcn), CVA variants, data-slot, DynamicImage, lazy-loaded overlays, and Storybook stories with snapshot tests. Use when creating or editing a component in src/components, adding a shadcn primitive, fixing styling that ignores the theme, writing a *.stories.tsx file, or running pnpm storybook:test. Do not use for re-branding colors, fonts, or logos (use `storefront-next:sfnext-theming`), route loaders (use `storefront-next:sfnext-data-fetching`), or Page Designer registration (use `storefront-next:sfnext-page-designer`)./sfnext-configurationConfigure a Storefront Next app: config.server.ts (defineConfig, metadata/runtime/app), AppConfig types in src/types/config.ts, PUBLIC__ environment variable overrides, getConfig(context) / useConfig(), extension config (app.extension, app.serverExtension), protected paths, server-only secrets, and multi-site settings (commerce.sites, url.prefix, seoRoutes, siteAliasMap, cookie domain). Use when editing config.server.ts, adding a config value, an env var is ignored or "not applied", `pnpm config:inspect` / `config:push-env`, "Ignoring environment variable" warnings, protected config path errors, setting up a second site or locale URLs, or going through the pre-launch config checklist. Do not use for creating a project or the npm script list (use `storefront-next:sfnext-project-setup`), pushing bundles or MRT env management (use `storefront-next:sfnext-deployment` / `b2c-cli:b2c-mrt`), or hybrid proxy and cookie-sharing with SFRA (use `storefront-next:sfnext-hybrid-storefronts`).Other plugins' skills for the same job