citty

v0.2.2 MIT

Elegant CLI Builder

Weekly Downloads
15.8M
Stars
1.2K
Forks
47
Open Issues
50
Gzip Size
3.0 kB
Unpacked Size
34.6 kB
Dependencies
1
Last Updated
1mo ago

citty Download Trends

Download trends for citty021.0M42.0M62.9M83.9MFeb 2025MayAugNovFebApr 2026
citty

About citty

Citty is designed to streamline the creation of command-line interfaces (CLIs) with an elegant and developer-friendly API. It addresses the common challenge of building sophisticated command structures, argument parsing, and help message generation, allowing developers to focus on application logic rather than boilerplate CLI scaffolding. The package provides a declarative way to define commands, options, and arguments, making complex CLI applications more manageable.

Its core philosophy centers on simplicity, expressiveness, and a positive developer experience. Citty aims to be intuitive for developers familiar with modern JavaScript patterns, offering a clean syntax that leads to readable and maintainable CLI code. The primary audience includes developers building standalone CLI tools, task runners, or integration scripts that require a robust command-line interface.

The package employs a pattern-based approach to API definition. Developers can define commands using a fluent API, chaining methods to specify parameters, types, descriptions, and default values. This includes handling nested commands and subcommands effectively, mirroring the hierarchical nature of many CLI tools. Features like automatic type coercion and validation are built into the parsing process.

Citty integrates seamlessly into typical Node.js development workflows. It can be used to build CLIs that are invoked directly via `npx` or as part of larger application build processes. Its output can be easily consumed by shell scripts or other automated tasks, making it a versatile tool for developers working with the Node.js ecosystem.

With a weekly download count of 20.1 million and a compact unpacked size of 34.6 kB (3.0 kB gzip), Citty demonstrates excellent performance characteristics and a minimal footprint. Its small bundle size ensures that it adds negligible overhead to applications, which is crucial for CLI tools that need to start quickly. The project has accumulated 1.2K GitHub stars, indicating significant community interest and adoption.

While Citty offers a powerful set of features for building CLIs, developers should be aware of its specific API conventions. It is primarily focused on command-based CLIs; for applications requiring more complex interactive prompts or TUI elements, additional libraries might be necessary. The current open issue count of 49 suggests an active development and community engagement, but also indicates areas where further refinement might be ongoing.

When to use

  • When defining nested commands and subcommands with clear hierarchical structures using chained API calls.
  • When automatically generating help messages and argument validation based on declarative command definitions.
  • When needing robust argument parsing with automatic type coercion for common JavaScript types.
  • When building task runners or utility scripts that require multiple commands with distinct options.
  • When aiming for a concise and readable CLI definition that mirrors command structure closely.
  • When integrating CLI functionality into a Node.js project with minimal bundle size impact.

When NOT to use

  • If your CLI solely involves very basic argument parsing with no nested commands or complex options, a simpler approach might suffice.
  • If you require advanced interactive TUI elements like progress bars or complex dialogs, you will likely need to combine citty with other specialized libraries.
  • When building CLIs that are intended to be extremely small and have zero external dependencies beyond Node.js itself.
  • If your command-line tool primarily needs to execute single, straightforward commands without argument variations.
  • When the project mandates using a specific, different CLI building paradigm that does not align with citty's declarative, fluent API.

citty Alternatives

citty Categories