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

Sub-skill of json-config-loader: 5. Environment Variable Configuration.

5 stars

Best use case

json-config-loader-5-environment-variable-configuration is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of json-config-loader: 5. Environment Variable Configuration.

Teams using json-config-loader-5-environment-variable-configuration should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/5-environment-variable-configuration/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_core/bash/json-config-loader/5-environment-variable-configuration/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/5-environment-variable-configuration/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

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

Feature / Agentjson-config-loader-5-environment-variable-configurationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of json-config-loader: 5. Environment Variable Configuration.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 5. Environment Variable Configuration

## 5. Environment Variable Configuration


Load configuration with environment variable overrides:

```bash
#!/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)"
```

Related Skills

toml-section-scoping-config-debug

5
from vamseeachanta/workspace-hub

Diagnose TOML config errors caused by misplaced keys in table sections

portable-config-baseline-pattern

5
from vamseeachanta/workspace-hub

Extract machine-agnostic settings into portable template files while keeping machine-specific hooks and plugins separate

portable-baseline-configuration-pattern

5
from vamseeachanta/workspace-hub

Separate portable/universal config from machine-specific settings to enable safe template reuse across environments

portable-baseline-config-pattern

5
from vamseeachanta/workspace-hub

Separate machine-portable baseline config from environment-specific hooks and plugins

large-parallel-planning-wave-environment-failure-handoff

5
from vamseeachanta/workspace-hub

Handle large pre-plan-review planning waves that succeed analytically but fail to persist artifacts due to quota exhaustion, sandbox write failures, or cancelled GitHub mutations.

codex-skill-loader-broken-symlink-recovery

5
from vamseeachanta/workspace-hub

Diagnose Codex startup failures in workspace-hub caused by a broken `.Codex/skills/skills` symlink and recover without misattributing the failure to issue scope.

orcaflex-environment-config

5
from vamseeachanta/workspace-hub

Configure OrcaFlex environmental conditions including wave spectra (JONSWAP, Dean Stream), current profiles, wind loading, and seabed properties for offshore analysis.

hermes-config-audit-gotchas

5
from vamseeachanta/workspace-hub

Audit Hermes custom config keys and migrated skill settings safely, with verified command behavior and stale-path checks.

hermes-local-configuration

5
from vamseeachanta/workspace-hub

Class-level Hermes local configuration and setup workflows, including config audit gotchas and Windows installation.

mkdocs-8-plugin-configuration

5
from vamseeachanta/workspace-hub

Sub-skill of mkdocs: 8. Plugin Configuration (+4).

json-config-loader-6-yaml-configuration-via-yq

5
from vamseeachanta/workspace-hub

Sub-skill of json-config-loader: 6. YAML Configuration (via yq).

json-config-loader-4-multi-section-ini-parsing

5
from vamseeachanta/workspace-hub

Sub-skill of json-config-loader: 4. Multi-Section INI Parsing.