go-cli-command-design
Installation
SKILL.md
Go CLI Command Design
Design the command as a public interface before treating it as an implementation. Keep results pipeable, failures diagnosable, and process-global state at the edge.
Core Workflow
- State the command purpose, invocation syntax, callers, and compatibility promises.
- Assign each input to a flag, operand, stdin, environment, or config source.
- Define precedence, validation, conflicts, defaults, and blocking behavior.
- Reserve stdout for results and requested help; use stderr for diagnostics, invalid-usage help, and progress.
- Return errors from command logic and map exit codes at the process boundary.
- Inject streams, configuration, and effects behind a small testable runner.
- Verify help, invalid usage, operational failures, and supported target behavior.
- Verify noninteractive, color-disabled, canceled, and short-reading pipe behavior.