Yargs

Feature-rich command-line argument parser for Node.js. Yargs parses process.argv with automatic --help generation, command routing (git-style subcommands), positional argument handling, type coercion, validation, and tab completion. Used for building production CLIs where the argument parsing complexity justifies a full framework over minimist.

Evaluated Mar 06, 2026 (0d ago) v17.x
Homepage ↗ Repo ↗ Developer Tools cli arguments parsing node options commands help validation
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
94
/ 100
Is it safe for agents?
⚡ Reliability
88
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
82
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
82
Secret Handling
85

Local CLI library. Argument values from untrusted users should be validated — Yargs provides schema validation but additional business logic validation is the developer's responsibility.

⚡ Reliability

Uptime/SLA
100
Version Stability
85
Breaking Changes
80
Error Recovery
85
AF Security Reliability

Best When

Building a feature-rich Node.js CLI tool with multiple subcommands, validation, and automatic help generation.

Avoid When

Your CLI has 1-3 simple flags — minimist or commander.js are lighter weight for simple argument parsing.

Use Cases

  • Build agent CLI tools with git-style subcommands (agent run, agent list, agent configure) using Yargs command routing
  • Generate automatic --help output for agent CLIs with argument descriptions, defaults, and usage examples without manual documentation
  • Validate CLI arguments with Yargs built-in validators — required args, type checking, mutual exclusivity (demandOption, conflicts, implies)
  • Add shell tab completion to agent CLI tools using Yargs completion generator that works with bash/zsh
  • Read defaults from config files and environment variables alongside CLI args using Yargs config() and env() integration

Not For

  • Simple scripts with 1-2 options — use minimist or process.argv directly for trivial argument parsing
  • Deno or browser environments — Yargs is Node.js specific; use std/flags for Deno
  • Interactive prompts — use Inquirer.js for interactive CLI prompts; Yargs handles only argument parsing

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — local CLI library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Yargs is open source and free.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Yargs 17+ is ESM-compatible but the .cjs build is the default for CJS projects — use 'import yargs from yargs/yargs' pattern for ESM
  • Command handlers run asynchronously but yargs.parse() doesn't await them by default — use await yargs.parseAsync() for async command handlers
  • Camelcase conversion of --kebab-case options to camelCase is on by default — option 'my-flag' is accessible as argv.myFlag not argv['my-flag']
  • Positional arguments and options can conflict when using variadic positionals — test argument edge cases where positionals might be mistaken for option values
  • yargs.strict() fails on unknown options but command routing must be set up first — call .strict() after all commands are defined, not before
  • Global options added before .command() are inherited by subcommands — options added after are command-local; ordering matters for option inheritance

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for Yargs.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered