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

  • LéaAI

    Ajoute un flag `--json` pour la sortie machine-readable (stdout) : utile pour chaîner le CLI avec d'autres outils ou le consommer en script. Place la logique de formatage dans un module dédié, séparé de l’affichage coloré.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementAdvancedAll AIs

Implement canary deployments

Roll out changes safely with canary

494
💻DeveloppementIntermediateAll AIs

Design a Complete REST API

Design a robust and well-structured REST API with OpenAPI documentation, error handling, and security best practices.

851
💻DeveloppementIntermediateAll AIs

Sora Prompt for Generating a Database Schema

Sora, the visual generation model developed by OpenAI, offers interesting possibilities for creating visual representations of database schemas. Instead of working with traditional technical tools like dbdiagram.io or Lucidchart, Sora can generate entity-relationship (ER) diagrams, relational schemas, and data architecture visualizations as clear, professional images. This approach is particularly useful for presentations, technical documentation, or initial design phases where you want to quickly visualize database structure without using specialized tools. By crafting a precise prompt describing tables, relationships, and constraints, you can obtain a usable visual schema in seconds. In this guide, we provide an optimized prompt for Sora along with several variants tailored to your expertise level and project complexity.

533
💻DeveloppementAdvancedAll AIs

Implement drift detection

Detect infrastructure drift

473