home / skills / hoangnguyen0403 / agent-skills-standard / configuration
This skill helps you apply 12-Factor, typed config, and secret management guidelines across languages, loading env vars and validating config.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill configurationReview the files below or copy the command above to add this skill to your agents.
---
name: Configuration
description: Standards for application configuration using environment variables and libraries.
metadata:
labels: [golang, config, env, viper]
triggers:
files: ['configs/**', 'cmd/**']
keywords: [configuration, env var, viper, koanf]
---
# Golang Configuration Standards
## **Priority: P1 (STANDARD)**
## Principles
- **12-Factor App**: Store config in environment variables.
- **Typed Config**: Load config into a struct, validate it immediately.
- **Secrets**: Never commit secrets. Use env vars or secret managers.
- **No Globals**: Return a Config struct and inject it.
## Libraries
- **Standard Lib**: `os.Getenv` for simple apps.
- **Viper**: Industry standard for complex configs (supports env, config files, remote config).
- **Koanf**: Lighter, cleaner alternative to Viper.
- **Caarlos0/env**: Good for strict struct tagging.
## Pattern
1. Define `Config` struct.
2. Load from defaults.
3. Override from file (optional).
4. Override from Env (priority).
5. Validate.
## References
- [Config Pattern](references/config-patterns.md)
This skill codifies standards for application configuration using environment variables and proven libraries across languages and frameworks. It emphasizes typed configuration, immediate validation, secret handling, and dependency injection to keep apps predictable and secure. The guidance is practical and implementation-focused for TypeScript and other ecosystems.
The skill inspects configuration handling patterns and recommends a consistent flow: define a typed Config object, load defaults, optionally read files, override from environment variables, then validate. It flags anti-patterns like global config, committed secrets, and unvalidated values, and suggests libraries appropriate for app complexity. Implementation notes include recommended libraries (lightweight and full-featured) and clear validation steps.
Should I ever use global variables for configuration?
Avoid globals. Return a typed Config and inject it where needed; this improves testability and limits hidden dependencies.
Which library should I choose for Go?
Use the standard library for simple apps, Koanf for a lightweight approach, and Viper when you need rich features like remote config and multiple file formats.