webiny-cli-extensions

Create custom Webiny CLI commands using the CliCommandFactory pattern.

8.0k|673|Updated Jan 9, 2018
One-click install
npx skills add https://github.com/webiny/webiny-js --skill webiny-cli-extensions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webiny-cli-extensions
Source: https://github.com/webiny/webiny-js/tree/main/skills/user-skills/cli-extensions
Command: npx skills add https://github.com/webiny/webiny-js --skill webiny-cli-extensions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Webiny projects often need custom automation such as data migrations, code generators, deployment scripts, or health checks, but the default CLI does not include these project-specific commands. This Skill shows how to extend the Webiny CLI with your own typed commands using the CliCommandFactory pattern.

Core Features & Use Cases

  • Custom Command Definition: Implement CliCommandFactory.Interface with a name, description, examples, typed params, and an async handler.
  • Terminal Output via Ui Service: Inject the Ui service to print info, success, warning, and error messages with consistent formatting.
  • Registration in webiny.config.tsx: Register commands declaratively with the <Cli.Command> component, including the required .ts file extension.
  • Use Case: Build a data migration command that seeds CMS content, then run it with yarn webiny my-custom-command "World" like any built-in CLI command.

Quick Start

Ask the AI to create a custom Webiny CLI command using CliCommandFactory and register it in webiny.config.tsx.

Frequently Asked Questions about webiny-cli-extensions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom command to the Webiny CLI?

Create a class implementing CliCommandFactory.Interface<TParams> that returns a command definition with name, description, params, and a handler. Export it with CliCommandFactory.createImplementation and register it in webiny.config.tsx using the <Cli.Command> component.

How do I register a CLI command in webiny.config.tsx?

Use the <Cli.Command src={"/extensions/MyCustomCommand.ts"} /> component in webiny.config.tsx. You must include the .ts file extension in the src prop, otherwise the build will fail.

What parameter types does Webiny CliCommandFactory support?

CliCommandFactory params support three types: string, number, and boolean. Each param definition includes a name matching your TParams interface key, a description for help text, and the value type.

How do I print colored output from a Webiny CLI command?

Inject the Ui service from webiny/cli into your command class via the dependencies array. Then call this.ui.info(), this.ui.success(), this.ui.warning(), this.ui.error(), or this.ui.emptyLine() inside your handler.

Why does my Webiny CLI command fail to build after registration?

The most common cause is omitting the .ts file extension in the src prop of <Cli.Command>. The path must be written as /extensions/MyCustomCommand.ts including the extension, otherwise the build fails.