P
💻DeveloppementIntermediateGemini

Create a CLI Tool with Node.js

Create a professional Node.js CLI tool with Commander.js, Inquirer, visual feedback, and npm publishing.

Paste in your AI

Adapt this prompt

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

You are a Node.js expert specializing in building command-line tools. I want to create a CLI (Command Line Interface) that I can use in my terminal or share on npm.

CLI tool to create:
[describe the tool: e.g. React component generator, file migration tool, REST API client, deployment tool]

Required features:

  • Main commands: [list the commands: e.g. init, generate, deploy, status]
  • Arguments and options: [e.g. --output-dir, --format, --dry-run, --verbose]
  • Interactive user input: [e.g. ask for the project name, choose a template]
  • Output: [e.g. generated files, API calls, transformations]

Distribution:

  • Usage: [e.g. just for me, publish on npm, internal team use]
  • Support: [e.g. macOS + Linux only, cross-platform]

Build the complete CLI with:

  1. Project structure: file organization, package.json with the bin field, TypeScript configuration if applicable.
  2. Command parsing: use Commander.js or yargs to define commands, subcommands and options with automatic help.
  3. Interactivity: use Inquirer.js for interactive prompts (selection, confirmation, text input).
  4. Terminal UX: ora for loading spinners, chalk for colors, table for tabular displays.
  5. Error handling: clear, actionable errors for the user, verbose mode for debugging.
  6. Configuration: local config file (.myapp.json) with overridable default values.
  7. Tests: command tests with file system mocking.
  8. npm publishing: configuration to publish the package with the necessary files.

Personalize this prompt with Léa · AI assistant

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

This prompt covers the entire lifecycle of a professional CLI tool, from project structure to npm publishing. The distinction between positional arguments, options, and interactive prompts (Inquirer) is crucial for designing an ergonomic CLI UX. Investment in terminal UX (spinners, colors, tables) may seem cosmetic but is fundamental to adoption: a CLI tool with good visual feedback is perceived as faster and more reliable than one displaying raw text lines, even if performance is identical. Managing configuration via a local file (pattern of ~/.myapp.json or .myapp.json in the project) is a professional practice that allows users to persist their preferences without specifying them with every command, drastically reducing daily usage friction.

Use Cases

Creating internal development toolsPublishing CLI tools on npmAutomating team workflows

Expected Output

A complete Node.js CLI tool with commands, interactivity, visual feedback, configuration, and npm publishing setup.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateClaude

Task brief for Claude Code: frame a feature end to end

Brief template to delegate a complete feature to Claude Code: goal, starting point, constraints, definition of done, working rules and recap format.

1681
💻DeveloppementIntermediateClaude

Write a project's CLAUDE.md: the brief Claude Code reads at every session

Turns your project description into a dense CLAUDE.md: commands, structure, conventions, pitfalls, off-limits areas and situations where the agent must ask before acting.

640
💻DeveloppementAdvancedAll AIs

Design a Secure Webhook API

Design a webhook API with event subscriptions, signed deliveries, retry limits, and a delivery log your support team can inspect.

411
💻DeveloppementIntermediateAll AIs

Generate Storybook Stories for UI Components

Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.

474