Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
General / UtilityintermediateNew

Config Manager

Share

Create application configuration manager

Works with OpenClaude

You 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

  1. Create a Config class that loads settings from environment variables and defaults
  2. Define a schema object with all required config keys and their types
  3. Implement validation logic in the constructor to check types and required fields
  4. Add a get() method for type-safe config value retrieval
  5. Create a validate() static method that checks all values against the schema
  6. Implement an update() method for runtime configuration changes (optional)
  7. Export a singleton instance so the entire app uses the same config object
  8. 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

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
generalconfigmanagement

Install command:

curl -o ~/.claude/skills/config-manager.md https://claude-skills-hub.vercel.app/skills/general/config-manager.md

Related General / Utility Skills

Other Claude Code skills in the same category — free to download.

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.