cobra-viper

cobra-viper is a skill for Claude Code from spf13/go-skills. It costs 104 tokens per session (5,252 once invoked), scanned A, original, MIT.

A guide to building command-line applications in Go with Cobra and Viper. Cobra handles commands, while Viper manages configuration such as environment variables; the guide also covers separating business logic and testing commands in memory.

In plain words
What is it for?
Use it when designing Go command-line tools, binding settings to environment variables, adding context-aware commands, or writing in-memory CLI tests.
Why use it?
It helps keep CLI code organized and makes configuration and command tests easier to manage.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the cobra-viper plugin — 1 skill shipped together

Good fit Use it when designing Go command-line tools, binding settings to environment variables, adding context-aware commands, or writing in-memory CLI tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/spf13/go-skills/cobra-viper
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add spf13/go-skills --skill cobra-viper
Clone the repo
git clone --depth 1 https://github.com/spf13/go-skills

Made for: Claude Code.

Or install cobra-viper, the plugin that ships this one along with the rest of its 1 skill.

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 cobra-viper

README.md
[![agentmods](https://agentmods.dev/badge/skills/spf13/go-skills/cobra-viper/github.svg)](https://agentmods.dev/skills/spf13/go-skills/cobra-viper)
Your own site
<a href="https://agentmods.dev/skills/spf13/go-skills/cobra-viper"><img src="https://agentmods.dev/badge/skills/spf13/go-skills/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 cobra-viper

Your own site · 80×15
<a href="https://agentmods.dev/skills/spf13/go-skills/cobra-viper"><img src="https://agentmods.dev/badge/skills/spf13/go-skills/cobra-viper.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 104 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,252 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 original No closer match found 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.00104 $0.05252
Opus 5.5 $0.00042 $0.02101
Sonnet 5.5 $0.00021 $0.01050
Haiku 4.5 $0.00010 $0.00525

Measured yesterday against content hash ba8c2a42d6af, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

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

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

Copies of this mod

1 near-identical copy found in the catalogue:

cobra-viper/SKILL.md · 507 lines

How it starts

The opening of the file, as written. The whole thing — 507 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Go CLI Architecture: Cobra & Viper

Idiomatic patterns and best practices for building robust, configuration-driven command-line interfaces using Cobra and Viper.

When to Activate

  • Writing a new CLI application in Go
  • Adding commands, subcommands, or flags to an existing Cobra application
  • Integrating Viper for configuration file, environment variable, or flag management
  • Reviewing or refactoring CLI code that uses Cobra and/or Viper
  • Designing the command structure or configuration schema for a CLI tool
  • Testing CLI commands

Core Philosophy

The Command-First Architecture

Treat your application binary as a router for commands. The CLI framework (Cobra) should solely handle flags, arguments, and routing. Your core business logic should remain completely unaware of the CLI layer, making it highly testable and reusable.

Unified Configuration

Configuration should be environment-aware and unified. Viper acts as the single source of truth, merging defaults, config files, environment variables, and command-line flags into a cohesive state before passing it to the application logic.

Commands Are Built, Not Declared

Construct the command tree with factory functions (NewRootCmd()), not package-level var declarations. Globals make commands untestable (state leaks between test runs) and unusable as a library. The only global in a well-built CLI is main.go calling the factory.

CLI Package Organization

Anti-Pattern: Hiding all your commands and core logic deep inside an internal/ directory tree, or shoving everything into main.go.

Discoverable, Flat Structures

Command routing and business logic should live in standard, logically named packages. The cmd/ package handles the CLI surface area, while other top-level packages handle the domain logic.

mycli/
├── main.go               # Minimal entry point: strictly calls cmd.Execute()
├── cmd/                  # The Cobra routing layer
│   ├── root.go           # Root command factory, global flags, Viper setup
│   ├── serve.go          # The 'serve' subcommand
│   └── build.go          # The 'build' subcommand
├── engine/               # Core business logic (name based on your domain)
│   ├── server.go
│   └── compiler.go
├── go.mod
└── go.sum

Read the full file on GitHub · 507 lines

Files

What ships with it

1 file 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. yesterday Changed · +15 lines ba8c2a42d6af
  2. 13d ago Changed · +45 lines 835fb38f07f5
  3. 2mo ago First seen · 447 lines · 104 tokens per session scan A e215454171a0

Subscribe to this mod's changes

cobra-viper is a skill published in the GitHub repository spf13/go-skills (697 stars, last pushed yesterday), licensed MIT. It adds 104 tokens to every session and 5,252 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

cobra-viper compared with skills from other repositories

cobra-viper next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cobra-viperspf13/go-skillsSkill697yesterdayMITA104Claude Code
golang-testingsamber/cc-skills-golangSkill3.8k5d agoMITA115Claude Code
golang-uber-fxsamber/cc-skills-golangSkill3.8k5d agoMITA122Claude Code
golang-samber-oopssamber/cc-skills-golangSkill3.8k5d agoMITA74Claude Code
ax-go-agent-optimizeax-llm/axSkill3.0ktodayApache-2.0A51Claude Code, Codex
golang-error-handlingsamber/cc-skills-golangSkill3.8k5d agoMITA144Claude Code
gmeasureonsi/gomegaSkill2.4k28d agoMITA129Claude Code