What problem does it solve? Go developers building command-line tools with spf13/cobra often misuse its API — writing manual argument checks inside RunE, printing to os.Stdout so tests cannot capture output, or losing the root command's PersistentPreRunE when a child command overrides it. This Skill encodes the correct patterns for command trees, hooks, flags, completions, and testing so generated cobra code follows the library's intended design. ## Core Features & Use Cases - Command tree and hook wiring: Guides correct use of RunE over Run, the PersistentPreRunE → PreRunE → RunE → PostRunE → PersistentPostRunE chain, and the child-replaces-parent hook inheritance trap. - Args validators and flag constraints: Covers built-in validators (ExactArgs, OnlyValidArgs, MatchAll composition) and parse-time flag rules like MarkFlagsMutuallyExclusive, MarkFlagsRequiredTogether, and MarkFlagsOneRequired. - Shell completions and testing: Explains ValidArgsFunction, RegisterFlagCompletionFunc, ShellCompDirective values, and test isolation via fresh command trees with SetArgs/SetOut/SetErr. - Use Case: When adding a delete <resource> subcommand to a Go CLI, the Skill directs you to declare Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs) instead of hand-rolled length checks, and to write output through cmd.OutOrStdout() so tests can capture it. ## Quick Start Ask the assistant to add a new cobra subcommand with argument validation, flags, and tests to your Go CLI project.