P
💻DeveloppementIntermediateAll AIs

Create a Professional Node.js CLI Tool from A to Z

A prompt to generate a complete Node.js command-line tool, from architecture to npm deployment, with argument handling, colors and configuration.

Paste in your AI

Adapt this prompt

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

You are a senior Node.js developer specializing in building command-line tools. Build a complete Node.js CLI for [tool description and its main purpose].

Technical specifications:

  • CLI name: [CLI name]
  • Runtime: Node.js (version 18+)
  • Language: [javascript|typescript]
  • Package manager: [npm|pnpm|yarn]

Expected features:

  1. Argument and option parsing with a modern library (commander, yargs, or meow)
  2. Subcommands organized logically by use case
  3. Built-in auto-generated help (--help) for each command
  4. Terminal color and formatting support (chalk/picocolors)
  5. Progress indicators for long-running operations (ora/cli-progress)
  6. Config file (.rc or .config.json) with hierarchical resolution
  7. Clean error handling with appropriate exit codes
  8. Verbose/debug mode toggled by a flag

Deliver the following:

  • Complete project structure with a file tree
  • package.json configured with the "bin" field and npm metadata
  • Source code for each file with explanatory comments
  • README.md file with usage examples
  • Unit tests for the main commands
  • Instructions for local development (npm link) and npm publishing

Follow these best practices:

  • #!/usr/bin/env node shebang at the top of the entry point
  • Clear separation between CLI parsing and business logic
  • Explicit error messages sent to stderr
  • Signal support (SIGINT/SIGTERM) for a clean shutdown
  • ESM code (import/export) with type: module in package.json

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 guides the AI to produce a professional, publish-ready Node.js CLI. By specifying the tool description and its name, you get a structured project with argument parsing, subcommands, color handling and configuration file — all the standards expected of a good terminal tool. The strength of this prompt lies in the separation it enforces between CLI parsing (arguments, options, help) and business logic. This architecture makes the code testable and maintainable. The required unit tests ensure each command works correctly before publishing. Adapt the variables to your needs: choose TypeScript for a robust project with autocompletion, or JavaScript for quick prototyping. The prompt also covers often-forgotten steps like • Configuring the bin field in package.json • Local development with npm link • Proper system signal handling to avoid zombie processes

Use Cases

Create a scaffolding tool to generate projects from templatesDevelop an internal deployment CLI to automate production releasesBuild a data migration tool between databases or APIs

Expected Output

A complete Node.js CLI project with file tree, commented source code, configured package.json, unit tests and npm publishing instructions. The code is modular, follows ESM conventions and includes error handling and system signal management.

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