Borrowing it
Nothing to install: this file belongs to castle-x/skills-x. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/castle-x/skills-x/main/.claude/skills/golang-cli-cobra-viper/SKILL.mdgit clone --depth 1 https://github.com/castle-x/skills-xWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/castle-x/skills-x/golang-cli-cobra-viper)<a href="https://agentmods.dev/skills/castle-x/skills-x/golang-cli-cobra-viper"><img src="https://agentmods.dev/badge/skills/castle-x/skills-x/golang-cli-cobra-viper/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/castle-x/skills-x/golang-cli-cobra-viper"><img src="https://agentmods.dev/badge/skills/castle-x/skills-x/golang-cli-cobra-viper.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00022 | $0.06950 |
| Opus 5.5 | $0.00009 | $0.02780 |
| Sonnet 5.5 | $0.00004 | $0.01390 |
| Haiku 4.5 | $0.00002 | $0.00695 |
Grade A, and why
golang-cli-cobra-viper scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
This is a copy
95% identical to golang-cli-cobra-viper — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 1,020 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Go CLI Development with Cobra & Viper
Overview
Cobra and Viper are the industry-standard libraries for building production-quality CLIs in Go. Cobra provides command structure and argument parsing, while Viper manages configuration from multiple sources with clear precedence rules.
Key Features:
- 🎯 Cobra Commands: POSIX-compliant CLI with subcommands (
app verb noun --flag) - ⚙️ Viper Config: Unified configuration from flags, env vars, and config files
- 🔄 Integration: Seamless Cobra + Viper plumbing patterns
- 🐚 Shell Completion: Auto-generated completions for bash, zsh, fish, PowerShell
- ✅ Production Ready: Battle-tested by kubectl, docker, gh, hugo
Used By: Kubernetes (kubectl), Docker CLI, GitHub CLI (gh), Hugo, Helm, and 100+ major projects
When to Use This Skill
Activate this skill when:
- Building multi-command CLI tools with subcommands
- Creating developer tools, project generators, or scaffolding utilities
- Implementing admin CLIs for services or infrastructure
- Requiring flexible configuration (flags > env vars > config files > defaults)
- Adding shell completion for frequently-used CLIs
- Building DevOps automation tools or deployment scripts
Cobra Framework
Command Structure Pattern
Cobra follows the APPNAME VERB NOUN --FLAG pattern popularized by git and kubectl.
// cmd/root.go
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var cfgFile string
var rootCmd = &cobra.Command{
Use: "myapp",
Short: "A powerful CLI tool for developers",
Long: `MyApp is a CLI tool that demonstrates best practices
for building production-quality command-line applications.
Complete documentation is available at https://myapp.example.com`,
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(initConfig)
// Persistent flags (available to all subcommands)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.myapp.yaml)")
rootCmd.PersistentFlags().Bool("verbose", false, "verbose output")
// Bind persistent flags to viper
viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
}
func initConfig() {
if cfgFile != "" {
viper.SetConfigFile(cfgFile)
} else {
home, err := os.UserHomeDir()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
viper.AddConfigPath(home)
viper.AddConfigPath(".")
viper.SetConfigType("yaml")
viper.SetConfigName(".myapp")
}
viper.SetEnvPrefix("MYAPP")
viper.AutomaticEnv()
if err := viper.ReadInConfig(); err == nil {
if viper.GetBool("verbose") {
fmt.Println("Using config file:", viper.ConfigFileUsed())
}
}
}
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 1,020 lines · 22 tokens per session scan A f83059e07fee
golang-cli-cobra-viper is a skill published in the GitHub repository castle-x/skills-x (18 stars, last pushed 1mo ago), licensed MIT. It adds 22 tokens to every session and 6,950 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 95% identical to golang-cli-cobra-viper, differing in 2 lines, and is treated as a copy.
golang-cli-cobra-viper compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| golang-cli-cobra-vipercastle-x/skills-x | Skill | 18 | 1mo ago | MIT | A | 22 | Claude Code |
| golang-cli-cobra-viperbobmatnyc/claude-mpm-skills | Skill | 79 | 4mo ago | MIT | A | 22 | Claude Code |
| printing-pressmvanhorn/cli-printing-press | Skill | 5.1k | today | MIT | A | 86 | Claude Code |
| goericrisco/rsc-harness | Skill | 682 | 4d ago | MIT | A | 86 | Claude Code, Codex |
| gographozgurcd/gograph | Skill | 234 | yesterday | MIT | A | 91 | Claude Code |
| go-127dimetron/pi-go | Skill | 232 | 6d ago | MIT | A | 177 | Claude Code, Codex |
| bubbletea-testingdimetron/pi-go | Skill | 232 | 6d ago | MIT | A | 139 | Claude Code, Codex |