skills-x: Skill for Claude Code

.claude/skills/golang-cli-cobra-viper/SKILL.md

golang-cli-cobra-viper is a skill for Claude Code from castle-x/skills-x. It costs 22 tokens per session (6,950 once invoked), scanned A, a copy of golang-cli-cobra-viper, MIT.

A guide to building command-line programs in Go using Cobra for commands and Viper for settings. Command-line programs are tools people run by typing commands in a terminal.

In plain words
What is it for?
Use it for developer tools, project generators, administration tools, infrastructure tools, and other Go programs with terminal commands and configurable behavior.
Why use it?
It helps organize tools with multiple commands and handle settings from flags, environment variables, and configuration files consistently.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is castle-x/skills-x's own configuration. It tells Claude Code how to work on skills-x itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything skills-x configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/castle-x/skills-x/main/.claude/skills/golang-cli-cobra-viper/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/castle-x/skills-x

Made for: Claude Code.

Wrote 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.

agentmods badge for golang-cli-cobra-viper

README.md
[![agentmods](https://agentmods.dev/badge/skills/castle-x/skills-x/golang-cli-cobra-viper/github.svg)](https://agentmods.dev/skills/castle-x/skills-x/golang-cli-cobra-viper)
Your own site
<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.

agentmods 80×15 button for golang-cli-cobra-viper

Your own site · 80×15
<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>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,950 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 95% copy Near-identical to another mod in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00022 $0.06950
Opus 5 $0.00011 $0.03475
Sonnet 5 $0.00004 $0.01390
Haiku 4.5 $0.00002 $0.00695

Measured 12d ago against content hash f83059e07fee, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

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 12d 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.

Origin

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.

.claude/skills/golang-cli-cobra-viper/SKILL.md · 1,020 lines

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())
        }
    }
}

Read the full file on GitHub · 1,020 lines

Files

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.

Changes

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.

  1. 12d ago First seen · 1,020 lines · 22 tokens per session scan A f83059e07fee

Subscribe to this mod's changes

golang-cli-cobra-viper is a skill published in the GitHub repository castle-x/skills-x (18 stars, last pushed 4mo ago), licensed MIT. It adds 22 tokens to every session and 6,950 once invoked, about $0.0001 per session on Opus 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.

Related

Other skills, from other repositories

golang-cli-cobra-viper

Building production-quality CLI tools with Cobra command framework and Viper configuration management.

bobmatnyc/claude-mpm-skills · 22 tokens

printing-press-polish

Polish a generated CLI to pass verification and become publish-ready. Runs diagnostics (dogfood, verify, scorecard, go vet, gosec), automatically fixes all issues (verify failures, static-analysis findings, dead code, descriptions, README, MCP tool quality), reports the before/after delta, and offers to publish. Use…

mvanhorn/cli-printing-press · 125 tokens

printing-press

Set up a new integration, connector, or CLI binding for any API. Wrap or generate a ship-ready Go CLI from an OpenAPI, HAR, or Postman spec via the lean research -> generate -> build -> shipcheck loop. Use when the user says build a CLI, wrap this API, set up a new integration, add a connector, integrate with a…

mvanhorn/cli-printing-press · 86 tokens

gograph

Go repository intelligence for Claude Code. Use when reading, navigating, editing, reviewing, or refactoring a Go codebase. Exposes 64 query, analysis, and workflow capabilities through the local gograph MCP server, including bounded first-call exploration, AST-aware call graphs, blast-radius analysis, impact, and…

ozgurcd/gograph · 69 tokens

go-127

What changed in Go 1.27 (released August 2026) and how it changes the way Go is written in pi-go. Use this skill when writing or reviewing Go that could use a 1.27 feature, when bumping the go directive in go.mod, when a build or test behaves differently after a toolchain upgrade, or when code-guidelines-go points…

dimetron/pi-go · 177 tokens

bubbletea-testing

Use this skill whenever writing tests for Bubble Tea (charmbracelet/bubbletea) TUI applications in Go. Triggers include any mention of testing Bubble Tea models, teatest, golden file testing for TUIs, testing tea.Cmd or tea.Msg, snapshot testing terminal output, or writing tests for any Go CLI/TUI that uses the Elm…

dimetron/pi-go · 139 tokens