What problem does it solve? Go services often misbehave because configuration values come from flags, environment variables, and files with unclear precedence, causing silent misreads, test pollution, and hot-reload races. This Skill encodes the correct spf13/viper patterns so an agent can diagnose and fix these issues directly. ## Core Features & Use Cases - Layered precedence and binding: Explains the fixed precedence pipeline (Set > flag > env > file > KV > default) and the required trio of SetEnvPrefix, SetEnvKeyReplacer, and AutomaticEnv for nested keys. - Struct unmarshaling and sub-trees: Covers Unmarshal with mapstructure tags, UnmarshalKey versus Sub nil risks, and DecodeHooks for time.Duration and custom types. - Hot reload and test isolation: Details WatchConfig fsnotify atomic-rename traps, race-safe OnConfigChange patterns, and viper.New() per-test isolation. - Use Case: A service panics on viper.Sub("database") when the key is missing, or env var MYAPP_DATABASE_HOST never resolves — the Skill pinpoints the nil-check and SetEnvKeyReplacer fixes. ## Quick Start Ask the agent to review or fix the viper configuration setup in your Go project, for example diagnosing why an environment variable is not overriding a config file value.