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

This skill generates B2C Commerce cartridges, controllers, hooks, APIs, job steps, and Page Designer components from scaffold templates to accelerate project

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

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

Files (1)
SKILL.md
4.2 KB
---
name: b2c-scaffold
description: Generate B2C Commerce cartridges, controllers, hooks, custom APIs, job steps, and Page Designer components from scaffold templates. Use when starting a new cartridge, adding a controller to an existing cartridge, creating hook implementations, bootstrapping custom API endpoints, or generating job steps and Page Designer components.
---

# B2C Scaffold Skill

Use the `b2c scaffold` commands to generate B2C Commerce components from templates.

> **Tip:** If `b2c` is not installed globally, use `npx @salesforce/b2c-cli` instead.

## Examples

### List Available Scaffolds

```bash
# list all scaffolds
b2c scaffold list

# list only cartridge scaffolds
b2c scaffold list --category cartridge

# show extended info (description, tags)
b2c scaffold list -x
```

### Generate a Cartridge

```bash
# generate interactively
b2c scaffold cartridge

# generate with name
b2c scaffold cartridge --name app_custom

# generate to specific directory
b2c scaffold cartridge --name app_custom --output ./src/cartridges

# skip prompts, use defaults
b2c scaffold cartridge --name app_custom --force

# preview without creating files
b2c scaffold cartridge --name app_custom --dry-run
```

### Generate a Controller

```bash
# generate interactively (prompts for cartridge selection)
b2c scaffold controller

# generate with all options
b2c scaffold controller \
  --option controllerName=Account \
  --option cartridgeName=app_custom \
  --option routes=Show,Submit
```

### Generate a Hook

```bash
# generate a system hook
b2c scaffold hook \
  --option hookName=validateBasket \
  --option hookType=system \
  --option hookPoint=dw.order.calculate \
  --option cartridgeName=app_custom

# generate an OCAPI hook
b2c scaffold hook \
  --option hookName=modifyBasket \
  --option hookType=ocapi \
  --option hookPoint=dw.ocapi.shop.basket.beforePOST \
  --option cartridgeName=app_custom
```

### Generate a Custom API

```bash
# generate a shopper API
b2c scaffold custom-api \
  --option apiName=loyalty-points \
  --option apiType=shopper \
  --option cartridgeName=app_custom

# generate an admin API
b2c scaffold custom-api \
  --option apiName=inventory-sync \
  --option apiType=admin \
  --option cartridgeName=app_custom
```

### Generate a Job Step

```bash
# generate a task-based job step
b2c scaffold job-step \
  --option stepId=custom.CleanupOrders \
  --option stepType=task \
  --option cartridgeName=app_custom

# generate a chunk-based job step
b2c scaffold job-step \
  --option stepId=custom.ImportProducts \
  --option stepType=chunk \
  --option cartridgeName=app_custom
```

### Generate a Page Designer Component

```bash
b2c scaffold page-designer-component \
  --option componentId=heroCarousel \
  --option componentName="Hero Carousel" \
  --option componentGroup=content \
  --option cartridgeName=app_custom
```

### Get Scaffold Info

```bash
# see parameters and usage for a scaffold
b2c scaffold info cartridge
b2c scaffold info controller
```

### Search Scaffolds

```bash
# search by keyword
b2c scaffold search api

# search within a category
b2c scaffold search template --category page-designer
```

### Create Custom Scaffolds

```bash
# create a project-local scaffold
b2c scaffold init my-component --project

# create a user scaffold
b2c scaffold init my-component --user

# validate a custom scaffold
b2c scaffold validate ./.b2c/scaffolds/my-component
```

## Built-in Scaffolds

| Scaffold | Category | Description |
|----------|----------|-------------|
| `cartridge` | cartridge | B2C cartridge with standard structure |
| `controller` | cartridge | SFRA controller with routes and middleware |
| `hook` | cartridge | Hook with hooks.json registration |
| `custom-api` | custom-api | Custom SCAPI with OAS 3.0 schema |
| `job-step` | job | Job step with steptypes.json registration |
| `page-designer-component` | page-designer | Page Designer component |

## Related Skills

- `b2c-cli:b2c-code` - Deploy generated cartridges to B2C instances
- `b2c:b2c-controllers` - SFRA controller patterns and best practices
- `b2c:b2c-hooks` - B2C hook extension points
- `b2c:b2c-custom-api-development` - Custom API development guide
- `b2c:b2c-custom-job-steps` - Job step implementation patterns
- `b2c:b2c-page-designer` - Page Designer component development

Overview

This skill scaffolds Salesforce B2C Commerce components from templates to accelerate cartridge development. It generates cartridges, controllers, hooks, custom APIs, job steps, and Page Designer components with sensible defaults and interactive or scripted options. Use it to bootstrap new projects or add consistent, ready-to-edit artifacts to existing cartridges.

How this skill works

The scaffold command reads built-in or project-local templates and fills them with provided options (name, cartridge, routes, hook points, etc.). It supports interactive prompts, --option overrides for automation, dry-run previews, and --force to overwrite files. You can list, inspect, search, and validate scaffold templates before generating files.

When to use it

  • Starting a new B2C cartridge with standard structure and files
  • Adding a new SFRA controller with route and middleware boilerplate
  • Creating hook implementations (system or OCAPI) and hooks.json registration
  • Bootstrapping custom SCAPI endpoints (shopper/admin) with OAS skeletons
  • Generating job steps (task or chunk) and registering in steptypes.json
  • Creating Page Designer components with metadata and client assets

Best practices

  • Prefer --dry-run to preview file changes before writing to disk
  • Use --option flags in CI scripts to generate artifacts reproducibly
  • Keep project-local scaffolds for company conventions and reuse
  • Validate custom scaffolds with scaffold validate before sharing or committing
  • Use descriptive cartridge and component names to avoid naming collisions

Example use cases

  • Quickly create a new cartridge scaffolded to company standards and placed under src/cartridges
  • Add an Account controller with Show and Submit routes using a single scaffold command
  • Generate a system hook implementation wired into hooks.json for order calculations
  • Bootstrap a shopper custom API with OpenAPI stub to implement loyalty endpoints
  • Create a Page Designer component scaffold with group, id, and basic rendering assets

FAQ

Can I run scaffolds non-interactively in CI?

Yes. Provide options with --option and use --force to skip prompts so the command runs unattended.

How do I preview what a scaffold will create?

Use --dry-run to display generated files and changes without writing them to disk.