add-oclif-command
Add a new OCLIF command to a CLI package with proper base class, flags, args, and post-creation steps
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- add-oclif-command
- description
- Add a new OCLIF command to a CLI package with proper base class, flags, args, and post-creation steps
- disable-model-invocation
- true
03 SKILL.md 正文
Add a New OCLIF Command
Guided workflow to add a command to an existing CLI package.
Step 1: Gather Info
Ask the user for:
- Target CLI package: cli, dill-cli, repopo, or sort-tsconfig
- Command name: e.g.,
statusorgit/status(slash = topic nesting) - Description: one-line summary
- Base class:
CommandWithConfig(default) orGitCommand(for git operations) — both from@tylerbu/cli-api - Flags and args: what inputs does the command need?
Step 2: Create the Command File
Create packages/<pkg>/src/commands/<name>.ts:
import { Args, Flags } from "@oclif/core";
import { CommandWithConfig } from "@tylerbu/cli-api";
export default class CommandName extends CommandWithConfig<typeof CommandName> {
public static override readonly description = "Description here";
public static override readonly flags = {
// Add flags here
...CommandWithConfig.flags,
};
public static override readonly args = {
// Add args here
};
public override async run(): Promise<void> {
const { args, flags } = this;
// Implementation
}
}
For git commands, use GitCommand instead — it provides this.git (simple-git instance).
Step 3: Build and Verify
# Compile
pnpm nx run <pkg>:build:compile
# Test with dev binary
./packages/<pkg>/bin/dev.js <command> --help
# Regenerate manifest
pnpm nx run <pkg>:build:manifest
# Regenerate README
pnpm nx run <pkg>:build:readme
Step 4: Update Snapshots (if applicable)
# Regenerate command snapshots
./packages/<pkg>/bin/dev.js snapshot:generate --filepath test/commands/__snapshots__/commands.json
# Verify snapshots match
./packages/<pkg>/bin/dev.js snapshot:compare --filepath test/commands/__snapshots__/commands.json
Step 5: Final Checks
# Full build to ensure everything links
pnpm nx run <pkg>:build
# Run tests
pnpm nx run <pkg>:test
# Policy check
./packages/repopo/bin/dev.js check
Conventions
- Use tabs for indentation
- Keep commands focused — one responsibility per command
- Use
this.log()for stdout,this.warn()for warnings,this.error()for fatal errors (exits) - Prefer flags over positional args for optional inputs
- Always spread
...BaseClass.flagsto inherit base flags
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.