cli-expert_skill

This skill helps you build robust npm CLI tools by applying Unix-inspired patterns, automatic project root detection, cross-platform arg parsing, and
  • TypeScript

60

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill cin12211/orca-q --skill cli-expert

  • SKILL.md24.2 KB

Overview

This skill is an expert guide for designing and building npm package CLIs that follow Unix philosophy, support robust argument parsing, detect project roots and monorepos automatically, and operate well in both interactive and non-interactive environments. It focuses on cross-platform reliability, distribution best practices, and performance patterns to keep startup times low and behavior predictable.

How this skill works

It inspects project layout, package.json bin entries, workspace markers, and environment variables to detect roots and monorepo types. It recommends libraries and patterns for parsing arguments, handling TTY vs piped input, and composing small tools that interoperate via text streams. It also provides diagnostic commands, validation checks, and test patterns to verify shebangs, permissions, and cross-platform behavior.

When to use it

  • Building a new CLI package intended for npm distribution
  • Refactoring a monorepo-aware CLI to support workspaces and hoisting
  • Adding robust interactive and non-interactive modes with TTY detection
  • Diagnosing install-time issues like broken shebangs or non-executable binaries
  • Optimizing CLI startup time and reducing bundle size for faster launches

Best practices

  • Design each binary to do one focused job and compose via pipes
  • Detect interactive mode with process.stdin.isTTY/process.stdout.isTTY and respect CI env
  • Use established parsers (parseArgs, Commander, Yargs) and allow unknown options for workspace tools
  • Enforce LF and binary attributes (.gitattributes) to prevent shebang corruption
  • Lazy-load commands and dynamic-import heavy modules to target <100ms startup
  • Test on Windows, macOS, and Linux; include CI matrix and npm pack validation before publish

Example use cases

  • Create a workspace-aware CLI that resolves the correct project root and runs workspace-specific tasks
  • Implement a tool that reads JSON from stdin for use in Unix pipelines and prints pretty output when TTY
  • Diagnose and fix a global install where the binary is not in PATH or lacks executable bit
  • Split a large tool into multiple focused binaries (main, daemon, worker) to reduce memory and simplify testing
  • Add graceful CI-safe behavior: no spinners, deterministic defaults, and machine-readable output

FAQ

Ensure files use LF line endings, add binary: true in .gitattributes for CLI files, and validate the shebang after install with head -n1 $(which your-cli).

Which argument parser should I pick?

For tiny CLIs use Node's util.parseArgs; for most tools choose Commander for ergonomics, Yargs for advanced middleware, and prefer allowing unknown options in workspace contexts.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
cli-expert skill by cin12211/orca-q | VeilStrat