Skip to content
Skills Library
Programming · Building & coding

webiny-cli-extensions

/webiny-cli-extensions

Adding custom commands to the Webiny CLI using CliCommandFactory. Use this skill when the developer wants to create a custom CLI command, add a data migration script, build a code generator, create deployment scripts, export CMS content, or add health check commands. Covers CliCommandFactory.Interface, command definition, typed parameters, the Ui service for terminal output, and registration via <Cli.Command>.

Repository
webiny-js ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

95/ 100Class: good
Format20 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Adding custom commands to the Webiny CLI using CliCommandFactory. Use this skill when the developer wants to create a custom CLI command, add a data migration script, build a code generator, create deployment scripts, export CMS content, or add health check commands. Covers CliCommandFactory.Interface, command definition, typed parameters, the Ui service for terminal output, and registration via <Cli.Command>.

Original author description

Adding custom commands to the Webiny CLI using CliCommandFactory. Use this skill when the developer wants to create a custom CLI command, add a data migration script, build a code generator, create deployment scripts, export CMS content, or add health check commands. Covers CliCommandFactory.Interface, command definition, typed parameters, the Ui service for terminal output, and registration via <Cli.Command>.

How it works

  1. TL;DR
  2. The CliCommandFactory Pattern
  3. Command Definition Properties
  4. Parameter Definition
  5. The Ui Service
  6. Use Cases
  7. Quick Reference
  8. Related Skills
Original SKILL.md headings · 122 lines, 513 words
SKILL.md preview
---
name: webiny-cli-extensions
description: >
  Adding custom commands to the Webiny CLI using CliCommandFactory.
  Use this skill when the developer wants to create a custom CLI command, add a data migration
  script, build a code generator, create deployment scripts, export CMS content, or add
  health check commands. Covers CliCommandFactory.Interface, command definition, typed
  parameters, the Ui service for terminal output, and registration via <Cli.Command>.
---

# 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

```typescript
// 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):

```tsx
<Cli.Command src={"/extensions/MyCustomCommand.ts"} />
```

Run it:

```bash
yarn webiny my-custom-command "World"
```

## Command Definition Properties

| Property      | Type                                 | Description                                                    |
| ------------- | ------------------------------------ | -------------------------------------------------------------- |
| `name`        | `string`                             | The command name used on the CLI (e.g., `"my-custom-command"`) |
| `description` | `string`                             | Help text shown when listing commands                          |
| `examples`    | `string[]`                           | Usage examples (`$0` is replaced with the CLI binary name)     |
| `params`      | `ParamDefinition[]`                  | Positional parameters and options                              |
| `handler`     | `(params: TParams) => Promise<void>` | The function that executes the command                         |

## Parameter Definition

Each param in the `params` array:

| Property      | Type                                | Description                                                  |
| ------------- | ----------------------------------- | ------------------------------------------------------------ |
| `name`        | `string`                            | Parameter name (matches the key in your `TParams` interface) |
| `description` | `string`                            | Help text for this parameter                                 |
| `type`        | `"string" \| "number" \| "boolean"` | Parameter value type                                         |

## The `Ui` Service

Inject `Ui` for formatted terminal output:

```typescript
import { Ui } from "webiny/cli";
```

| Method                       | Description                      |
| ---------------------------- | -------------------------------- |
| `this.ui.info("message")`    | Print an info message (blue)     |
| `this.ui.success("message")` | Print a success message (green)  |
| `this.ui.warning("message")` | Print a warning message (yellow) |
| `this.ui.error("message")`   | Print an error message (red)     |
| `this.ui.emptyLine()`        | 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

- `webiny-dependency-injection` -- The `createImplementation` pattern and available injectable services
- `webiny-project-structure` -- How to register CLI commands in `webiny.config.tsx`
- `webiny-full-stack-architect` -- Full-stack extensions that may include CLI commands alongside API and Admin

Versions

The database has no other skills named webiny-cli-extensions.

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 7febee09a805 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95webiny-project-structure
    Webiny project layout, webiny.config.tsx anatomy, and extension registration. Use this skill when the developer asks about folder structure, where custom code goes, how to register extensions, what webiny.config.tsx does, or how the project is organized. Also use when they need…
  • 95webiny-custom-graphql-api
    Adding custom GraphQL queries and mutations using GraphQLSchemaFactory. Use this skill when the developer wants to add custom GraphQL endpoints, create custom queries or mutations, add business logic to the API layer, build custom resolvers, inject backend services (identity,…
  • 100webiny-webhooks
    Receive and verify Webiny webhooks (webiny.com, the open-source serverless headless CMS, Webiny 6.x). Use when setting up a Webiny webhook endpoint, configuring the signing secret, debugging webhook-id / webhook-timestamp / webhook-signature Standard Webhooks verification, or…
  • 100cli-commands
    Use when adding or modifying CLI command (`but` commands) under `crates/but/src`.
  • 95add-command
    Add support for a new CLI command. Use when implementing a handler or adding to SIMPLE_SAFE.
  • 90command-surface-audit
    Audit, classify and run the real ableton-mind command surface. Use whenever package scripts, CI commands, docs commands, bins, "run all commands", stale scripts, broken commands or command coverage are mentioned.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.