Webiny-js webiny-cli-extensions
install
source · Clone the upstream repo
git clone https://github.com/webiny/webiny-js
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/webiny/webiny-js "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/user-skills/cli-extensions" ~/.claude/skills/webiny-webiny-js-webiny-cli-extensions && rm -rf "$T"
manifest:
skills/user-skills/cli-extensions/SKILL.mdsource content
CLI Extensions
TL;DR
Add custom commands to the Webiny CLI using the
CliCommandFactory pattern. Define a class implementing CliCommandFactory.Interface<TParams>, specify command name, description, params, and handler, then export with CliCommandFactory.createImplementation(). Register in webiny.config.tsx via <Cli.Command>.
The CliCommandFactory Pattern
// extensions/MyCustomCommand.ts import { Ui } from "webiny/cli"; import { CliCommandFactory } from "webiny/cli/command"; export interface IMyCustomCommandParams { name: string; } class MyCustomCommandImpl implements CliCommandFactory.Interface<IMyCustomCommandParams> { constructor(private ui: Ui.Interface) {} execute(): CliCommandFactory.CommandDefinition<IMyCustomCommandParams> { return { name: "my-custom-command", description: "This is my custom command", examples: ["$0 my-custom-command test1", "$0 my-custom-command test2"], params: [ { name: "name", description: "Your name", type: "string" } ], handler: async params => { this.ui.info("Starting my custom command..."); this.ui.emptyLine(); this.ui.success(`Hello, ${params.name}! This is my custom command.`); } }; } } export default CliCommandFactory.createImplementation({ implementation: MyCustomCommandImpl, dependencies: [Ui] });
Register in
webiny.config.tsx (YOU MUST include the .ts file extension in the src prop — omitting it will cause a build failure):
<Cli.Command src={"/extensions/MyCustomCommand.ts"} />
Run it:
yarn webiny my-custom-command "World"
Command Definition Properties
| Property | Type | Description |
|---|---|---|
| | The command name used on the CLI (e.g., ) |
| | Help text shown when listing commands |
| | Usage examples ( is replaced with the CLI binary name) |
| | Positional parameters and options |
| | The function that executes the command |
Parameter Definition
Each param in the
params array:
| Property | Type | Description |
|---|---|---|
| | Parameter name (matches the key in your interface) |
| | Help text for this parameter |
| | Parameter value type |
The Ui
Service
UiInject
Ui for formatted terminal output:
import { Ui } from "webiny/cli";
| Method | Description |
|---|---|
| Print an info message (blue) |
| Print a success message (green) |
| Print a warning message (yellow) |
| Print an error message (red) |
| Print a blank line for spacing |
Use Cases
- Data migrations -- Scripts to migrate or seed CMS data
- Code generators -- Generate boilerplate extension files
- Deployment scripts -- Custom deployment workflows
- Data exports -- Export CMS content to files
- Health checks -- Verify infrastructure or API status
Quick Reference
Import: import { CliCommandFactory } from "webiny/cli/command"; Ui import: import { Ui } from "webiny/cli"; Interface: CliCommandFactory.Interface<TParams> Definition: CliCommandFactory.CommandDefinition<TParams> Export: CliCommandFactory.createImplementation({ implementation, dependencies }) Register: <Cli.Command src={"/extensions/MyCommand.ts"} /> Run: yarn webiny <command-name> [args]
Related Skills
-- Thewebiny-dependency-injection
pattern and available injectable servicescreateImplementation
-- How to register CLI commands inwebiny-project-structurewebiny.config.tsx
-- Full-stack extensions that may include CLI commands alongside API and Adminwebiny-full-stack-architect