1
---
2
name: configuration-management
3
description: >
4
Manage application configuration including environment variables, settings
5
management, configuration hierarchies, secret management, feature flags, and
6
12-factor app principles. Use for config, environment setup, or settings
7
management.
8
---
9
10
# Configuration Management
11
12
## Table of Contents
13
14
- [Overview](#overview)
15
- [When to Use](#when-to-use)
16
- [Quick Start](#quick-start)
17
- [Reference Guides](#reference-guides)
18
- [Best Practices](#best-practices)
19
20
## Overview
21
22
Comprehensive guide to managing application configuration across environments, including environment variables, configuration files, secrets, feature flags, and following 12-factor app methodology.
23
24
## When to Use
25
26
- Setting up configuration for different environments
27
- Managing secrets and credentials
28
- Implementing feature flags
29
- Creating configuration hierarchies
30
- Following 12-factor app principles
31
- Migrating configuration to cloud services
32
- Implementing dynamic configuration
33
- Managing multi-tenant configurations
34
35
## Quick Start
36
37
Minimal working example:
38
39
```bash
40
# .env.development
41
NODE_ENV=development
42
PORT=3000
43
DATABASE_URL=postgresql://localhost:5432/myapp_dev
44
REDIS_URL=redis://localhost:6379
45
LOG_LEVEL=debug
46
API_KEY=dev-api-key-12345
47
48
# .env.production
49
NODE_ENV=production
50
PORT=8080
51
DATABASE_URL=${DATABASE_URL} # From environment
52
REDIS_URL=${REDIS_URL}
53
LOG_LEVEL=info
54
API_KEY=${API_KEY} # From secret manager
55
56
# .env.test
57
NODE_ENV=test
58
DATABASE_URL=postgresql://localhost:5432/myapp_test
59
LOG_LEVEL=error
60
```
61
62
## Reference Guides
63
64
Detailed implementations in the `references/` directory:
65
66
| Guide | Contents |
67
|---|---|
68
| [Environment Variables](references/environment-variables.md) | Environment Variables |
69
| [Configuration Hierarchies](references/configuration-hierarchies.md) | Configuration Hierarchies |
70
| [Secret Management](references/secret-management.md) | Secret Management |
71
| [Feature Flags](references/feature-flags.md) | Feature Flags |
72
| [12-Factor App Configuration](references/12-factor-app-configuration.md) | 12-Factor App Configuration |
73
| [Configuration Validation](references/configuration-validation.md) | Configuration Validation |
74
| [Dynamic Configuration (Remote Config)](references/dynamic-configuration-remote-config.md) | Dynamic Configuration (Remote Config) |
75
76
## Best Practices
77
78
### ✅ DO
79
80
- Store configuration in environment variables
81
- Use different config files per environment
82
- Validate configuration on startup
83
- Use secret managers for sensitive data
84
- Never commit secrets to version control
85
- Provide sensible defaults
86
- Document all configuration options
87
- Use type-safe configuration objects
88
- Implement configuration hierarchy (base + overrides)
89
- Use feature flags for gradual rollouts
90
- Follow 12-factor app principles
91
- Implement graceful degradation for missing config
92
- Cache secrets to reduce API calls
93
94
### ❌ DON'T
95
96
- Hardcode configuration in source code
97
- Commit .env files with real secrets
98
- Use different config formats across services
99
- Store secrets in plain text
100
- Expose configuration through APIs
101
- Use production credentials in development
102
- Ignore configuration validation errors
103
- Access process.env directly everywhere
104
- Store configuration in databases (circular dependency)
105
- Mix configuration with business logic
106