home / skills / salesforcecommercecloud / b2c-developer-tooling / b2c-code

This skill helps you deploy, monitor, and manage Salesforce B2C code versions using the b2c CLI, simplifying cartridge workflows.

npx playbooks add skill salesforcecommercecloud/b2c-developer-tooling --skill b2c-code

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.5 KB
---
name: b2c-code
description: Deploy and manage code versions/cartridges on B2C Commerce instances/sandboxes with the b2c cli. Use when uploading cartridges, activating code versions, watching for file changes during development and CI/CD.
---

# B2C Code Skill

Use the `b2c` CLI to deploy and manage code versions on Salesforce B2C Commerce instances.

> **Tip:** If `b2c` is not installed globally, use `npx @salesforce/b2c-cli` instead (e.g., `npx @salesforce/b2c-cli code deploy`).

## Examples

### Deploy Cartridges

```bash
# deploy all cartridges from current directory
b2c code deploy

# deploy cartridges from a specific directory
b2c code deploy ./my-cartridges

# deploy to a specific server and code version
b2c code deploy --server my-sandbox.demandware.net --code-version v1

# deploy and reload (re-activate) the code version
b2c code deploy --reload

# delete existing cartridges before upload and reload
b2c code deploy --delete --reload

# deploy only specific cartridges
b2c code deploy -c app_storefront_base -c plugin_applepay

# exclude specific cartridges from deployment
b2c code deploy -x test_cartridge
```

### Watch for Changes

```bash
# watch cartridges and upload changes automatically
b2c code watch

# watch a specific directory
b2c code watch ./my-cartridges

# watch with specific server and code version
b2c code watch --server my-sandbox.demandware.net --code-version v1

# watch only specific cartridges
b2c code watch -c app_storefront_base

# watch excluding specific cartridges
b2c code watch -x test_cartridge
```

### List Code Versions

```bash
# list code versions on the instance
b2c code list

# list with JSON output
b2c code list --json
```

### Activate Code Version

```bash
# activate a code version
b2c code activate <version-name>

# reload (re-activate) the current code version
b2c code activate --reload
```

**Note:** Activating a code version triggers Custom API endpoint registration. If you've added or modified Custom APIs, use `--reload` with deploy or activate to register them. Check registration status with the `b2c-cli:b2c-scapi-custom` skill.

### Delete Code Version

```bash
# delete a code version
b2c code delete <version-name>
```

### More Commands

See `b2c code --help` for a full list of available commands and options in the `code` topic.

## Related Skills

- `b2c-cli:b2c-scapi-custom` - Check Custom API registration status after deployment
- `b2c-cli:b2c-webdav` - Low-level file operations (delete cartridges, list files)
- `b2c:b2c-custom-api-development` - Creating Custom API endpoints

Overview

This skill provides a command-line interface for deploying and managing code versions and cartridges on Salesforce B2C Commerce instances using the b2c CLI. It streamlines uploading cartridges, activating or reloading code versions, watching file changes during development, and automating CI/CD tasks. Use it to reduce manual WebDAV operations and ensure Custom API endpoints are registered after deployments.

How this skill works

The skill wraps the b2c CLI commands to upload cartridges, list and activate code versions, delete versions, and watch source directories for changes. It supports targeting specific servers and code versions, including options to delete existing cartridges, exclude or include specific cartridges, and trigger a reload to register Custom APIs. Watch mode monitors files and pushes incremental updates during development or CI runs.

When to use it

  • Deploy cartridge sets to a sandbox or instance.
  • Activate or reload a code version after code or Custom API changes.
  • Continuously upload changes during local development with watch mode.
  • Run automated deployments in CI/CD pipelines.
  • Remove or clean up old code versions on an instance.

Best practices

  • Use --reload when adding or changing Custom APIs to ensure registration occurs.
  • Specify cartridges (-c) or exclusions (-x) to limit upload scope and speed up deployments.
  • In CI, run b2c code list and validate the expected code versions before and after activation.
  • Combine --delete with deploy cautiously to avoid losing needed files; test in a sandbox first.
  • Use watch mode for fast iterative development, but switch to full deploy in staging/CI for consistent artifacts.

Example use cases

  • Push the storefront and plugin cartridges to a developer sandbox: b2c code deploy -c app_storefront_base -c plugin_applepay.
  • Run an automated pipeline step that deploys, deletes old cartridges, and reloads the target code version.
  • Activate a new release on a staging instance: b2c code activate v2 --server staging.example.demandware.net.
  • Locally develop a cartridge and have changes uploaded automatically: b2c code watch ./cartridges -c my_cartridge.
  • List code versions in JSON for scripting and validation: b2c code list --json.

FAQ

Do I need the b2c CLI installed globally?

No. If b2c is not installed globally, run it via npx: npx @salesforce/b2c-cli code <command>.

When should I use --reload?

Use --reload when you add or modify Custom API endpoints or when you need the instance to re-register APIs and server-side hooks after deployment.