{
 "kind": "tool",
 "slug": "yargs",
 "path": "tools/yargs/",
 "name": "yargs",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Dev workflow and config",
   "tools/dev-workflow/"
  ]
 ],
 "lead": "Options, help and errors for command-line tools.",
 "chips": [
  {
   "label": "Dev workflow and config",
   "path": "tools/dev-workflow/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install yargs"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/yargs/yargs"
  },
  {
   "label": "Website",
   "href": "https://yargs.js.org/"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy",
   "note": "Paid and closed-source products may use it; no fee and no on-screen credit needed.",
   "src": "https://github.com/yargs/yargs/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change today",
   "note": "Latest GitHub release Sep 20, 2026. ",
   "src": "https://github.com/yargs/yargs"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "32 projects",
   "status": "info",
   "sub": "#41 of 299 in its category",
   "note": "Dependency in 32 public GitHub projects set up for AI coding agents that we scanned (0.5%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What yargs does",
   "parts": [
    {
     "t": "prose",
     "text": "yargs is a free JavaScript package for Node.js that reads the words typed after a command, such as --port 8080. You list your options once; yargs turns what the person typed into named values, prints a help screen and reports typos. It can also read chat-bot commands, not only terminal input."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Flags for your project scripts",
       "text": "The build, import or seed script your AI assistant writes gets --port, --open or --dry-run flags with defaults, so you change behaviour without editing code.",
       "idea": false
      },
      {
       "title": "Slash commands in a chat bot",
       "text": "Your Slack or Discord bot reads messages like \"resize cat.jpg -w 640\" and answers with the help text or a clear error when the message is wrong.",
       "idea": false
      },
      {
       "title": "Catch typos in options",
       "text": "A mistyped option such as --widht stops the tool with a clear message instead of being quietly ignored.",
       "idea": false
      },
      {
       "title": "Check values before the work starts",
       "text": "Stop the tool early when a value makes no sense, such as a port that is not a number, with your own message.",
       "idea": false
      },
      {
       "title": "Settings from environment variables",
       "text": "On a server, the same options can come from settings such as MY_PROGRAM_FRUIT_THING instead of typed flags.",
       "idea": false
      },
      {
       "title": "Tab completion in the terminal",
       "text": "People who use your tool press Tab to finish command and option names in bash, zsh or fish.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "yargs popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "71",
       "of": "/ 100",
       "l": "Gid Score, #329 overall"
      },
      {
       "n": "393M",
       "l": "downloads a week, npm"
      },
      {
       "n": "11.5K",
       "l": "GitHub stars"
      },
      {
       "n": "32",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How yargs is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "yargs is a dependency in 32 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.7% of the 4,867 JavaScript/TypeScript ones), #41 of 299 in dev workflow and config.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 98; those are left out of every share on this page.",
      "The most used alternative in our scan is Commander (174 projects).",
      "Projects that use it most often also use tsx (50.0%), chalk (31.2%), TypeScript (81.2%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "18 projects, 0.7%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "18 projects, 0.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "13 projects, 0.4%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 50.0% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 31.2% of its projects",
       "v": "chalk",
       "path": "tools/chalk/"
      },
      {
       "l": "In 81.2% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 62.5% of its projects",
       "v": "ESLint",
       "path": "tools/eslint/"
      },
      {
       "l": "In 40.6% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 46.9% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 25.0% of its projects",
       "v": "Babel (JavaScript)",
       "path": "tools/babel-npm/"
      },
      {
       "l": "In 25.0% of its projects",
       "v": "glob",
       "path": "tools/glob/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about yargs",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/shadowspawn",
        "thanks.dev: https://thanks.dev/u/gh/shadowspawn",
        "Tidelift: https://tidelift.com/funding/github/npm/yargs",
        "4 GitHub sponsors"
       ]
      },
      {
       "title": "More in Dev workflow and config",
       "path": "tools/dev-workflow/",
       "items": [
        {
         "text": "dotenv",
         "path": "tools/dotenv/"
        },
        {
         "text": "Husky",
         "path": "tools/husky/"
        },
        {
         "text": "python-dotenv",
         "path": "tools/python-dotenv/"
        },
        {
         "text": "lint-staged",
         "path": "tools/lint-staged/"
        },
        {
         "text": "concurrently",
         "path": "tools/concurrently/"
        },
        {
         "text": "Rich",
         "path": "tools/rich/"
        },
        {
         "text": "Pydantic Settings",
         "path": "tools/pydantic-settings/"
        },
        {
         "text": "cross-env",
         "path": "tools/cross-env/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "yargs",
       "me": true,
       "facts": [
        "MIT",
        "Gid 71",
        "393M/wk"
       ]
      },
      {
       "name": "Commander",
       "why": "Pick Commander when you prefer its style of declaring commands and options; it is another complete toolkit for Node.js command-line programs.",
       "path": "tools/commander/",
       "facts": [
        "MIT",
        "Gid 82",
        "788M/wk"
       ]
      },
      {
       "name": "Click",
       "why": "Pick Click when your tool is written in Python rather than JavaScript.",
       "path": "tools/click-py/",
       "facts": []
      }
     ],
     "more": "Compare yargs with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use the npm package yargs (pin yargs@18.2.0, Node.js 20.19+ or 22.12+, ES modules) to give this script --port and --dry-run options with defaults, a --help screen and .strict() so mistyped options fail."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add yargs to your Node.js project (Node.js 20.19+, 22.12+ or 23+ for version 18).",
       "code": "npm i yargs",
       "src": "https://github.com/yargs/yargs/blob/main/README.md"
      },
      {
       "text": "Parse what was typed after the script name; hideBin drops the first two entries of process.argv for you.",
       "code": "import yargs from 'yargs';\nimport {hideBin} from 'yargs/helpers';\nconst argv = yargs(hideBin(process.argv)).parse();\n",
       "src": "https://github.com/yargs/yargs/blob/main/README.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "const argv = require('yargs').argv (yargs 17 and older examples)",
       "fix": "import yargs from 'yargs'; import {hideBin} from 'yargs/helpers'; const argv = yargs(hideBin(process.argv)).parse()",
       "why": "yargs 18 is ES modules first and removed the global yargs.argv shortcut."
      },
      {
       "dont": "Installing yargs 18 on Node.js 18 or 20.0-20.18",
       "fix": "Use Node.js 20.19+ or 22.12+, or stay on yargs 17.7.x for older Node.js",
       "why": "Version 18 raised the minimum Node.js versions."
      },
      {
       "dont": "Leaving out .strict(), so --widht 640 is quietly accepted",
       "fix": "Add .strict() (or .strictOptions()) so unknown options are reported as errors",
       "why": "Without it, a mistyped option just becomes an extra value; in our run .strict() turned it into \"Unknown argument widht\"."
      },
      {
       "dont": "Trusting type: 'number' to reject text such as --port eighty",
       "fix": "Add .check(argv => Number.isInteger(argv.port) || 'port must be a whole number')",
       "why": "In our run --port eighty gave NaN with no error; only the .check() rule stopped it."
      },
      {
       "dont": "import Yargs from 'https://unpkg.com/yargs@…/browser.mjs' in a production web page",
       "fix": "Bundle yargs/browser with your build tool, or map the two unpkg.com addresses it imports to local copies",
       "why": "The browser entry imports cliui and yargs-parser straight from unpkg.com at run time."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I still use require('yargs') and yargs.argv from old examples?",
       "a": "Not as before. Version 18 is ES modules first and removed the yargs.argv shortcut; use import and yargs(hideBin(process.argv)).parse().",
       "evidence": {
        "url": "https://github.com/yargs/yargs/blob/main/CHANGELOG.md",
        "quote": "singleton usage of yargs yargs.foo, yargs().argv, has been removed."
       }
      },
      {
       "q": "Does it work outside the terminal?",
       "a": "Yes. Pass the text to parse() with a callback and yargs returns the values and any help or error text instead of printing it, which suits chat bots.",
       "evidence": {
        "url": "https://github.com/yargs/yargs/blob/main/docs/api.md",
        "quote": "output: any text that would have been output by yargs to the terminal, had a callback not been provided."
       }
      },
      {
       "q": "Does it come with TypeScript types?",
       "a": "The types live in the separate @types/yargs package.",
       "evidence": {
        "url": "https://github.com/yargs/yargs/blob/main/README.md",
        "quote": "npm i @types/yargs --save-dev"
       }
      },
      {
       "q": "Which value wins if a setting comes from both a flag and an environment variable?",
       "a": "The typed flag wins, then the environment variable, then a config file, then the default.",
       "evidence": {
        "url": "https://github.com/yargs/yargs/blob/main/docs/api.md",
        "quote": "Program arguments are defined in this order of precedence"
       }
      },
      {
       "q": "Can I use it in a paid product?",
       "a": "Yes. It is MIT licensed; keep the license notice with its files.",
       "evidence": {
        "url": "https://github.com/yargs/yargs/blob/main/LICENSE",
        "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy"
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm yargs"
  ],
  [
   "Category",
   "Dev workflow and config"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "71.4"
  ],
  [
   "Rank in category",
   "#41 of 299"
  ],
  [
   "GitHub",
   "yargs/yargs"
  ],
  [
   "Last change",
   "Nov 17, 2026"
  ]
 ],
 "good": [
  "Version 18 needs Node.js 20.19 or newer (or 22.12 or newer on the 22 line) and is built for ES modules first.",
  "Version 18 removed the old shortcut yargs.argv that many older examples still use.",
  "By default yargs ends the program after printing help, the version or an error; turn that off inside servers and bots."
 ],
 "checked_line": "Read by AgentGid from 10 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/yargs.png"
}