querying-yaml
yq: YAML Query and Extraction Tool
Always invoke yq skill to extract YAML fields - do not execute bash commands directly.
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.
Default Strategy
Invoke yq skill for extracting specific fields from YAML files efficiently. Use instead of reading entire files to save 80-95% context.
Common workflow: fd skill → yq skill → other skills (fzf, sd, bat) for extraction and transformation.
Pipeline Combinations
- yq | fzf: Interactive selection from YAML data
- yq | sd: Transform YAML to other formats
- yq | bat: View extracted YAML with syntax highlighting
Skill Combinations
For Discovery Phase
- fd → yq: Find YAML config files and extract specific fields
- ripgrep → yq: Find YAML usage patterns and extract values
- extracting-code-structure → yq: Understand API structures before extraction
For Analysis Phase
- yq → fzf: Interactive selection from structured data
- yq → bat: View extracted data with syntax highlighting
- yq → tokei: Extract statistics from YAML output
For Refactoring Phase
- yq → sd: Transform YAML data to other formats
- yq → jq: Convert YAML to JSON for different tools
- yq → xargs: Use extracted values as command arguments
Multi-Skill Workflows
- yq → jq → sd → bat: YAML to JSON transformation with preview
- yq → fzf → xargs: Interactive selection and execution based on YAML data
- fd → yq → ripgrep: Find config files, extract values, search usage
- docker-compose workflow: yq → fzf → nc (extract ports, test connectivity)
Common Integration Examples
# Get service ports and test connectivity
yq '.services.*.ports' docker-compose.yml | sd - '[^0-9]' '' | fzf | xargs -I {} nc -zv localhost {}
# Extract and filter environment variables
yq '.services.*.environment' docker-compose.yml | sd '\s*-\s*' '' | fzf
Note: Choosing Between jq and yq
- JSON files (package.json, tsconfig.json): Use
jq - YAML files (docker-compose.yml, GitHub Actions): Use
yq
Quick Examples
# Get service ports from docker-compose
yq '.services.*.ports' docker-compose.yml
# Get specific service configuration
yq '.services.web.image' docker-compose.yml
# List all service names
yq '.services | keys[]' docker-compose.yml
Detailed Reference
For comprehensive yq patterns, syntax, and examples, load yq guide when needing:
- Complex YAML structure navigation
- Array manipulation and filtering
- Data transformation patterns
- Docker Compose and Kubernetes examples
- Integration with other tools
- 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
More from iota9star/my-skills
querying-json
Extracts specific fields from JSON files efficiently using jq instead of reading entire files, saving 80-95% context. Use this skill when querying JSON files, filtering/transforming data, or getting specific field(s) from large JSON files
27finding-files
Performs fast file discovery with parallel search and smart defaults. Use this skill when searching for files by name, pattern, or type, especially when performance matters or when working with large directories
24extracting-code-structure
Extracts file structure (functions, classes, exports) efficiently without reading entire files, using ast-grep, Dart/Flutter analyzer, ctags, or other language-specific tools to get outlines and signatures. Use this skill when listing all methods, functions, or classes in a file, exploring unfamiliar code, getting API overviews, or deciding what to read selectively
24viewing-files
Enhanced cat clone with syntax highlighting, Git integration, and automatic paging for efficient file content viewing. Use this skill when viewing source files, documentation, or when syntax highlighting would improve readability
22replacing-text
Provides intuitive find & replace CLI with JavaScript regex and string-literal mode. Use this skill when performing text replacements, batch transformations, or need JavaScript-style regex syntax
21fuzzy-selecting
Provides interactive fuzzy finder for selecting items from any list with preview capabilities. Use this skill when choosing from search results, files, processes, or any command output
21