/b2c-cli:b2c-configfrom b2c-cli
Configures B2C CLI/MCP authentication, instances, and project defaults. Helps troubleshoot missing credentials, wrong targets, and configuration precedence.
Ships in b2c-cli. 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.
For routine inspection, call config_inspect or b2c setup inspect directly;
no skill read is required. Keep secrets redacted; manually reading dw.json is usually unnecessary. Read the relevant section
here when configuring sources or diagnosing unexpected/missing values.
| Task | CLI | MCP | Preference / difference | Fallback |
|---|---|---|---|---|
| Inspect resolved configuration | b2c setup inspect | config_inspect | Either; same resolver, redacted by default. MCP accepts per-call project/instance overrides. | Inspect source files only for edits or unresolved issues. |
| Change configuration or authenticate | b2c setup set, b2c setup, b2c auth | No configuration-writing equivalent | CLI; inspect command help for the requested operation. | Edit the intended configuration source. |
If b2c is unavailable, use npx @salesforce/b2c-cli.
The CLI automatically detects instance hostname, credentials, tenant ID, MRT API key, and other settings from multiple sources. You usually do not need to pass --server, --client-id, --client-secret, --username, --password, --tenant-id, --short-code, or --api-key as flags — the CLI picks them up from the environment or config files.
Sources, in resolution order (highest priority first):
SFCC_*, MRT_*) in the project's .env (or the file selected with --dotenv-file / SFCC_DOTENV_FILE) come next.dw.json — selected by --config / SFCC_CONFIG, the env file, the project-local file, or the shared global dw.json. Supports a single instance or a configs[] array with active: true / -i <name> selection.dw.json entry (see below).~/.mobify — home-directory file (MRT API key only).package.json under the b2c key — non-sensitive project defaults (e.g., shortCode, clientId, mrtProject). Sensitive fields like clientSecret/password are intentionally not allowed here.Hostname protection applies between sources: if an env file's SFCC_SERVER differs from the selected dw.json entry's hostname, that whole entry is skipped (HOSTNAME_MISMATCH warning). If no source sets a tenant ID and the hostname is a sandbox hostname (abcd-001.dx.commercecloud.salesforce.com), the tenant ID is derived (abcd_001); a conflicting configured tenant ID produces a TENANT_MISMATCH warning. Conversely, if no source sets a hostname and the tenant ID is a sandbox tenant (abcd_001, including a Storefront Next f_ecom_abcd_001 organization ID), the hostname is derived (abcd-001.dx.commercecloud.salesforce.com).
Use --dotenv-file .env.staging (or SFCC_DOTENV_FILE) to use another env file instead of .env; it replaces .env rather than layering on it. --dotenv-file "" uses no env file, and --config "" uses no dw.json.
For unexpected values, inspect resolved configuration and sources with config_inspect or b2c setup inspect.
The resolver accepts these Storefront Next variables as fallbacks, so a project
can reuse its existing B2C Commerce and SLAS configuration. The PUBLIC__app__*
and COMMERCE_API_SLAS_SECRET variables rank below dw.json: with -i stg,
stg's own tenant, short code, site, and SLAS client are kept and these only fill gaps.
| Storefront Next variable | Resolved field | Default toolkit variable |
|---|---|---|
PUBLIC__app__commerce__api__clientId | slasClientId | SFCC_SLAS_CLIENT_ID |
PUBLIC__app__commerce__api__organizationId | tenantId | SFCC_TENANT_ID |
PUBLIC__app__commerce__api__shortCode | shortCode | SFCC_SHORTCODE |
COMMERCE_API_SLAS_SECRET | slasClientSecret | SFCC_SLAS_CLIENT_SECRET |
PUBLIC__app__defaultSiteId | siteId | SFCC_SITE_ID |
MRT_PROJECT | mrtProject | MRT_PROJECT |
MRT_TARGET | mrtEnvironment | MRT_ENVIRONMENT |
Explicit flags, default toolkit variables, and the selected dw.json entry win over these fallbacks. MRT_PROJECT and MRT_TARGET are toolkit variables and keep toolkit priority.
Use a shared fallback when the same dw.json-format file should work across the CLI, MCP server, and B2C DX VS Code extension:
b2c setup default-config set /path/to/dw.json
b2c setup default-config get
b2c setup default-config unset
The configuration-file selection order is: explicit --config; process SFCC_CONFIG; env file SFCC_CONFIG; project-local dw.json; global default. The global file never replaces an explicit or project-local choice. An explicit path (--config / SFCC_CONFIG) is used on its own, without the global file; setup inspect notes when the global default is skipped.
A discovered project dw.json and the global dw.json form one instance catalog. -i <name> searches the primary file first and then the global file, with same-name primary entries shadowing global entries. Each selected instance is complete—its fields are not merged with a matching entry in the other file. Instance list/remove/set-active operate across both files; create writes to the primary file when present and otherwise to the global dw.json.
Without -i, an active primary instance wins. A root-level primary configuration with no active field is its implicit default; set its root to active: false to opt it out and allow an active/default global instance to be selected. b2c setup inspect shows both files in its Sources section and marks the selected file.
For MCP installation or tool selection, use mcp/b2c-mcp-server when
available or the MCP configuration guide (b2c docs read mcp-configuration).
These are client launch settings; config_inspect reports B2C values and sources,
not enabled toolsets or client filters. Project .env does not select MCP tools.
Local MCP project tools accept projectDirectory. Tools that resolve B2C/MRT configuration accept the same flat projectDirectory, configPath, and instanceName arguments. This override is especially important for plugin installs, where the MCP process working directory may be the plugin directory rather than the open project. For each configuration-aware call, the MCP server:
.env from projectDirectory.dw.json-format configuration file in this order: per-call configPath; startup --config / SFCC_CONFIG; project .env SFCC_CONFIG; ${projectDirectory}/dw.json; shared global default. An explicit path is used without the shared global default. Storefront Next variables from the project .env only fill gaps below dw.json.configPath and project .env SFCC_CONFIG values from projectDirectory.instanceName, when supplied, from the primary file first and then the shared global dw.json, without changing either file.package.json.cartridgeDirectory, buildDirectory, and outputDirectory from the same root when relative.Project .env values are scoped to that MCP call so one project's environment does not leak into another.
Each project/config-aware result includes an authoritative, compact resolution block. It reports the selected project, configuration file, instance, hostname, and specialized directories without relying on paths embedded in tool descriptions. Session and watch start calls retain it, and their list tools expose it for later follow-up calls. The MCP config_inspect tool additionally returns the full source graph and uses the same SDK resolver and registered CLI plugin configuration sources as b2c setup inspect. Use projectDirectory, configPath, and/or instanceName to compare the intended project, file, and instance.
dw.json Key CasingField names in dw.json accept both camelCase and kebab-case — they're equivalent. For example:
| Either form works |
|---|
clientId ≡ client-id |
clientSecret ≡ client-secret |
codeVersion ≡ code-version |
tenantId ≡ tenant-id |
shortCode ≡ short-code ≡ scapi-shortcode |
webdavHostname ≡ webdav-hostname ≡ webdav-server ≡ secureHostname |
certificatePassphrase ≡ certificate-passphrase ≡ passphrase |
Legacy aliases like server (for hostname) are also still supported. If a value isn't being picked up, casing is rarely the cause — check spelling, then run b2c setup inspect to see what the CLI actually parsed.
A JSON Schema for dw.json is published at https://salesforcecommercecloud.github.io/b2c-developer-tooling/schemas/dw.schema.json (the B2C DX VS Code extension applies it automatically). Add it as "$schema" in a dw.json for editor validation and completion.
For the full field reference, see the Configuration guide (b2c docs read guide-configuration).
Most commands that interact with a B2C Commerce instance require authentication. The CLI supports several methods:
clientId and clientSecret in dw.json or environment variables. This is the default for automated/CI use. No API client yet? The user can create one with their own sign-in (b2c-cli:b2c-am, Create Client); confirm every detail with them first.--user-auth on any OAuth-enabled command to sign in with your Account Manager account in the browser.username and password for WebDAV operations.b2c auth login to stay signed in; later commands reuse the saved session when no other client is configured. Client credentials need no session (each command gets a token); b2c auth client exists for sfcc-ci client:auth compatibility.webdav commands need only the hostname; the user signs in with their Account Manager account in the browser when asked.abcd-001.dx.commercecloud.salesforce.com on a sandbox), never a storefront or Default Domain host (*.my.commercecloud.salesforce.com). Storefront hosts sit behind eCDN rate limits and firewall rules meant for shoppers, and on sandboxes the .my host serves only the storefront. If a user offers a storefront URL, ask for their Business Manager URL instead.b2c setup inspect shows how the instance authenticates; b2c auth status shows who is signed in.--user-auth FlagMany commands support --user-auth to sign in with your account instead of using client credentials. SCAPI Admin APIs don't support it yet (release 26.8): with --user-auth, commands that also support OCAPI use it, and --api-backend scapi fails with an error. It's useful when:
clientSecret configured# Sign in with your account
b2c sandbox list --user-auth
b2c am users list --user-auth
b2c auth token --user-auth
Coding agents can use --user-auth wherever a browser can be opened. Don't combine it with --auth-methods.
To sign in with the CLI's built-in client even when a client or access key is configured (for example, the configured client doesn't allow browser sign-in), use --default-client or SFCC_DEFAULT_CLIENT=true. It works for auth login, WebDAV, code upload, logs, sandbox, and Account Manager commands; OCAPI and SCAPI commands reject it. Don't combine it with --client-id, --client-secret, or --auth-methods.
Running behind a proxy: If localhost:8080 isn't reachable by the browser (e.g., running in a container or behind a reverse proxy), set SFCC_REDIRECT_URI to the proxy URL. The local OAuth server still listens on the default port (or SFCC_OAUTH_LOCAL_PORT), but the redirect URI sent to Account Manager will use your proxy URL. Add the proxy URL to the API client's redirect URLs in Account Manager.
B2C Commerce uses two related identifiers:
zzxy_prd or zzxy-prd)f_ecom_ prefix (e.g., f_ecom_zzxy_prd)The CLI automatically normalizes and translates between these formats. You can provide either form in configuration or flags — the CLI handles the conversion. It also extracts tenant IDs from hostnames (e.g., zzxy-prd.dx.commercecloud.salesforce.com resolves to zzxy_prd).
In dw.json or environment variables, use the tenantId config key. The CLI will add the f_ecom_ prefix when making SCAPI calls.
Use b2c setup inspect to view the resolved configuration and understand where each value comes from. Use b2c setup instance commands to manage named instance configurations.
Note:
b2c setup configworks as an alias forb2c setup inspect.
Use b2c setup inspect when you need to:
# Display resolved configuration (sensitive values masked by default)
b2c setup inspect
# View configuration for a specific instance from dw.json
b2c setup inspect -i staging
# View configuration with a specific config file
b2c setup inspect --config /path/to/dw.json
# Reveal secrets only when the user explicitly requests their values
b2c setup inspect --unmask
# Output as JSON for parsing in scripts
b2c setup inspect --json
# Pretty-print with jq
b2c setup inspect --json | jq '.config'
# Check which sources are loaded
b2c setup inspect --json | jq '.sources'
Use b2c setup set, get, and unset to change a single value. They pick the
file for you: the dw.json entry or project .env that already supplies the
value, otherwise the selected instance's dw.json entry. They refuse, without
writing, when the value comes from the shell environment, ~/.mobify, or
another read-only source, or when no instance is selected.
b2c setup set scapi-schemas=./scapi-schemas
b2c setup set code-version version2 -i staging
b2c setup set safety '{"level":"NO_DELETE"}' # non-string keys take JSON
b2c setup get code-version # value on stdout, source on stderr
b2c setup get client-secret # masked; --unmask only when asked
b2c setup unset code-version
Keys use dw.json names. Values are checked against the dw.json schema.
Use b2c setup ide to configure IDE tooling that consumes the resolved CLI configuration and to enable Script API IntelliSense.
# Vendor Script API TypeScript definitions + jsconfig.json (plain VS Code, WebStorm, etc.)
b2c setup ide vscode-types
# Also type obj.custom.* from the instance's custom attributes (needs sfcc.object-definitions scope)
b2c setup ide vscode-types --custom-attributes --force
# Print the TS Server plugin path for LSP-based editors (Neovim, Helix, Zed, ...)
b2c setup ide tsserver-plugin --json
The B2C DX VS Code extension needs no setup — it injects the same TypeScript Server plugin at runtime.
b2c setup openshell creates an NVIDIA OpenShell sandbox from the resolved configuration. Secrets stay on the OpenShell gateway, and the sandbox can reach only the B2C hosts in use, at the configured Safety Mode level (or NONE if unset); Safety Mode rules carry over. Requires the openshell CLI with a running gateway, and Docker.
# Sandbox for the active instance at the configured Safety Mode level
b2c setup openshell
# Read-only sandbox
b2c setup openshell --safety-level READ_ONLY
# Allow writes but not deletes; include the MCP server
b2c setup openshell --safety-level NO_DELETE --mcp
# Write the policy, profiles, Dockerfile, and setup.sh without running anything
b2c setup openshell --dry-run
# Run a command in the sandbox
openshell sandbox exec -n b2c-<instance> -- b2c code list
Re-run to apply a changed safety level, Safety Mode rules, or an edited .openshell/<sandbox>/policy.yaml (an edited policy is kept; --force regenerates it); use --recreate after changing secrets or configuration, or when the command warns that sandbox settings changed (recreating removes uploaded files and attached agent providers). Add hosts with --allow-host. Only client credentials work in the sandbox (no browser login). See the Agent Sandboxing guide (b2c docs read guide-agent-sandboxing).
# Show all instances from dw.json
b2c setup instance list
# Output as JSON
b2c setup instance list --json
# Interactive mode - prompts for all values
b2c setup instance create staging
# With hostname
b2c setup instance create staging --hostname staging.example.com
# Create and set as active
b2c setup instance create staging --hostname staging.example.com --active
# Optionally save SCAPI coordinates and use SCAPI-first active-version detection
b2c setup instance create staging --hostname staging.example.com \
--short-code kv7kzm78 --tenant-id zzxy_prd --api-backend auto
# Non-interactive mode (for scripts)
b2c setup instance create staging \
--hostname staging.example.com \
--username admin \
--password <access-key> \
--force
create writes dw.json in the current directory (or the --config / --project-directory target, or the global default when no local dw.json exists) and prints the path. Commands run from another directory won't see it unless they pass --config or --project-directory, or the file is registered with b2c setup default-config set <path>. create fails for an existing name; change an existing instance with b2c setup set <key> <value> --instance <name>.
shortCode and tenantId are optional. When present with stateless OAuth, setup tries SCAPI first to detect the active code version; otherwise auto uses OCAPI. If detection fails, interactive setup reports the reason and allows manual code-version entry.
# Set staging as the default instance
b2c setup instance set-active staging
# Now commands use staging by default
b2c code list # Uses staging
# Remove with confirmation prompt
b2c setup instance remove staging
# Remove without confirmation
b2c setup instance remove staging --force
The setup inspect command displays configuration organized by category:
SafetyFile identifies the global file listed in Sources; SafetyEnv identifies environment settings. Use --verbose for numbered rules in matching order with their sources, or --json for the complete effective safety object. Explicit confirmation rules still apply when level confirmation is disabled.Each value shows its source in brackets:
[DwJsonSource] — Value from the primary dw.json file[default] — Value from the shared default dw.json (shown as DwJsonSource (default) in the Sources table)[EnvSource] — Value from an SFCC_* environment variable[MobifySource] — Value from ~/.mobify file[PackageJsonSource] — Value from package.json b2c keyValues are resolved with this priority (highest to lowest):
SFCC_*/MRT_*)b2c keyWhen troubleshooting, check the source column to understand which configuration is taking precedence.
Put non-sensitive defaults shared by the project under the b2c key. siteId supplies the default site/channel for commands that accept configured site context. For content commands, set contentLibrary and list the same ID with siteLibrary: true when it is the site's private library:
{
"b2c": {
"siteId": "RefArch",
"contentLibrary": "RefArch",
"libraries": [{"id": "RefArch", "siteLibrary": true}]
}
}
With this configuration, b2c content list and b2c content export homepage default to the RefArch site-private library without --library or --site-library. CLI flags, environment variables, and dw.json remain higher-priority overrides. Keep credentials, passwords, secrets, hostnames, and other environment-specific connection data out of package.json.
Always start with b2c setup inspect — it shows resolved values and their sources. Keep masking enabled; use --json for scripting. If a value isn't where you expect, the source column will tell you which file/env var/plugin won.
clientId/clientSecret. Run b2c setup inspect and check the OAuth section.dw.json then the shared global default, without a parent-directory search.SFCC_CLIENT_ID/SFCC_CLIENT_SECRET env vars are exported in this shell, not just defined elsewhere.clientId comes from one source and clientSecret from a lower-priority one, the lower-priority secret is discarded. Provide both from the same source, or use a higher-priority override.b2c setup inspect will show the resolved hostname and its source.dw.json, the active: true config is used by default. Override with -i <name> per-command, or change the default with b2c setup instance set-active <name>.SFCC_SERVER (or any env var) overrides dw.json. Unset it if you want dw.json to win.--server (or SFCC_SERVER) that differs from the dw.json hostname, the CLI ignores all other values from dw.json to prevent mixing credentials across instances. Either match the hostname or pass full credentials explicitly.dw.json is not being picked upSources block from b2c setup inspect — if DwJsonSource isn't listed, the file wasn't found.SFCC_PROJECT_DIRECTORY, or pass --config /path/to/dw.json.clientId and client-id work. See "dw.json Key Casing" above.clientId/clientSecret belong to the target instance (Account Manager scopes the API client per tenant).sfcc.cdn-zones, sfcc.orders). Pass --auth-scope or set SFCC_OAUTH_SCOPES.tenantId is correct — tenant IDs use underscores (zzxy_001), hostnames use hyphens (zzxy-001). The CLI normalizes between them, but a wrong tenant ID will produce 403s.tenantId / shortCodedw.json, SFCC_TENANT_ID/SFCC_SHORTCODE, or package.json. Run b2c setup inspect to see which source provided them.tenantId is derived from the hostname (replace - with _): zzxy-001.dx... → zzxy_001. The reverse also applies: with a sandbox tenant ID and no hostname, the hostname is derived.MRT_API_KEY (or SFCC_MRT_API_KEY) env var, or ~/.mobify file ({ "api_key": "..." }).--cloud-origin <host>, the CLI looks for ~/.mobify--<host> instead of plain ~/.mobify.setup inspectadmi...REDACTED. Keep masking enabled for routine troubleshooting. Use --unmask only when the user explicitly requests secret values.-, no source provided it. Check spelling in dw.json, env var presence, and plugin output. Remember: clientSecret, password, and mrtApiKey cannot be set via package.json — use dw.json or env vars..env file) override dw.json, and an env file SFCC_SERVER with a different hostname skips the dw.json entry entirely. Storefront Next variables never override dw.json.Compare two outputs:
b2c setup inspect --json > expected.json # in a known-good shell
# ... run the failing command in the broken shell, then:
b2c setup inspect --json > actual.json
diff expected.json actual.json
The diff usually points directly at the missing or overridden field.
Use b2c auth token to get an admin OAuth access token for Account Manager credentials (OCAPI and Admin APIs). This is useful for testing APIs, scripting, or CI/CD pipelines.
# Get access token (outputs raw token to stdout)
b2c auth token
# Get token with browser-based auth
b2c auth token --user-auth
# Get token with specific scopes (accepts multiple: repeat --auth-scope or comma-separate)
b2c auth token --auth-scope sfcc.orders --auth-scope sfcc.products
b2c auth token --auth-scope "sfcc.orders,sfcc.products"
# Get token as JSON (includes expiration and scopes)
b2c auth token --json
# Use in curl for OCAPI calls
curl -H "Authorization: Bearer $(b2c auth token)" \
"https://your-instance.dx.commercecloud.salesforce.com/s/-/dw/data/v24_1/sites"
The token is obtained using the clientId and clientSecret from your configuration (dw.json or environment variables). If no secret is configured, or --user-auth is used, you sign in with your account in the browser.
Note: This command returns admin tokens for OCAPI/Admin APIs. For shopper tokens (SLAS), see the b2c-slas skill.
Calling SCAPI Admin APIs (system or custom)? The token must carry the tenant scope
SALESFORCE_COMMERCE_API:<tenant_id>plus the API-specific scopes.b2c auth tokendoes not add the tenant scope for you (unlike the SCAPI subcommands such asb2c scapi custom status), so pass it explicitly:b2c auth token \ --auth-scope "SALESFORCE_COMMERCE_API:zzpq_013" \ --auth-scope sfcc.orders --auth-scope sfcc.products.rwSee the
b2c:b2c-scapi-adminandb2c:b2c-custom-api-developmentskills for details.
See b2c setup --help for other setup commands including b2c setup skills for AI agent skill installation.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin b2c-cli28 skills in this plugin
/b2c-amManage Account Manager resources including API clients, users, roles, and organizations. Use this skill whenever the user needs to create or update API clients, onboard or offboard developers, assign Account Manager roles scoped to tenants, audit user permissions, look up organizations, or provision API clients for CI/CD pipelines. Also use when managing AM role assignments or querying Account Manager data — even if they just say "add a new developer" or "set up an API client". For instance-level Business Manager administration (BM roles, BM users, BM access keys, BM whoami), defer to the `b2c-cli:b2c-bm-users-roles` skill./b2c-bm-users-rolesManage Business Manager users, access roles, role permissions, and per-user access keys on a B2C Commerce instance using the b2c CLI. Use this skill whenever the user needs to list or search BM users on a sandbox or production instance, identify which BM user an OAuth token resolves to ("whoami"), assign or revoke instance-level access roles, edit role permissions, look up a user's WebDAV / OCAPI / Storefront access key, or rotate access keys for SSO-managed users. Also use when the user asks "what's my BM login on sandbox X", "rotate my WebDAV password", "how do I make a custom BM role", "audit BM users on this instance", or "delete a stale BM user from a sandbox".Other plugins' skills for the same job