58. Minimal Dependencies for CLI
Status: Accepted Date: 2025-07-06
Context
The Command-Line Interface (CLI) is a crucial tool for developers and operators for debugging, maintenance, and automation. To be effective, a CLI needs to be fast, reliable, and easy to use. Loading it with numerous third-party dependencies can make it slow to start, prone to dependency conflicts, and increase its security footprint.
Decision
The mercury-cli module will adhere to a strict Minimal Dependencies policy. The CLI application's own dependencies will be kept to the absolute minimum required for its function.
The core dependencies will be:
- A command-line argument parsing library (e.g.,
commander). - The necessary NestJS libraries to bootstrap the main application context (
@nestjs/core).
Any other dependency must be strongly justified. The goal is a CLI that starts instantly and has a very small, manageable set of its own dependencies. Note that this policy applies to the CLI application wrapper itself; the CLI will, by design, load the entire NestJS application and all its dependencies in order to function (adr://direct-system-access). The focus here is on not adding additional, unnecessary dependencies just for the CLI's own logic.
Consequences
Positive:
- Fast Startup Time: A minimal CLI starts faster, which is critical for a good user experience and for use in scripts.
- High Reliability: Fewer dependencies mean fewer things that can break or cause conflicts.
- Enhanced Security: A minimal dependency set reduces the attack surface for the CLI tool itself.
- Low Maintenance: Less time is spent updating and managing dependencies for the CLI.
Negative:
- Fewer Bells and Whistles: We might forego "nice-to-have" CLI features like complex interactive prompts, colorful output, or elaborate tables if they require adding large, new dependencies.
- More Boilerplate Code: Some utility functions that could be imported might need to be written from scratch.
Mitigation:
- Focus on Function over Form: The primary goal of this CLI is powerful, scriptable functionality, not a beautiful user interface. We will prioritize raw utility over polished presentation. Standard console output is sufficient.
- Leverage Existing Utilities: If a utility function is needed, we will first look for it within our own shared libraries or the NestJS ecosystem before considering a new third-party library.
- Pragmatism: As with
adr://minimal-dependencies-ai, this is a guiding principle. A small, high-quality library that provides significant, necessary functionality can still be approved after careful consideration.