← ClaudeAtlas

golang-spf13-viperlisted

Maintain layered configuration when `github.com/spf13/viper` is already used or explicitly selected. Covers source precedence, environment and pflag binding, typed unmarshalling, isolated instances, and validated reloads; use a general configuration or CLI skill when Viper is absent.
reagin/agent-skills · ★ 0 · AI & Automation · score 63
Install: claude install-skill reagin/agent-skills
# Viper configuration Preserve the application's documented keys, source precedence, defaults, decoding, validation, and reload behavior. ## Inspect before editing Check `go.mod`, whether code uses a dedicated `*viper.Viper` or the global instance, enabled sources, key aliases, environment normalization, flag bindings, decode hooks, validation, reload, remote providers, and tests. Verify API and precedence details against the selected version and local wrappers. ## Source and key contract Viper's documented precedence is explicit `Set`, flags, environment, config files, remote key/value stores, then defaults. Preserve the sources the application actually enables and test conflicts at the boundaries that matter. - Treat key spelling, prefixing, case handling, and separators as compatibility-sensitive. - Configure environment prefixes or replacers only when the application's key-to-environment mapping needs them; they are not universally required. - Bind flags before the first lookup or decode that depends on their values. This can be during construction or a hook, depending on the program's actual order. - A missing config file is ignorable only when the product contract says the file is optional. Distinguish not-found from parse, permission, and validation errors. - Do not assume `AutomaticEnv` makes every environment-only key appear during struct unmarshalling. Register or bind the expected key set as needed by the selected version and cover env-only decoding in tests.