go-viper

Installation
SKILL.md

Use this skill to produce a clean Viper setup that reads configuration from file, flags, and environment with Viper's normal precedence:

  1. explicit Set
  2. flags
  3. environment variables
  4. config file
  5. remote key/value store
  6. defaults

Core approach

  • Prefer viper.New() over the package global; build one configured instance and pass it where needed.
  • Define a typed Config struct and unmarshal into it after all defaults, file paths, env bindings, and flag bindings are configured.
  • Keep configuration bootstrap in one place such as internal/config or pkg/config with a Load(...) function.
  • Treat the config file as optional only when the app design allows it; otherwise return a clear error.
  • Bind flags and env explicitly for important keys, and use AutomaticEnv() plus an env key replacer for the general case.

Clean Viper bootstrap

Related skills

More from aaronflorey/agent-skills

Installs
20
First Seen
Mar 17, 2026