·
Last changedVersion:
This version passed the hardening gate. Hardening applied 16 targeted changes and preserved all other text. Classified findings before hardening: 1. Classified findings closed: 0. Classified findings remaining: 1. Unclassified scanner findings remaining: 0. Review findings closed: 15. Review findings remaining: 1.
1
1
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Excessive Agency & Rogue Autonomy | — | Medium | Open |
1 finding
You are working on a .NET CLI application built with System.CommandLine v2.x.x, targeting .NET 8 or later or any .NET Standard 2.0 implementation, including .NET Framework 4.6.1 or later and .NET Core 2.0 or later. Follow these rules and patterns when creating or modifying CLI commands, unless the project already has established conventions or security practices, in which case preserve them. Pin one exact stable release of System.CommandLine in the project, using a lock file or central package management, and prefer currently supported runtimes such as .NET 8 or later for new work. The .NET Standard 2.0 compatibility above describes the library, not a recommendation to target out-of-support runtimes.
Prefer defining a project-specific abstract CommandBase that inherits from System.CommandLine.Command. Concrete commands should inherit from this base class so shared behavior and conventions remain centralized.
When the project already has a command base class, preserve its established conventions. Otherwise, introduce one when commands need shared behavior; simple applications may inherit from Command directly when a base class adds no meaningful value.
Validate file arguments before use: add a validator to the argument's Validators collection that rejects missing files, resolve the value to a full canonical path, and where a base directory applies, reject paths that resolve outside it, including through symbolic links.
Reading an omitted optional option or argument returns null or the default value. Declare optional options with nullable types and handle the missing case in the handler; mark options that must be supplied as Required.
Handlers are async methods wired via SetAction:
Pass the cancellation token to every awaited service call. When a handler awaits nothing, return a completed task instead of marking the method async. Redact keys, tokens, authorization headers, and other sensitive fields from results, service responses, and exception messages before writing them to the console.
A group command registers children but does not call SetAction:
A command may define both an action and subcommands when the direct invocation has meaningful behavior.
Top-level commands → register in RootCommand.cs:
Subcommands → register inside the parent command's constructor:
If the project defines its own root command class, give it a name distinct from the library's root command type, or fully qualify the library type, so the two types are not confused.
Accept only the answers the prompt advertises, and compare the answer case-insensitively and culture-invariantly. Read confirmation only from an interactive console; when input is redirected or not interactive, stop with a non-zero exit code unless the user passed an explicit confirmation option on the command line. Adapt the sample so a cancelled operation returns a non-zero exit code that is distinct from success.
The logic of each command should be in one or more service classes that implement interfaces. The command receives interfaces through dependency injection (DI), not concrete implementations. The command handler should not contain business logic. The command handler should be thin, responsible only for:
Service class should be injected in the command constructor via DI, not instantiated directly.
Services are registered in Program.cs:
Add a convenience extension in ServiceProviderExtensions.cs:
Use this extension only in composition-root code at the program entry point. Commands receive services through constructor parameters as described in RULE 7, so construct commands that need services through the service container, or have the parent command pass their services in when it creates them.
| Element | Convention | Example |
|---|---|---|
CLI command name | lowercase kebab-case |
|
Command class | PascalCase + |
|
Option field |
|
|
Option long name |
|
|
Option short alias |
|
|
Argument field |
|
|
Namespace |
|
|
Folder |
|
|
internal.Define options shared by the entire command tree once in GlobalOptions.cs. Reuse the same
Option<T> instance when registering, validating, and reading the option.
Expose repeated parsing or conversion through protected CommandBase helpers:
Consume those helpers from the leaf command's handler. The command must not add the global options to its own
Options collection; recursive registration on the root already makes them available in its ParseResult.
Read a global option directly in a leaf handler only when no shared conversion or fallback logic is needed.
Always use the static GlobalOptions symbol; never create a second Option<T> with the same aliases.
Follow these requirements:
Recursive = true so the option is accepted for every descendant command.RootCommand.Options; do not duplicate it on leaf commands.CommandBase helper.Validators collection so invalid input becomes a parse error and
the command handler is not invoked. Do not rely on exceptions from new Uri(...) or downstream services.https URIs. Allow http only for local loopback development behind an explicit opt-in, and send the key only to https endpoints. Default the endpoint to a trusted value defined by the project, optionally restrict hosts to a configured allow list, and require explicit user confirmation before sending a key to a host other than the default. Reject unsupported schemes,
relative URIs, query strings, and fragments because appending a fixed endpoint path would change their meaning.--key, allow omission but reject an explicitly supplied blank or
whitespace-only value. Validate the value without logging, displaying, trimming, or otherwise mutating it.
Secrets passed on the command line are visible in process listings, shell history, and CI logs, so prefer a
source outside the command line that the project already supports and keep the option as a discouraged fallback.
Apply the blank value check to every source, and keep the secret out of validation messages, help output, and logs.When creating a new command, verify:
name, description to baseDescription, Requiredthis.SetAction(CommandHandler)async Task<int> CommandHandler(ParseResult, CancellationToken)internalCommands/<Group>/ folderMyProject.Commands.<Group>Get started with chainctlchainctl skill install public/github/system-commandline-cli:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.chainreg.biz/public/github.com/github/skills/system-commandline-cli:latest
MIT
HARDENING.md
LICENSE
SKILL.md