system-commandline-cli

Implements and reviews .NET CLI commands built with System.CommandLine.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill system-commandline-cli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: system-commandline-cli
Source: https://github.com/github/awesome-copilot/tree/main/skills/system-commandline-cli
Command: npx skills add https://github.com/github/awesome-copilot --skill system-commandline-cli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building a consistent, well-structured command-line interface in .NET requires many architectural decisions: command hierarchies, option validation, dependency injection, and naming conventions. This Skill enforces proven patterns for System.CommandLine v2.x so every command follows the same structure without repeated design work.

Core Features & Use Cases

  • Command Architecture Patterns: Provides rules for command base classes, command groups with subcommands, and registration in RootCommand.
  • Options, Arguments & Validation: Covers defining options and arguments, global recursive options, and validator-based input checking that fails before handlers run.
  • DI-Based Handler Design: Enforces thin handlers that delegate business logic to injected service interfaces registered in Program.cs.
  • Use Case: When asked to add a new verb like agent create to an existing .NET CLI, the Skill produces an internal command class with kebab-case naming, described options, an async SetAction handler, and proper registration in the parent command.

Quick Start

Add a new subcommand called 'list' to the config command group in my System.CommandLine project following the established conventions.

Frequently Asked Questions about system-commandline-cli

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

FAQPage Schema
How do I create a new CLI command with System.CommandLine?

Create an internal class inheriting from Command or a project CommandBase, pass the name and description to the base constructor, add options and arguments, then wire the handler with this.SetAction(CommandHandler). Register the command in RootCommand or a parent group command.

How do I add subcommands in System.CommandLine?

Create a parent group command that adds children via this.Subcommands.Add(new ChildCommand()) in its constructor. The group command typically does not call SetAction, though a command may define both an action and subcommands when direct invocation is meaningful.

Which .NET versions does System.CommandLine support?

System.CommandLine v2.x targets .NET 8 or later and any .NET Standard 2.0 implementation, including .NET Framework 4.6.1 or later and .NET Core 2.0 or later.

How do I validate global options in System.CommandLine?

Define the option once in a static GlobalOptions class, set Recursive = true, add it only to RootCommand.Options, and add validation to the option's Validators collection. Invalid input then becomes a parse error and the command handler is never invoked.

Should command handlers contain business logic in System.CommandLine?

No. Handlers should be thin: parse input, validate configuration, call an injected service interface, and output results. Business logic belongs in service classes registered via dependency injection in Program.cs, not in the command itself.