@oclif/command

The legacy base command class for the oclif framework for building Node.js command-line interfaces.

Framework
npm
v1.8.36
136stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
45/100Fair
Development Activity0
Maintenance44
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture78
Code Quality74
Innovation76
Learning Curve68

@oclif/command is the base command building block of the oclif CLI framework. You subclass its abstract Command class and implement a run method, and it wires up argument and flag parsing, help generation, error handling, and the command lifecycle so you can focus on your command’s behavior rather than CLI plumbing.

This package has been superseded by @oclif/core, which consolidates the previously separate oclif packages into a single dependency, and it is no longer maintained. It remains widely installed as a transitive dependency of older oclif-based CLIs and is documented here for reference and migration planning.

What You Get

  • An abstract Command base class with a run method to implement your command logic
  • A flags helper for declaring typed flags and arguments
  • Built-in help generation, error formatting, and Node version and CWD checks
  • A run/Main entry point for bootstrapping single-command and multi-command CLIs

Common Use Cases

  • Defining commands for a Node.js CLI built on the oclif framework
  • Declaring typed flags and positional arguments with automatic parsing and validation
  • Maintaining or migrating an existing oclif v1 CLI toward @oclif/core

Under The Hood

Architecture - src/index.ts runs startup guards (checkCWD, checkNodeVersion) and re-exports the abstract Command from src/command.ts, the flags helper from src/flags.ts, and run/Main from src/main.ts. The Command class in command.ts composes the sibling oclif packages: it delegates argument and flag parsing to @oclif/parser, configuration to @oclif/config, error formatting to @oclif/errors, and help rendering to @oclif/help. Concrete commands subclass it and implement run, while the base handles the lifecycle and even installs a process.stdout EPIPE guard so piping to tools like head does not crash the CLI.

Tech Stack - Written in TypeScript and published as compiled CommonJS to lib/. Runtime dependencies are the other oclif building blocks (@oclif/config, @oclif/errors, @oclif/parser, @oclif/help) plus debug and semver. The build and test toolchain uses tsconfig.json and a Mocha-style test suite.

Code Quality - The source is small and focused across command.ts, flags.ts, main.ts, and util.ts, with a test directory containing command.test.ts and main.test.ts. The code is typed throughout and documented with JSDoc comments on the base class members, though the project is now frozen in maintenance-only status.

API Design - The developer surface is deliberately narrow: extend Command, implement run, and declare flags/args. This subclass-and-override pattern is idiomatic and well documented, but because the package is one piece of a multi-package framework it requires understanding the surrounding oclif packages, which is precisely the friction @oclif/core was created to remove.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search