oclif-command-guide
Reference for OCLIF command patterns, base classes, and conventions used in CLI packages
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- oclif-command-guide
- description
- Reference for OCLIF command patterns, base classes, and conventions used in CLI packages
- user-invocable
- false
02 资源文件 1
- 参考文档prompt.md10.9 KB
03 SKILL.md 正文
OCLIF Command Patterns
Reference for working with OCLIF commands in this monorepo's CLI packages (cli, dill-cli, repopo, sort-tsconfig).
Base Classes (from @tylerbu/cli-api)
CommandWithConfig— For commands that load config files. Provides--configflag and config resolution.GitCommand— For git operations. Providesthis.git(simple-git instance) and git-aware error handling. ExtendsCommandWithConfig.
Always extend one of these base classes, not raw OCLIF Command.
Command File Structure
import { Args, Flags } from "@oclif/core";
import { GitCommand } from "@tylerbu/cli-api";
export default class MyCommand extends GitCommand<typeof MyCommand> {
public static override readonly description = "What this command does";
public static override readonly flags = {
"dry-run": Flags.boolean({ description: "Preview without making changes" }),
...GitCommand.flags, // Inherit base flags
};
public static override readonly args = {
target: Args.string({ required: true, description: "Target branch" }),
};
public override async run(): Promise<void> {
const { args, flags } = this;
// this.git is available from GitCommand
// this.log(), this.warn(), this.error() for output
}
}
File Placement
Commands go in src/commands/. Directory structure defines topics:
src/commands/download.ts→tbu downloadsrc/commands/git/squish.ts→tbu git squishsrc/commands/git/merge-train/preview.ts→tbu git merge-train preview
After Adding/Modifying Commands
Always run these steps after changing commands:
pnpm nx run <pkg>:build:compile— Compile TypeScriptpnpm nx run <pkg>:build:manifest— Regenerateoclif.manifest.jsonpnpm nx run <pkg>:build:readme— Regenerate README command docs./packages/<pkg>/bin/dev.js snapshot:generate— Update test snapshots (if applicable)
Or just run pnpm nx run <pkg>:build to execute all of these via orchestration.
Dev vs Prod Mode
- Dev:
./bin/dev.js <command>— runs from TypeScript source, no compile needed - Prod:
./bin/run.js <command>— runs from compiledesm/
Plugins
CLI packages declare plugins in package.json → oclif.plugins. Common ones:
@oclif/plugin-help,@oclif/plugin-autocomplete,@oclif/plugin-commands@oclif/plugin-command-snapshot— for snapshot testing
Testing
- OCLIF CLIs use command snapshot testing via
@oclif/plugin-command-snapshot - Snapshots in
test/commands/__snapshots__/commands.json - Generate:
./bin/dev.js snapshot:generate - Compare:
./bin/dev.js snapshot:compare(runs duringtest:snapshots)
04 同仓库更多 Skills
unslop
Cut AI tells from any writing.
storytelling
Make sure all prose sentences contribute to a coherent narrative, forming a small story rather than a series of disconnected statements.
stop-slop
Remove AI writing patterns from prose. Use when drafting, editing, or reviewing text to eliminate predictable AI tells.
prose-banlist
A skill that bans certain phrases from being used in prose writing.
ponytail
Lazy senior dev mode: the smallest change that fully solves the task, and a reply a busy human understands in one read. Use on any coding task (writing, fixing, refactoring, reviewing, choosing dependencies) and when the user says "ponytail", "be lazy", "simplest solution", "yagni", or complains about over-engineering or bloat. Levels: lite, full (default), ultra.
ponytail-review
Quality review of a change: is the logic right, is it safe, does it hold under real load, is risky code tested, is it fast enough, and is every line needed. Reads the connected code, not only the diff. Each finding is explained in plain English. Use for "review this", "code review", "review the last commit", "review my PR", "is this over-engineered", /ponytail-review.