Skip to main content

Plugins

Plugins are a great way to offer experimental functionality, allow users to extend your CLI, break up a CLI into modular components, or share functionality between CLIs.

Plugins can have commands or hooks just like a CLI. To add a plugin such as the not-found plugin plugin, first add it to your CLI with yarn add @oclif/plugin-not-found, then add the following to your package.json:

{
"name": "mycli",
"version": "0.0.0",
// ...
"oclif": {
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-not-found"
]
}
}

If you want users to be able to install their own plugins into your CLI, use the plugins plugin.

Useful Plugins

Community Plugins

Building your own plugin

Writing code for plugins is essentially the same as writing within a CLI. They can export 3 different types: commands, hooks, and other plugins.

Run npx oclif generate mynewplugin to create a plugin in a new directory. This will come with a sample command called hello.