A Node script becomes an executable CLI with a shebang line (`#!/usr/bin/env node`) at the top, executable permissions, and a `"bin"` field in `package.json` mapping a command name to the script — `npm link` or a global install then makes it runnable by name.
js
#!/usr/bin/env node
const args = process.argv.slice(2);
const command = args[0];
if (command === "balance") {
const address = args[1];
console.log(`checking balance for ${address}`);
} else {
console.log("usage: mytool balance <address>");
process.exit(1);
}json
{ "bin": { "mytool": "./cli.js" } }For anything beyond trivial argument parsing, libraries like `commander` or `yargs` handle flags, subcommands, help text and validation far more robustly than hand-rolled `process.argv` slicing.