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

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

Tu es un expert Node.js spécialisé dans la création d'outils en ligne de commande. Je veux créer un CLI (Command Line Interface) que je pourrai utiliser dans mon terminal ou partager sur npm.

Outil CLI à créer :
[DÉCRIRE_L_OUTIL: ex. générateur de composants React, outil de migration de fichiers, client pour une API REST, outil de déploiement]

Fonctionnalités requises :

  • Commandes principales : [LISTER_LES_COMMANDES: ex. init, generate, deploy, status]
  • Arguments et options : [EX: --output-dir, --format, --dry-run, --verbose]
  • Entrées utilisateur interactives : [EX: demander le nom du projet, choisir un template]
  • Sortie : [EX: fichiers générés, appels API, transformations]

Distribution :

  • Usage : [EX: uniquement pour moi, publier sur npm, usage interne d'équipe]
  • Support : [EX: macOS + Linux uniquement, cross-platform]

Crée le CLI complet avec :

  1. Structure du projet : organisation des fichiers, package.json avec bin field, configuration TypeScript si applicable.
  2. Parsing des commandes : utilise Commander.js ou yargs pour définir les commandes, sous-commandes et options avec aide automatique.
  3. Interactivité : utilise Inquirer.js pour les prompts interactifs (sélection, confirmation, entrée texte).
  4. UX du terminal : ora pour les spinners de chargement, chalk pour les couleurs, table pour les affichages tabulaires.
  5. Gestion des erreurs : erreurs claires et actionnables pour l'utilisateur, mode verbose pour le debug.
  6. Configuration : fichier de configuration local (.myapp.json) avec valeurs par défaut overridables.
  7. Tests : tests des commandes avec mocking du système de fichiers.
  8. Publication npm : configuration pour publier le package avec les fichiers nécessaires.
100% found this useful

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>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.</p><p>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.</p><p>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.</p>

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

  • LéaAI

    Pour les tests, utilise `execa` pour simuler les appels en ligne de commande plutôt que de mocker `fs` directement : plus proche de l'expérience réelle. Ajoute un mode `--quiet` pour désactiver les couleurs et spinners, utile en CI.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementBeginnerAll AIs

Convert CSS to Tailwind

Migrate styling to Tailwind

090
💻DeveloppementIntermediateAll AIs

Refactor legacy code to modern patterns

Gradually modernizing legacy code

0100
💻DeveloppementIntermediateGemini

Gemini Prompt for Generating SQL Queries

Gemini, Google's artificial intelligence model, excels at generating SQL queries through its deep understanding of data structures and database syntax. Whether you are working with MySQL, PostgreSQL, SQL Server or SQLite, Gemini can transform your natural language descriptions into optimized and functional SQL queries. This capability is particularly valuable for developers looking to speed up their workflow, data analysts handling complex datasets, and beginners learning SQL. By providing a well-structured prompt to Gemini, you not only get the desired query but also explanations of the logic used, optimization suggestions, and alternatives based on your database management system. The prompt engineering approach allows you to guide Gemini to take into account your specific constraints: performance, readability, compatibility with a particular DBMS, or adherence to your organization's naming conventions. Discover how to formulate your prompts to get the most out of Gemini in generating SQL queries.

0112
💻DeveloppementIntermediateAll AIs

Implement secrets management

Secure credentials management

0102