dotnet-cli-architecture

Structure .NET CLI applications with Command/Handler/Service layers and clig.dev principles.

1|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-cli-architecture-rudironsoni
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-cli-architecture
Source: https://github.com/rudironsoni/dotnet-agent-harness/tree/main/.rulesync/skills/dotnet-cli-architecture
Command: npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-cli-architecture-rudironsoni

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a robust architectural pattern for .NET Command Line Interface (CLI) applications, ensuring maintainability, testability, and adherence to best practices.

Core Features & Use Cases

  • Layered Architecture: Implements Command/Handler/Service separation for clean code organization.
  • Configuration Management: Defines clear precedence for configuration sources (appsettings, environment variables, CLI arguments).
  • Standardized Output & Exit Codes: Adheres to clig.dev principles for human-first output, machine-readable formats, and consistent exit codes.
  • Use Case: Develop a new .NET CLI tool for managing cloud resources, ensuring it has a well-defined structure, handles configuration gracefully, and provides clear feedback to the user and any automation scripts that consume it.

Quick Start

Structure a new .NET CLI application using the Command/Handler/Service pattern.

Frequently Asked Questions about dotnet-cli-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a .NET CLI application for maintainability?

A .NET CLI architecture separates Command, Handler, and Service layers to organize code cleanly, ensure testability, and enforce maintainability. This structure isolates argument parsing from business logic, making the application easier to test and extend over time.

What is the best way to handle configuration precedence in dotnet command-line apps?

The best way to handle configuration precedence is defining a strict order across appsettings, environment variables, and CLI arguments. This ensures predictable runtime behavior where explicit command-line arguments override environment variables, which in turn override default appsettings file values.

How does System.CommandLine 2.0 work with a generic host in .NET?

System.CommandLine 2.0 integrates with the .NET generic host to provide structured dependency injection, configuration management, and logging alongside modern command parsing. This combination allows you to build robust, enterprise-grade CLI tools that follow standard application lifecycle patterns.

Why do my dotnet CLI tools need standardized exit codes and output formats?

Dotnet CLI tools need standardized exit codes and output formats to provide clear feedback to both human users and automation scripts. Adhering to clig.dev principles ensures your tool supports human-first output alongside machine-readable formats, making it reliable for CI/CD pipelines.

Can I use this Command/Handler/Service pattern for a new cloud resource management tool?

Yes, you can use this pattern for a new cloud resource management tool to guarantee a well-defined structure, graceful configuration handling, and clear user feedback. The layered architecture scales effectively for complex operations while maintaining strict testability and clean code organization.