MCP HubMCP Hub
Вернуться к навыкам

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

vamseeachanta
Обновлено Today
11 просмотров
3
2
3
Посмотреть на GitHub
Другоеgeneral

О программе

Этот навык позволяет парсить конфигурационные файлы YAML в bash-скриптах с использованием yq при его наличии, с резервным вариантом через jq для JSON-совместимых подмножеств YAML. Он предоставляет стандартизированный метод загрузки YAML-конфигураций в формате JSON для единообразной обработки в различных инструментах. Используйте его, когда вашим bash-скриптам необходимо чтение YAML-конфигураций в средах, где могут быть доступны yq или jq.

Быстрая установка

Claude Code

Рекомендуется
Основной
npx skills add vamseeachanta/workspace-hub
Команда плагинаАльтернативный
/plugin add https://github.com/vamseeachanta/workspace-hub
Git клонированиеАльтернативный
git clone https://github.com/vamseeachanta/workspace-hub.git ~/.claude/skills/json-config-loader-6-yaml-configuration-via-yq

Скопируйте и вставьте эту команду в Claude Code для установки этого навыка

Документация

6. YAML Configuration (via yq)

6. YAML Configuration (via yq)

Parse YAML files when yq is available:

#!/bin/bash
# ABOUTME: YAML configuration parsing with yq
# ABOUTME: Falls back to jq for JSON subset of YAML

# Check for yaml parser
get_yaml_parser() {
    if command -v yq &> /dev/null; then
        echo "yq"
    elif command -v jq &> /dev/null; then
        echo "jq"  # Can parse YAML's JSON subset
    else
        echo "none"
    fi
}

# Load YAML config
load_yaml_config() {
    local file="$1"
    local parser
    parser=$(get_yaml_parser)

    if [[ ! -f "$file" ]]; then
        echo "{}"
        return 1
    fi

    case "$parser" in
        yq)
            yq -o=json "$file" 2>/dev/null || echo "{}"
            ;;
        jq)
            # Try to parse as JSON (YAML subset)
            jq '.' "$file" 2>/dev/null || echo "{}"
            ;;
        *)
            echo "Error: No YAML parser available (install yq or jq)" >&2
            echo "{}"
            return 1
            ;;
    esac
}

# Get YAML value (returns as JSON for jq processing)
yaml_get() {
    local file="$1"
    local path="$2"
    local default="${3:-}"

    local parser
    parser=$(get_yaml_parser)

    local value
    case "$parser" in
        yq)
            value=$(yq -r "$path // \"$default\"" "$file" 2>/dev/null)
            ;;
        jq)
            value=$(jq -r "$path // \"$default\"" "$file" 2>/dev/null)
            ;;
        *)
            value="$default"
            ;;
    esac

    if [[ -z "$value" || "$value" == "null" ]]; then
        echo "$default"
    else
        echo "$value"
    fi
}

# Usage
CONFIG_FILE="config.yaml"

# Load entire config as JSON
CONFIG_JSON=$(load_yaml_config "$CONFIG_FILE")

# Or get specific values
DB_HOST=$(yaml_get "$CONFIG_FILE" '.database.host' 'localhost')
DB_PORT=$(yaml_get "$CONFIG_FILE" '.database.port' '5432')

echo "Database: $DB_HOST:$DB_PORT"

GitHub репозиторий

vamseeachanta/workspace-hub
Путь: .claude/skills/_core/bash/json-config-loader/6-yaml-configuration-via-yq

Похожие навыки

algorithmic-art

Мета

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.

Просмотреть навык

subagent-driven-development

Разработка

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.

Просмотреть навык

executing-plans

Дизайн

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.

Просмотреть навык

cost-optimization

Другое

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.

Просмотреть навык