jq
x jq - JSON Processor (AI Optimized)
x jq is an enhanced module based on jq, with the core advantage of zero-dependency auto-installation and optimization for scripted tasks. It ensures JSON can be processed immediately in any environment.
When to Activate
- When specific fields need to be extracted from complex JSON responses.
- When JSON structures need to be filtered, restructured, or transformed.
- When unformatted JSON strings need to be beautified for further analysis.
- When processing results need to be output as raw strings (
-r) for other commands.
Core Principles & Rules
- Non-interactive First: AI should avoid the interactive
replmode and use jq expressions directly. - Pipe Integration: Recommended for use with pipes, e.g.,
cat data.json | x jq '.field'. - Format Control:
- Use
-r(raw-output) for raw values without quotes (ideal for getting single string values). - Use
-c(compact-output) for compact one-line JSON to save context Tokens.
- Use
- Environment Isolation:
x jqautomatically downloads and runs jq when necessary, without polluting the system environment.
Patterns & Examples
Extract and Output Raw String
# Get the value of the 'version' field (no quotes, suitable for script use)
x jq -r '.version' package.json
Filter Array and Compact Output
# Filter and output as a compact one-line JSON to save Tokens
x jq -c '.items[] | select(.status == "active")' data.json
Construct New JSON Object
# Construct a new object containing status and timestamp
x jq -n --arg ts "$(date)" '{"status": "ok", "timestamp": $ts}'
Process Multiple Files
# Merge and process multiple JSON files
x jq -s '.[0] * .[1]' config1.json config2.json
Checklist
- Confirm that a non-interactive command is used (no
rorrepl). - Consider if
-ris needed for plain text values. - Consider if
-cis needed to reduce output volume.
More from x-cmd/skill
x-cmd
|
25x-security
This skill provides comprehensive security assessment and vulnerability management tools through x-cmd CLI, including network reconnaissance with Shodan, vulnerability scanning with OSV, and known exploited vulnerability tracking with KEV. This skill should be used when users need to perform security assessments, vulnerability research, network reconnaissance, or security monitoring from command line interfaces.
13x-network
This skill provides comprehensive network administration and diagnostic tools through x-cmd CLI, including network scanning with Nmap, ARP table management, DNS configuration, routing table analysis, and enhanced ping utilities. This skill should be used when users need to perform network diagnostics, troubleshoot connectivity issues, analyze network topology, or monitor network performance from command line interfaces.
11x-knowledge
This skill provides access to various knowledge search tools through x-cmd CLI, including Hacker News, Wikipedia, DuckDuckGo search, RFC documents, Project Gutenberg books, and Stack Exchange. This skill should be used when users need to search for technical information, browse online knowledge bases, or access documentation from command line interfaces.
6x-git
This skill provides comprehensive Git and code hosting platform management tools through x-cmd CLI, including GitHub, GitLab, Codeberg, Forgejo integration, and Git hooks management. This skill should be used when users need to manage Git repositories, work with code hosting platforms, automate Git workflows, or configure Git hooks from command line interfaces.
6x-system
This skill provides comprehensive system administration and monitoring tools through x-cmd CLI, including process management, macOS system utilities, network configuration, disk health monitoring, and storage analysis. This skill should be used when users need to perform system administration tasks, monitor system performance, manage network configurations, or troubleshoot system issues from command line interfaces.
6