golang-spf13-cobra Skill for Claude: What It Does and How to Install It
Makes Claude build Go command-line tools with spf13/cobra: command trees, flags, completions and tests.
- Installs
- 37.9K
- on skills.sh
- Stars
- 3.7K
- on GitHub
- Files
- 6
- besides SKILL.md
- Updated
- Nov 2026
- last repo commit
This skill covers spf13/cobra. Claude designs the user-facing command surface first, then puts behavior in the right hook, such as RunE instead of Run and PersistentPreRunE for shared setup.
It covers argument validators, persistent and local flags, command groups, shell completion, help templates, man-page and markdown docs, and testing with SetArgs, SetOut and SetErr. It loads when your code imports github.com/spf13/cobra.
Good for
- Go developers building a command-line tool
- Teams adding subcommands, flags and shell completion
- Anyone testing cobra commands without running the binary
Install golang-spf13-cobra
Claude Code
- 1
Copy this prompt.
Install the golang-spf13-cobra skill in Claude Code. Run this command: npx skills add https://github.com/samber/cc-skills-golang --skill golang-spf13-cobra Then check that it loaded and tell me how to use it.
- 2
Paste it into Claude Code. It shows the change and asks before running it.
Requires Node.js.
From its listing on skills.sh. Source.
What's in the skill
When it loads
Golang CLI command tree library using spf13/cobra — cobra.Command, RunE vs Run, PersistentPreRunE hook chain, Args validators (NoArgs, ExactArgs, MatchAll, custom), persistent vs local flags, command groups, ValidArgsFunction, RegisterFlagCompletionFunc, ShellCompDirective, usage/help template customization, man-page and markdown doc generation, and testing with SetArgs/SetOut/SetErr. Apply when using or adopting spf13/cobra, or when the codebase imports `github.com/spf13/cobra`. For configuration layering alongside cobra, see the `samber/cc-skills-golang@golang-spf13-viper` skill. For general CLI architecture (project layout, exit codes, signal handling, I/O patterns), see `samber/cc-skills-golang@golang-cli`.
Sections in SKILL.md
- Cobra vs. viper
- Command tree
- The Run\ family
- Args validators
- Flags primer
- Completions primer
- Testing commands
- Best Practices
- Common Mistakes
- Further Reading
- Cross-References
Key facts
- Author
- samber
- License
- MIT
- Installs on skills.sh
- 37,923 (Nov 2, 2026)
- Last repo commit
- Nov 1, 2026
- Skill version
- 1.1.2
- Library version covered
- 1.10.2
What it includes
Three ways SKILL.md works on a CLI
Build creates a CLI from scratch. Extend adds subcommands, flags or completions after reading the current command tree. Review audits an existing CLI against the Common Mistakes table.
Write ·
Build, Extend and Review modesWhere command parsing ends and config begins
Cobra owns the command tree, flags, argument checks and completions. Viper handles configuration values. The skill points to the viper skill for the combined setup.
Try: “Add a deploy subcommand with a required --env flag to this cobra CLI.”
Read ·
Cobra vs viperRoot, subcommands and command groups
Designs the command hierarchy and the help users see.
Write ·
Command treeRunE vs Run and the PersistentPreRunE chain
Covers RunE versus Run and the hook chain that runs before a command.
Write ·
The Run familyNoArgs, ExactArgs, MatchAll and custom
Checks positional arguments before your code runs.
Write ·
Args validatorsPersistent vs local flags
Reference guide in references/flags.md.
Write ·
FlagsValidArgsFunction and RegisterFlagCompletionFunc
Shell completion, with a reference guide in references/completions.md.
Write ·
CompletionsMan pages and markdown docs
Man pages, markdown, YAML and RST docs, plus the cobra-cli scaffolder. Details are in references/generators.md.
Write ·
Docs generationSetArgs, SetOut and SetErr
Runs commands in-process and checks output. Reference guide in references/testing.md.
Write ·
Testing commands
From the official docs
Permissions
Low risk
What it can do
- Read your data
- Create and change things
- Delete things
- Read-only mode
Watch out for
It lists git and shell commands as allowed tools
The allowed-tools line covers any go, golangci-lint and git command (git:*), not just read ones. Keep Claude Code's permission prompts on for git commands that change history. github.com
It may fetch web pages or query Context7
It lists WebFetch and the Context7 tools as allowed. Library names and questions can leave your machine. Do not put secrets in prompts about this code. github.com
It adds cobra to your go.mod
The skill's install step runs go get for the cobra module. Check go.mod and go.sum in the diff. github.com
The scaffolder installs a tool and writes files
references/generators.md shows go get -tool github.com/spf13/cobra-cli@latest, then go tool cobra-cli init and add. These change go.mod and create files. Review the diff before committing. github.com
Security advisories
No published security advisories as of Nov 2, 2026.
Technical details
| Turning on read-only | No read-only mode in SKILL.md. Use version control. |
|---|---|
| Talks to | WebFetch is listed as an allowed tool. Library lookups go to Context7 if the Context7 MCP server is installed (the skill uses it as a fallback). Installing the library with go get downloads the module |
| Sign-in and keys | SKILL.md does not mention any account or key. |
| Scopes |
|
Questions
What does the golang-spf13-cobra skill do?
It teaches Claude to build command-line tools in Go with cobra. That covers the command tree, flags, argument validation, shell completion, docs and tests.
How do I install golang-spf13-cobra?
Use the install box at the top of this page. It is a text skill with reference guides, so there is nothing to compile. Start a new session so it loads, then work in a Go project.
cobra skill vs viper and CLI skills?
This skill is about cobra itself. The description sends you to golang-spf13-viper for configuration layering and to golang-cli for general CLI architecture such as project layout, exit codes and signal handling.
Does it need other skills from the same repo?
SKILL.md does not list any other skill as required. SKILL.md points to related skills in samber/cc-skills-golang for side topics, and the README says installing only a subset gives a partial and possibly inconsistent view of the guidelines. For best results it recommends installing the general-purpose Go skills together.
Is golang-spf13-cobra safe?
Mostly, for your own Go projects. It is instructions plus reference files, and it lets Claude edit files and run go and git commands. Review diffs, keep the project under version control and avoid secrets in prompts.
Does golang-spf13-cobra work in Codex, Cursor or the Claude app?
It is designed for Claude Code, Codex or a similar tool, and the README says the skills are built for Claude Code, Codex, Gemini, Copilot, Antigravity and Cursor. Because it works on your Go files and uses the go command, use a coding tool rather than the Claude app.
Information
updated Nov 2, 2026
- Repository
- samber/cc-skills-golang
- Folder
skills/golang-spf13-cobra
Sources
Docs, issue trackers and discussions this page is built from.
Show all 3Hide
- golang-spf13-cobra SKILL.md · github.com
- cc-skills-golang README · github.com
- golang-spf13-cobra generators.md · github.com