cli-command-development
БесплатноБез исполняемых скриптовНе проверенCreating new CLI commands and topics for the B2C CLI using oclif. Use when adding a new command, creating a topic, adding flags or arguments, implementing…
Об этом скилле
CLI Command Development
This skill covers creating new CLI commands and topics for the B2C CLI.
Command Organization
Commands live in packages/b2c-cli/src/commands/. The directory structure maps directly to command names:
commands/
├── code/
│ ├── deploy.ts → b2c code deploy
│ ├── activate.ts → b2c code activate
│ └── list.ts → b2c code list
├── sandbox/
│ ├── create.ts → b2c sandbox create
│ └── list.ts → b2c sandbox list
└── mrt/
└── env/
└── var/
└── set.ts → b2c mrt env var set
Command Class Hierarchy
Choose the appropriate base class based on what your command needs:
BaseCommand (logging, JSON output, error handling)
└─ OAuthCommand (OAuth authentication)
├─ InstanceCommand (B2C instance: hostname, code version)
│ ├─ CartridgeCommand (cartridge path + filters)
│ ├─ JobCommand (job execution helpers)
│ └─ WebDavCommand (WebDAV root directory)
├─ MrtCommand (Managed Runtime API)
└─ OdsCommand (On-Demand Sandbox API)
Import from @salesforce/b2c-tooling-sdk/cli:
import { InstanceCommand, CartridgeCommand, OdsCommand } from '@salesforce/b2c-tooling-sdk/cli';
Standard Command Template
/*
* Copyright (c) 2025, Salesforce, Inc.
* SPDX-License-Identifier: Apache-2
* For full license text, see the license.txt file in the repo root
*/
import {Args, Flags} from '@oclif/core';
import {InstanceCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {getApiErrorMessage} from '@salesforce/b2c-tooling-sdk';
import {t} from '../../i18n/index.js';
interface MyCommandResponse {
success: boolean;
data: SomeType[];
}
export default class MyCommand extends InstanceCommand<typeof MyCommand> {
static description = t('commands.topic.mycommand.description', 'Human-readable description');
static enableJsonFlag = true;
static examples = [
'<%= config.bin %> <%= command.id %> arg1',
'<%= config.bin %> <%= command.id %> --flag value',
'<%= config.bin %> <%= command.id %> --json',
];
static args = {
name: Args.string({
description: 'Description of the argument',
required: true,
}),
};
static flags = {
myFlag: Flags.string({
char: 'm',
description: 'Flag description',
default: 'defaultValue',
}),
myBool: Flags.boolean({
description: 'Boolean flag',
default: false,
}),
};
async run(): Promise<MyCommandResponse> {
// Validation - call appropriate require* methods
this.requireServer();
// Access parsed args and flags
const {name} = this.args;
const {myFlag, myBool} = this.flags;
this.log(t('commands.topic.mycommand.working', 'Working on {{name}}...', {name}));
// Implementation
const {data, error, response} = await this.instance.ocapi.GET('/some/endpoint');
if (error) {
this.error(t('commands.topic.mycommand.error', 'Failed: {{message}}', {
message: getApiErrorMessage(error, response),
}));
}
const result: MyCommandResponse = {
success: true,
data,
};
// JSON mode returns the object directly (oclif handles serialization)
if (this.jsonEnabled()) {
return result;
}
// Human-readable output
this.log('Success!');
return result;
}
}
Adding a New Topic
When creating a new command topic, add it to packages/b2c-cli/package.json in the oclif section:
{
"oclif": {
"topics": {
"newtopic": {
"description": "Commands for new functionality"
},
"newtopic:subtopic": {
"description": "Subtopic commands"
}
}
}
}
Flag Patterns
Common Flag Types
static flags = {
// String with short alias and env var fallback
server: Flags.string({
char: 's',
description: 'Server hostname',
env: 'SFCC_SERVER',
}),
// Integer with default
timeout: Flags.integer({
description: 'Timeout in seconds',
default: 60,
}),
// Boolean with --no-* variant
wait: Flags.boolean({
description: 'Wait for completion',
default: true,
allowNo: true, // enables --no-wait
}),
// Comma-separated multiple values
channels: Flags.string({
description: 'Site channels (comma-separated)',
multiple: true,
multipleNonGreedy: true,
delimiter: ',',
}),
// Enum-like options
format: Flags.string({
description: 'Output format',
options: ['json', 'csv', 'table'],
default: 'table',
}),
// Conditional flag
secret: Flags.string({
description: 'Client secret (required for private clients)',
dependsOn: ['client-id'],
}),
};
Flags That Duplicate Config Identifiers
Any flag that names something also stored in shared configuration (siteId, realm, mrtProject, mrtEnvironment, contentLibrary, shortCode, tenantId, ...) must fall back to the resolved config value (dw.json, env, pack
Установить cli-command-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cli-command-development?
Creating new CLI commands and topics for the B2C CLI using oclif. Use when adding a new command, creating a topic, adding flags or arguments, implementing table output, or extending BaseCommand/OAuthCommand/InstanceCommand.
Как установить скилл cli-command-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cli-command-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic