oclif-plugin-dev

Develop oclif and sf CLI plugins with commands, flags, hooks, and tests.

Updated Dec 1, 2025
One-click install
npx skills add https://github.com/jterratsdev/smart-deployment --skill oclif-plugin-dev-jterratsdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: oclif-plugin-dev
Source: https://github.com/jterratsdev/smart-deployment/tree/main/.setup-agents/skills/oclif-plugin
Command: npx skills add https://github.com/jterratsdev/smart-deployment --skill oclif-plugin-dev-jterratsdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building Salesforce CLI plugins with oclif involves many conventions—command anatomy, message files, flag patterns, schema generation, and testing—that are easy to get wrong without a structured reference. ## Core Features & Use Cases - Command Scaffolding Patterns: Provides the standard SfCommand structure with Messages API, typed flags, and JSON-serializable result types. - Testing Guidance: Covers unit tests with mocha/chai and command integration tests using TestContext from @salesforce/core. - Build & Release Workflow: Documents schema generation, command snapshots, wireit builds, and local plugin linking. - Use Case: When adding a new sf smart-deployment analyze command, follow the Skill's command anatomy, messages file format, and flag patterns, then regenerate schemas and snapshots before release. ## Quick Start Ask the assistant to scaffold a new oclif command with flags, a messages file, and unit tests following the sf plugin conventions.

Frequently Asked Questions about oclif-plugin-dev

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

FAQPage Schema
How do I create a new sf CLI command with oclif?

Extend SfCommand from @salesforce/sf-plugins-core, define static summary, description, examples, and flags using the Messages API, then implement the run method returning a JSON-serializable result type. Keep business logic in a services directory rather than inside the command class.

How do I test oclif commands with mocha and chai?

Use TestContext from @salesforce/core/testSetup for command integration tests, calling MyCommand.run with an argument array and asserting on the returned result. For pure logic, write fast unit tests against services without bootstrapping oclif.

What flag types does oclif support for CLI commands?

The Flags API supports string, boolean, and integer types with options like required, default, min, options for enums, multiple for repeatable flags, and exclusive for mutually exclusive flags. Each flag should have summary and description text loaded from message files.

Why must I regenerate schemas and snapshots after changing commands?

oclif derives JSON schemas and command snapshots from command and flag definitions, so adding or modifying commands makes them stale. Run schema generate and snapshot:generate through the dev bin after any command surface change to keep tests passing.

Does sf plugin development require ESM modules?

Yes, the pattern is ESM-only: use .js extensions in relative imports and import.meta.url for path resolution such as Messages.importMessagesDirectoryFromMetaUrl. CommonJS require statements are not used in this project structure.