Plugin System
ForgeKit supports a plugin system that lets you extend the CLI with new commands from the community.
Usage
bash
forgekit plugin <subcommand>Subcommands
| Subcommand | Description |
|---|---|
add <name> | Install a plugin from npm |
remove <name> | Uninstall a plugin |
list | List all installed plugins |
Examples
bash
# Install a plugin
forgekit plugin add forgekit-plugin-terraform
# Remove a plugin
forgekit plugin remove forgekit-plugin-terraform
# Skip confirmation on remove
forgekit plugin remove forgekit-plugin-terraform -y
# List installed plugins
forgekit plugin listHow Plugins Work
- Plugins are npm packages named
forgekit-plugin-* - They are installed to
~/.forgekit/plugins/ - On CLI startup, ForgeKit loads all installed plugins and registers their commands
- Bad plugins are safely skipped and never crash the CLI
Writing a Plugin
A ForgeKit plugin is an npm package that exports a register function:
typescript
// forgekit-plugin-example/index.js
module.exports = {
register(program) {
program
.command('example')
.description('An example plugin command')
.action(() => {
console.log('Hello from the example plugin!');
});
}
};Plugin Requirements
- Package name must start with
forgekit-plugin- - Must export a
register(program)function - The
programargument is a Commander.js instance - Must not throw during registration
- Must not block the event loop during loading
Package.json
json
{
"name": "forgekit-plugin-example",
"version": "1.0.0",
"description": "An example ForgeKit plugin",
"main": "index.js",
"keywords": ["forgekit", "forgekit-plugin"]
}Plugin Safety
ForgeKit takes several precautions with plugins:
- Name validation: Plugin names are validated against path traversal attacks
- Isolated loading: Each plugin is loaded in a try/catch; failures are logged as warnings, not errors
- No crash guarantee: If a plugin fails to load or register, the CLI continues normally
- Skip flag: Use
--no-pluginsto start ForgeKit without loading any plugins
bash
# Run without plugins
forgekit --no-plugins new my-appPlugin Storage
Plugins are installed to:
~/.forgekit/plugins/
node_modules/
forgekit-plugin-terraform/
forgekit-plugin-example/
package.jsonConfiguration
You can track your preferred plugins in the config file:
json
// ~/.forgekit/config.json
{
"plugins": [
"forgekit-plugin-terraform",
"forgekit-plugin-example"
]
}