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.
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:
- Argument and option parsing with a modern library (commander, yargs, or meow)
- Subcommands organized logically by use case
- Built-in auto-generated help (--help) for each command
- Terminal color and formatting support (chalk/picocolors)
- Progress indicators for long-running operations (ora/cli-progress)
- Config file (.rc or .config.json) with hierarchical resolution
- Clean error handling with appropriate exit codes
- 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
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 OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Improve this prompt with the Optimizer
Analyze the prompt, strengthen the context and get a more precise version.
Prompt Engineering
Cross-model principles for writing more reliable prompts.
AI prompts for web developers
Code review and debugging, keeping API keys and secrets out of the prompt.
Security, GDPR & Business Plans
ChatGPT Business, Claude Team, Gemini Workspace and Mistral Vibe compared from vendor sources: training, EU hosting and a GDPR checklist.
Similar Prompts
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.
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.
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.
Generate Storybook Stories for UI Components
Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.