# @salesforce/sf-plugins-core

> Utils for writing Salesforce CLI plugins

Latest version **13.0.4** (published 2026-08-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @salesforce/sf-plugins-core
pnpm add @salesforce/sf-plugins-core
yarn add @salesforce/sf-plugins-core
bun add @salesforce/sf-plugins-core
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 13.0.4 |
| Published | 2026-08-31 |
| First published | 2021-08-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.0.0 |
| Dependencies | 10 |
| Unpacked size | 215.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Maintainers | ire-npm-team-user, jimjag, salesforce-releases, jasonschroeder-sfdc, mobify, lwc-admin, salesforce-admin |

## Links

- npm: https://www.npmjs.com/package/@salesforce/sf-plugins-core
- Repository: https://github.com/salesforcecli/sf-plugins-core
- Homepage: https://github.com/salesforcecli/sf-plugins-core#readme
- Issues: https://github.com/salesforcecli/sf-plugins-core/issues
- npm.io page: https://npm.io/package/@salesforce/sf-plugins-core

## Dependencies (10)

- [ansis](https://npm.io/package/ansis.md) ^3.3.2
- [@oclif/core](https://npm.io/package/@oclif/core.md) ^5.0.0
- [@oclif/table](https://npm.io/package/@oclif/table.md) ^1.0.0
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.12.0
- [terminal-link](https://npm.io/package/terminal-link.md) ^3.0.0
- [@salesforce/kit](https://npm.io/package/@salesforce/kit.md) ^4.0.0
- [@salesforce/core](https://npm.io/package/@salesforce/core.md) ^9.1.4
- [@inquirer/confirm](https://npm.io/package/@inquirer/confirm.md) ^6.1.1
- [@inquirer/password](https://npm.io/package/@inquirer/password.md) ^5.1.1
- [@salesforce/ts-types](https://npm.io/package/@salesforce/ts-types.md) ^3.0.0

## Recent versions

- 13.0.4 (latest) — 2026-08-31
- 11.3.3-dev.3 (dev) — 2024-08-16
- 10.0.0-beta.1 (beta) — 2024-06-04
- 8.0.5-qa.0 (qa) — 2024-04-09
- 13.0.3 — 2026-08-18
- 13.0.2 — 2026-08-18
- 13.0.1 — 2026-08-18
- 13.0.0 — 2026-07-29
- 12.2.28 — 2026-07-24
- 12.2.27 — 2026-07-24
- 12.2.26 — 2026-07-08
- 12.2.25 — 2026-06-26
- 12.2.24 — 2026-05-31
- 12.2.23 — 2026-05-31
- 12.2.22 — 2026-05-25
- … 322 more at https://npm.io/package/@salesforce/sf-plugins-core/versions

## README

[![NPM](https://img.shields.io/npm/v/@salesforce/sf-plugins-core.svg)](https://www.npmjs.com/package/@salesforce/sf-plugins-core)

# Description

The @salesforce/sf-plugins-core provides utilities for writing [sf](https://github.com/salesforcecli/cli) plugins.

Docs: [https://salesforcecli.github.io/sf-plugins-core](https://salesforcecli.github.io/sf-plugins-core)

## SfCommand Abstract Class

The SfCommand abstract class extends [@oclif/core's Command class](https://github.com/oclif/core/blob/main/src/command.ts) for examples of how to build a definition.
) class and adds useful extensions to ease the development of commands for use in the Salesforce Unified CLI.

- SfCommand takes a generic type that defines the success JSON result
- Enable the json flag support by default
- Provides functions that help place success messages, warnings and errors into the correct location in JSON results
- Enables additional help sections to the standard oclif command help output
- Provides access to the [cli-ux cli actions](https://github.com/oclif/cli-ux#cliaction). This avoids having to import that interface from cli-ux and manually handling the `--json` flag.
- Provides simple, stubbable prompts for confirmation and secrets

## Flags

Flags is a convenience reference to [@oclif/core#Flags](https://github.com/oclif/core/blob/main/src/flags.ts)

### Specialty Flags

These flags can be imported into a command and used like any other flag. See code examples in the links

- [orgApiVersionFlag](src/flags/orgApiVersion.ts)
  - specifies a Salesforce API version.
  - reads from Config (if available)
  - validates version is still active
  - warns if version if deprecated
- [requiredOrgFlag](src/flags/orgFlags.ts)
  - accepts a username or alias
  - aware of configuration defaults
  - throws if org or default doesn't exist or can't be found
- [optionalOrgFlag](src/flags/orgFlags.ts)
  - accepts a username or alias
  - aware of configuration defaults
  - might be undefined if an org isn't found
- [requiredHubFlag](src/flags/orgFlags.ts)
  - accepts a username or alias
  - aware of configuration defaults
  - throws if org or default doesn't exist or can't be found
  - throws if an org is found but is not a dev hub
- [durationFlag](src/flags/duration.ts)
  - specify a unit
  - optionally specify a min, max, and defaultValue
  - returns a [Duration](https://github.com/forcedotcom/kit/blob/main/src/duration.ts)
  - can be undefined if you don't set the default
- [salesforceIdFlag](src/flags/salesforceId.ts)
  - validates that IDs are valid salesforce ID
  - optionally restrict to 15/18 char
  - optionally require it to be begin with a certain prefix

### Unit Test Helpers

Want to verify SfCommand Ux behavior (warnings, tables, spinners, prompts)? Check out the functions in `stubUx``.

---
_Source: https://npm.io/package/@salesforce/sf-plugins-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
