yq

xdg's avatarfrom xdg

Extract specific fields from YAML files efficiently using qq instead of reading entire files, saving 80-95% context.

⭐2stars🔀0forks📁View on GitHub🕐Updated Nov 23, 2025

When & Why to Use This Skill

The yq Claude skill is a high-performance YAML query and extraction tool designed to optimize AI context management. By retrieving only specific fields instead of processing entire files, it reduces context window usage by 80-95%. This tool is essential for developers and DevOps engineers working with large configuration files, enabling efficient data transformation, filtering, and deep-nested querying without hitting token limits.

Use Cases

  • Efficiently extracting specific service ports, volumes, or environment variables from large docker-compose.yml files.
  • Retrieving specific job steps or secret references from complex GitHub Actions and CI/CD workflow configurations.
  • Querying and inspecting nested resource limits, image tags, or metadata within massive Kubernetes (K8s) manifest files.
  • Filtering structured YAML data to provide the AI agent with only the necessary parameters for debugging or architectural analysis.
  • Automating the extraction of versioning and dependency information from configuration files to save token costs during large-scale code reviews.
nameyq
descriptionExtract specific fields from YAML files efficiently using qq instead of reading entire files, saving 80-95% context.

yq: YAML Query and Extraction Tool

Use yq to extract specific fields from YAML files without reading entire file contents, saving 80-95% context usage.

When to Use yq

Use yq when:

  • Need specific field(s) from structured YAML file
  • File is large (>50 lines) and only need subset of data
  • Querying nested structures in YAML
  • Filtering/transforming YAML data
  • Working with docker-compose.yml, GitHub Actions workflows, K8s configs

Just use Read when:

  • File is small (<50 lines)
  • Need to understand overall structure
  • Making edits (need full context anyway)

Tool Selection

JSON files → Use jq

  • Common: package.json, tsconfig.json, lock files, API responses

YAML files → Use yq

  • Common: docker-compose.yml, GitHub Actions, CI/CD configs

Both tools extract exactly what you need in one command - massive context savings.

Quick Examples

# Get version from package.json
jq -r .version package.json

# Get service ports from docker-compose
yq '.services.*.ports' docker-compose.yml

Detailed Reference

For comprehensive yq patterns, syntax, and examples, load yq guide:

  • Core patterns (80% of use cases)
  • Real-world workflows (Docker Compose, GitHub Actions, Kubernetes)
  • Advanced patterns and edge case handling
  • Output formats and pipe composition
  • Best practices and integration with other tools