BigHugger
sk Skill · samber

golang-spf13-viper

Golang configuration library using spf13/viper — layered precedence (flag > env > file > KV > default), BindPFlag/BindPFlags, SetEnvPrefix + SetEnvKeyReplacer + AutomaticEnv, ReadInConfig + ConfigFileNotFoundError, Unmarshal + mapstructure struct tags, Sub for sub-trees, WatchConfig + OnConfigChange for hot reload, viper.New() for test isolation, and remote KV integration. Apply when using or adopting spf13/viper,…

installs 8w
3,631
30-day movement
starts with the next reading
Related entries
1
Connections
0
gobashGo

An agent skill (SKILL.md) covering spf13/viper, the Go configuration library that resolves values across layered sources with flag > env > file > KV > default precedence. It provides rules, pitfalls, and reference bundles on binding, env wiring, unmarshaling, sub-trees, hot reload, and test isolation.

Reach for it when writing or reviewing Go code that imports github.com/spf13/viper, since its pitfalls (env replacers, flag binding timing, global viper in tests) are easy to get wrong.

Use it to

  • Wire SetEnvPrefix, SetEnvKeyReplacer, and AutomaticEnv together
  • Bind cobra flags to viper in init or PersistentPreRunE
  • Unmarshal resolved config into structs with mapstructure tags
  • Handle ConfigFileNotFoundError and Sub nil-checks safely
  • Isolate viper state in tests with viper.New()

For Go developers configuring apps with spf13/viper

Host repository
samber/cc-skills-golang
Version
1.1.2
Installs, lifetime
35k
Installs, 8 weeks
3,631
Compatible with
Designed for Claude Code, Codex or similar harness, and for projects using Golang.
Licence
MIT
Invocable by
user
Host stars
3,261
Host language
Go
topicsgolangviperconfigurationenv-bindinghot-reloadtesting