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

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

Tu es un développeur Node.js senior spécialisé dans la création d'outils en ligne de commande. Crée un CLI complet en Node.js pour [DESCRIPTION DE L'OUTIL ET SON OBJECTIF PRINCIPAL].

Spécifications techniques :
- Nom du CLI : [NOM DU CLI]
- Runtime : Node.js (version 18+)
- Langage : [javascript|typescript]
- Gestionnaire de paquets : [npm|pnpm|yarn]

Fonctionnalités attendues :
1. Parsing des arguments et options avec une librairie moderne (commander, yargs ou meow)
2. Sous-commandes organisées logiquement selon les cas d'usage
3. Aide intégrée (--help) auto-générée pour chaque commande
4. Gestion des couleurs et du formatage terminal (chalk/picocolors)
5. Indicateurs de progression pour les opérations longues (ora/cli-progress)
6. Fichier de configuration (.rc ou .config.json) avec résolution hiérarchique
7. Gestion d'erreurs propre avec codes de sortie appropriés
8. Mode verbose/debug activable par flag

Livre les éléments suivants :
- Structure complète du projet avec arborescence des fichiers
- package.json configuré avec le champ "bin" et les métadonnées npm
- Code source de chaque fichier avec commentaires explicatifs
- Fichier README.md avec exemples d'utilisation
- Tests unitaires pour les commandes principales
- Instructions pour le développement local (npm link) et la publication npm

Respecte ces bonnes pratiques :
- Shebang #!/usr/bin/env node en tête du point d'entrée
- Séparation claire entre parsing CLI et logique métier
- Messages d'erreur explicites dirigés vers stderr
- Support des signaux (SIGINT/SIGTERM) pour un arrêt propre
- Code ESM (import/export) avec type: module dans package.json

Why this prompt works

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

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.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Similar Prompts

💻DeveloppementIntermediateAll AIs

Optimize Your Web Application Frontend Performance

A comprehensive prompt to audit and optimize web application frontend performance, covering bundle size, rendering, assets and Core Web Vitals.

0104
💻DeveloppementAdvancedClaude

Debug a Production Error

Quickly analyze a production error with a structured Root Cause Analysis approach and an immediate action plan.

47211
💻DeveloppementIntermediateGemini

Create a CLI Tool with Node.js

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

23224
💻DeveloppementIntermediateClaude

Complete Code Review for Pull Requests

Get an exhaustive code review covering quality, performance, security, and maintainability for any language.

34238