Skip to content

Commit 11f0c9f

Browse files
authored
claude skills and webdav behavior update (#24)
1 parent cc895a0 commit 11f0c9f

File tree

8 files changed

+505
-22
lines changed

8 files changed

+505
-22
lines changed

AGENTS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,35 @@ Features:
8080
- Supports `extended` flag on columns for optional fields
8181
- Use `TableRenderer` class directly for column validation helpers (e.g., `--columns` flag support)
8282

83+
## Claude Code Skills Plugin
84+
85+
The `./plugins/b2c-cli/skills/` directory contains Claude Code skills that teach Claude about the CLI commands. Each skill has a `SKILL.md` file with examples and documentation.
86+
87+
**When modifying CLI commands:**
88+
- Update the corresponding skill in `plugins/b2c-cli/skills/b2c-<topic>/SKILL.md` if it exists
89+
- For breaking changes (renamed flags, removed arguments, changed behavior), update all affected examples
90+
91+
**Skill format:**
92+
```markdown
93+
---
94+
name: b2c-<topic>
95+
description: Brief description of what the skill teaches
96+
---
97+
98+
# B2C <Topic> Skill
99+
100+
Overview of the command topic.
101+
102+
## Examples
103+
104+
### <Use Case>
105+
106+
\`\`\`bash
107+
# comment explaining the command
108+
b2c <topic> <command> [args] [flags]
109+
\`\`\`
110+
```
111+
83112
## Testing
84113

85114
Tests use Mocha + Chai with c8 for coverage. HTTP mocking uses MSW (Mock Service Worker).

packages/b2c-cli/src/commands/webdav/get.ts

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
import * as fs from 'node:fs';
77
import {basename, resolve} from 'node:path';
8-
import {Args} from '@oclif/core';
8+
import {Args, Flags} from '@oclif/core';
99
import {WebDavCommand} from '@salesforce/b2c-tooling-sdk/cli';
1010
import {t} from '../../i18n/index.js';
1111

@@ -21,9 +21,6 @@ export default class WebDavGet extends WebDavCommand<typeof WebDavGet> {
2121
description: 'Remote file path relative to root',
2222
required: true,
2323
}),
24-
local: Args.string({
25-
description: 'Local destination path (defaults to filename in current directory)',
26-
}),
2724
};
2825

2926
static description = t('commands.webdav.get.description', 'Download a file from WebDAV');
@@ -32,39 +29,51 @@ export default class WebDavGet extends WebDavCommand<typeof WebDavGet> {
3229

3330
static examples = [
3431
'<%= config.bin %> <%= command.id %> src/instance/export.zip',
35-
'<%= config.bin %> <%= command.id %> src/instance/export.zip ./downloads/export.zip',
32+
'<%= config.bin %> <%= command.id %> src/instance/export.zip -o ./downloads/export.zip',
3633
'<%= config.bin %> <%= command.id %> --root=logs customerror.log',
34+
'<%= config.bin %> <%= command.id %> --root=logs customerror.log -o -',
3735
];
3836

37+
static flags = {
38+
...WebDavCommand.baseFlags,
39+
output: Flags.string({
40+
char: 'o',
41+
description: 'Output file path (use - for stdout, defaults to filename in current directory)',
42+
}),
43+
};
44+
3945
async run(): Promise<GetResult> {
4046
this.ensureWebDavAuth();
4147

4248
const fullPath = this.buildPath(this.args.remote);
4349

44-
// Determine local path - default to filename in current directory
45-
const localPath = this.args.local || basename(this.args.remote);
50+
// Determine output path - default to filename in current directory
51+
const outputPath = this.flags.output ?? basename(this.args.remote);
52+
const isStdout = outputPath === '-';
4653

47-
this.log(t('commands.webdav.get.downloading', 'Downloading {{path}}...', {path: fullPath}));
54+
if (!isStdout) {
55+
this.log(t('commands.webdav.get.downloading', 'Downloading {{path}}...', {path: fullPath}));
56+
}
4857

4958
const content = await this.instance.webdav.get(fullPath);
50-
51-
// Write to local file
5259
const buffer = Buffer.from(content);
53-
fs.writeFileSync(localPath, buffer);
5460

55-
const result: GetResult = {
61+
if (isStdout) {
62+
process.stdout.write(buffer);
63+
} else {
64+
fs.writeFileSync(outputPath, buffer);
65+
this.log(
66+
t('commands.webdav.get.success', 'Downloaded {{size}} bytes to {{path}}', {
67+
size: buffer.length,
68+
path: resolve(outputPath),
69+
}),
70+
);
71+
}
72+
73+
return {
5674
remotePath: fullPath,
57-
localPath: resolve(localPath),
75+
localPath: isStdout ? '-' : resolve(outputPath),
5876
size: buffer.length,
5977
};
60-
61-
this.log(
62-
t('commands.webdav.get.success', 'Downloaded {{size}} bytes to {{path}}', {
63-
size: result.size,
64-
path: result.localPath,
65-
}),
66-
);
67-
68-
return result;
6978
}
7079
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: b2c-code
3+
description: Salesforce B2C Commerce code version deployment and management Skill
4+
---
5+
6+
# B2C Code Skill
7+
8+
Use the `b2c` CLI plugin to deploy and manage code versions on Salesforce B2C Commerce instances.
9+
10+
## Examples
11+
12+
### Deploy Cartridges
13+
14+
```bash
15+
# deploy all cartridges from current directory
16+
b2c code deploy
17+
18+
# deploy cartridges from a specific directory
19+
b2c code deploy ./my-cartridges
20+
21+
# deploy to a specific server and code version
22+
b2c code deploy --server my-sandbox.demandware.net --code-version v1
23+
24+
# deploy and reload (re-activate) the code version
25+
b2c code deploy --reload
26+
27+
# delete existing cartridges before upload and reload
28+
b2c code deploy --delete --reload
29+
30+
# deploy only specific cartridges
31+
b2c code deploy -c app_storefront_base -c plugin_applepay
32+
33+
# exclude specific cartridges from deployment
34+
b2c code deploy -x test_cartridge
35+
```
36+
37+
### Watch for Changes
38+
39+
```bash
40+
# watch cartridges and upload changes automatically
41+
b2c code watch
42+
43+
# watch a specific directory
44+
b2c code watch ./my-cartridges
45+
46+
# watch with specific server and code version
47+
b2c code watch --server my-sandbox.demandware.net --code-version v1
48+
49+
# watch only specific cartridges
50+
b2c code watch -c app_storefront_base
51+
52+
# watch excluding specific cartridges
53+
b2c code watch -x test_cartridge
54+
```
55+
56+
### List Code Versions
57+
58+
```bash
59+
# list code versions on the instance
60+
b2c code list
61+
62+
# list with JSON output
63+
b2c code list --json
64+
```
65+
66+
### Activate Code Version
67+
68+
```bash
69+
# activate a code version
70+
b2c code activate <version-name>
71+
72+
# reload (re-activate) the current code version
73+
b2c code activate --reload
74+
```
75+
76+
### Delete Code Version
77+
78+
```bash
79+
# delete a code version
80+
b2c code delete <version-name>
81+
```
82+
83+
### More Commands
84+
85+
See `b2c code --help` for a full list of available commands and options in the `code` topic.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: b2c-job
3+
description: Salesforce B2C Commerce job execution and site archive import/export (IMPEX) Skill
4+
---
5+
6+
# B2C Job Skill
7+
8+
Use the `b2c` CLI plugin to run jobs and import/export site archives on Salesforce B2C Commerce instances.
9+
10+
## Examples
11+
12+
### Run a Job
13+
14+
```bash
15+
# run a job and return immediately
16+
b2c job run my-custom-job
17+
18+
# run a job and wait for completion
19+
b2c job run my-custom-job --wait
20+
21+
# run a job with a timeout (in seconds)
22+
b2c job run my-custom-job --wait --timeout 600
23+
24+
# run a job with parameters
25+
b2c job run my-custom-job -P "SiteScope={\"all_storefront_sites\":true}" -P OtherParam=value
26+
27+
# show job log if the job fails
28+
b2c job run my-custom-job --wait --show-log
29+
```
30+
31+
### Import Site Archives
32+
33+
```bash
34+
# import a local directory as a site archive
35+
b2c job import ./my-site-data
36+
37+
# import a local zip file
38+
b2c job import ./export.zip
39+
40+
# keep the archive on the instance after import
41+
b2c job import ./my-site-data --keep-archive
42+
43+
# import an archive that already exists on the instance (in Impex/src/instance/)
44+
b2c job import existing-archive.zip --remote
45+
46+
# show job log on failure
47+
b2c job import ./my-site-data --show-log
48+
```
49+
50+
### Export Site Archives
51+
52+
```bash
53+
# export site data using the job export command
54+
b2c job export
55+
```
56+
57+
### Search Job Executions
58+
59+
```bash
60+
# search for job executions
61+
b2c job search
62+
63+
# search with JSON output
64+
b2c job search --json
65+
```
66+
67+
### Wait for Job Completion
68+
69+
```bash
70+
# wait for a specific job execution to complete
71+
b2c job wait <execution-id>
72+
```
73+
74+
### More Commands
75+
76+
See `b2c job --help` for a full list of available commands and options in the `job` topic.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: b2c-mrt
3+
description: Salesforce B2C Commerce Managed Runtime (MRT) project and deployment management Skill
4+
---
5+
6+
# B2C MRT Skill
7+
8+
Use the `b2c` CLI plugin to manage Managed Runtime (MRT) projects and deployments for PWA Kit storefronts.
9+
10+
## Examples
11+
12+
### Push Bundle to Managed Runtime
13+
14+
```bash
15+
# push a bundle to MRT for a specific project
16+
b2c mrt push --project my-storefront
17+
18+
# push to a specific environment (staging, production, etc.)
19+
b2c mrt push --project my-storefront --environment staging
20+
21+
# push to production with a release message
22+
b2c mrt push --project my-storefront --environment production --message "Release v1.0.0"
23+
24+
# push from a custom build directory
25+
b2c mrt push --project my-storefront --build-dir ./dist
26+
27+
# specify Node.js version for SSR runtime
28+
b2c mrt push --project my-storefront --node-version 20.x
29+
30+
# add SSR parameters
31+
b2c mrt push --project my-storefront --ssr-param SSRProxyPath=/api
32+
33+
# use JSON output for automation
34+
b2c mrt push --project my-storefront --json
35+
```
36+
37+
### Manage Environments
38+
39+
```bash
40+
# create a new MRT environment
41+
b2c mrt env create
42+
43+
# delete an MRT environment
44+
b2c mrt env delete
45+
```
46+
47+
### Environment Variables
48+
49+
```bash
50+
# manage environment variables for an MRT environment
51+
b2c mrt env var
52+
```
53+
54+
### Configuration
55+
56+
MRT settings can be configured in `dw.json`:
57+
- `mrtProject`: MRT project slug
58+
- `mrtEnvironment`: MRT environment name (staging, production, etc.)
59+
60+
Environment variables:
61+
- `SFCC_MRT_PROJECT`: MRT project slug
62+
- `SFCC_MRT_ENVIRONMENT`: MRT environment
63+
- `SFCC_MRT_API_KEY`: MRT API key
64+
65+
### More Commands
66+
67+
See `b2c mrt --help` for a full list of available commands and options in the `mrt` topic.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: b2c-sites
3+
description: Salesforce B2C Commerce storefront sites listing and inspection Skill
4+
---
5+
6+
# B2C Sites Skill
7+
8+
Use the `b2c` CLI plugin to list and inspect storefront sites on Salesforce B2C Commerce instances.
9+
10+
## Examples
11+
12+
### List Sites
13+
14+
```bash
15+
# list all sites on the configured instance
16+
b2c sites list
17+
18+
# list sites on a specific server
19+
b2c sites list --server my-sandbox.demandware.net
20+
21+
# list sites with JSON output (useful for parsing/automation)
22+
b2c sites list --json
23+
24+
# use a specific instance from config
25+
b2c sites list --instance production
26+
27+
# enable debug logging
28+
b2c sites list --debug
29+
```
30+
31+
### More Commands
32+
33+
See `b2c sites --help` for a full list of available commands and options in the `sites` topic.

0 commit comments

Comments
 (0)