Create application configuration manager
✓Works with OpenClaudeYou are a backend developer building a robust configuration management system. The user wants to create an application configuration manager that handles environment-specific settings, validation, and runtime updates.
What to check first
- Determine if you need environment variable support, file-based config, or both
- Check what configuration values need validation (e.g., port numbers, URLs, API keys)
- Verify if you need hot-reload capability or if config is loaded once at startup
Steps
- Create a
Configclass that loads settings from environment variables and defaults - Define a schema object with all required config keys and their types
- Implement validation logic in the constructor to check types and required fields
- Add a
get()method for type-safe config value retrieval - Create a
validate()static method that checks all values against the schema - Implement an
update()method for runtime configuration changes (optional) - Export a singleton instance so the entire app uses the same config object
- Add logging when config is loaded and when invalid values are detected
Code
class ConfigManager {
constructor(schema = {}, envPrefix = 'APP_') {
this.schema = schema;
this.envPrefix = envPrefix;
this.config = {};
this.load();
}
load() {
for (const [key, definition] of Object.entries(this.schema)) {
const envKey = `${this.envPrefix}${key.toUpperCase()}`;
const envValue = process.env[envKey];
const value = envValue !== undefined ? this.coerce(envValue, definition.type) : definition.default;
if (definition.required && value === undefined) {
throw new Error(`Missing required config: ${key} (env: ${envKey})`);
}
if (value !== undefined && definition.validate && !definition.validate(value)) {
throw new Error(`Invalid config value for ${key}: ${value}`);
}
this.config[key] = value;
}
console.log(`✓ Configuration loaded (${Object.keys(this.config).length} keys)`);
}
coerce(value, type) {
if (type === 'number') return Number(value);
if (type === 'boolean') return value === 'true' || value === '1';
if (type === 'json') return JSON.parse(value);
return value;
}
get(key, defaultValue = undefined) {
if (!(key in this.config)) {
if (defaultValue !== undefined) return defaultValue;
throw new Error(`Config key not found: ${key}`);
}
return this.config[key];
}
getAll() {
return { ...this.config };
}
set(key, value) {
if (!(key in this.schema)) {
throw new Error(`Unknown config key: ${key}`);
}
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related General / Utility Skills
Other Claude Code skills in the same category — free to download.
Env Setup
Set up development environment from scratch
Gitignore Generator
Generate .gitignore for any project type
NPM Publish
Prepare and publish npm package
Error Boundary
Create error boundary components
Feature Flag
Implement feature flag system
Date Time Helper
Create date/time utility functions
String Utils
Create string manipulation utilities
File Utils
Create file system utility functions
Want a General / Utility skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.