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.
Why this prompt works
<p>This prompt covers the entire lifecycle of a professional CLI tool, from project structure to npm publication. 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 for adoption: a CLI tool with good visual feedback is perceived as faster and more reliable than a tool that displays raw text lines, even if performance is identical.</p><p>Configuration management 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 each command, drastically reducing daily usage friction.</p>
Use Cases
Expected Output
A complete Node.js CLI tool with commands, interactivity, visual feedback, configuration and npm publishing setup.
Learn more
Check the full skill on Prompt Guide to master this technique from A to Z.
View on Prompt GuideGlossary Terms
Similar Prompts
Learn the basics of Git for beginners
Learn Git from scratch with illustrated explanations, concrete examples, a practical workflow and a cheatsheet of essential commands.
Define a Git strategy for a team
Define a comprehensive Git strategy adapted to your team: branching model, conventions, code review and release management.
Configure a CI/CD pipeline with GitHub Actions
Configure a professional CI/CD pipeline with GitHub Actions covering testing, security, Docker build and multi-environment deployment.
Write integration tests for an API
Create comprehensive API integration tests with database setup, authentication, CRUD and end-to-end scenarios.