MCP HubMCP Hub
Zurück zu Fähigkeiten

json-config-loader-5-environment-variable-configuration

vamseeachanta
Aktualisiert Today
9 Ansichten
3
2
3
Auf GitHub ansehen
Anderegeneral

Über

Diese Fähigkeit ermöglicht die Überschreibung von Umgebungsvariablen beim Laden von JSON-Konfigurationen, sodass Entwickler Umgebungseinstellungen über dateibasierte Werte priorisieren können. Sie bietet eine Bash-Implementierung, die Konfigurationen aus Dateien lädt, während sie präfixierte Umgebungsvariablen als höherpriorisierte Überschreibungen unterstützt. Verwenden Sie dies, wenn Sie flexible Konfigurationsverwaltung benötigen, bei der umgebungsspezifische Einstellungen die Standarddateikonfigurationen überschreiben sollen.

Schnellinstallation

Claude Code

Empfohlen
Primär
npx skills add vamseeachanta/workspace-hub
Plugin-BefehlAlternativ
/plugin add https://github.com/vamseeachanta/workspace-hub
Git CloneAlternativ
git clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/json-config-loader-5-environment-variable-configuration

Kopieren Sie diesen Befehl und fügen Sie ihn in Claude Code ein, um diese Fähigkeit zu installieren

Dokumentation

5. Environment Variable Configuration

5. Environment Variable Configuration

Load configuration with environment variable overrides:

#!/bin/bash
# ABOUTME: Configuration with environment variable overrides
# ABOUTME: File config < Environment variable precedence

declare -A APP_CONFIG

# Load config with env override support
load_config_with_env() {
    local file="$1"
    local prefix="${2:-APP_}"  # Environment variable prefix

    # First load from file
    if [[ -f "$file" ]]; then
        while IFS= read -r line || [[ -n "$line" ]]; do
            [[ "$line" =~ ^[[:space:]]*# ]] && continue
            [[ -z "${line// /}" ]] && continue

            if [[ "$line" =~ ^([^=]+)=(.*)$ ]]; then
                local key="${BASH_REMATCH[1]}"
                local value="${BASH_REMATCH[2]}"

                key="${key#"${key%%[![:space:]]*}"}"
                key="${key%"${key##*[![:space:]]}"}"

                APP_CONFIG["$key"]="$value"
            fi
        done < "$file"
    fi

    # Override with environment variables
    for key in "${!APP_CONFIG[@]}"; do
        local env_key="${prefix}${key^^}"  # Convert to UPPER_CASE
        env_key="${env_key//-/_}"          # Replace - with _

        if [[ -v "$env_key" ]]; then
            APP_CONFIG["$key"]="${!env_key}"
        fi
    done
}

# Check required config keys
require_config() {
    local missing=()

    for key in "$@"; do
        if [[ -z "${APP_CONFIG[$key]:-}" ]]; then
            missing+=("$key")
        fi
    done

    if [[ ${#missing[@]} -gt 0 ]]; then
        echo "Error: Missing required configuration:" >&2
        printf "  - %s\n" "${missing[@]}" >&2
        return 1
    fi

    return 0
}

# Get config with type conversion
config_string() {
    local key="$1"
    local default="${2:-}"
    echo "${APP_CONFIG[$key]:-$default}"
}

config_int() {
    local key="$1"
    local default="${2:-0}"
    local value="${APP_CONFIG[$key]:-$default}"

    if [[ "$value" =~ ^-?[0-9]+$ ]]; then
        echo "$value"
    else
        echo "$default"
    fi
}

config_bool() {
    local key="$1"
    local default="${2:-false}"
    local value="${APP_CONFIG[$key]:-$default}"

    case "${value,,}" in
        true|yes|1|on) echo "true" ;;
        false|no|0|off) echo "false" ;;
        *) echo "$default" ;;
    esac
}

# Usage
load_config_with_env "app.conf" "MYAPP_"

# Check required keys
require_config "api_key" "database_url" || exit 1

# Access with type conversion
PORT=$(config_int "port" 8080)
DEBUG=$(config_bool "debug" false)
API_KEY=$(config_string "api_key")

echo "Starting on port $PORT (debug: $DEBUG)"

GitHub Repository

vamseeachanta/workspace-hub
Pfad: .claude/skills/_core/bash/json-config-loader/5-environment-variable-configuration

Verwandte Skills

algorithmic-art

Meta

This Claude Skill creates original algorithmic art using p5.js with seeded randomness and interactive parameters. It generates .md files for algorithmic philosophies, plus .html and .js files for interactive generative art implementations. Use it when developers need to create flow fields, particle systems, or other computational art while avoiding copyright issues.

Skill ansehen

subagent-driven-development

Entwicklung

This skill executes implementation plans by dispatching a fresh subagent for each independent task, with code review between tasks. It enables fast iteration while maintaining quality gates through this review process. Use it when working on mostly independent tasks within the same session to ensure continuous progress with built-in quality checks.

Skill ansehen

executing-plans

Design

Use the executing-plans skill when you have a complete implementation plan to execute in controlled batches with review checkpoints. It loads and critically reviews the plan, then executes tasks in small batches (default 3 tasks) while reporting progress between each batch for architect review. This ensures systematic implementation with built-in quality control checkpoints.

Skill ansehen

cost-optimization

Andere

This Claude Skill helps developers optimize cloud costs through resource rightsizing, tagging strategies, and spending analysis. It provides a framework for reducing cloud expenses and implementing cost governance across AWS, Azure, and GCP. Use it when you need to analyze infrastructure costs, right-size resources, or meet budget constraints.

Skill ansehen