Use -e where null/false must fail a pipeline step.
Common Pitfalls
Missing keys return null instead of raising an error.
Quoted JSON strings are not suitable when raw output is required.
Large one-liner filters become brittle without iterative checks.
Output Interpretation
Pretty JSON by default; use -c for compact JSON lines.
-e returns non-zero on null/false, useful for guard conditions.
Why It Matters For Agents
jq is the standard adapter between JSON output and shell automation.
It reduces custom parser code and keeps pipelines deterministic.
Repo Conventions
Prefer jq over ad-hoc JSON parsing scripts.
Keep filters readable and scoped to required fields.
Trigger Examples
Should trigger: "Extract tool names from this JSON report."
Should trigger: "Convert API JSON into a compact table-friendly shape."
Should not trigger: "Lint shell scripts for quoting errors."
1---2name: tool-jq-23description: tool-jq4---5# tool-jq67## When To Use89- Extract fields from API responses and config outputs.10- Transform nested JSON into concise pipeline-friendly structures.11- Validate JSON shape and enforce required keys in scripts.1213## Trusted Commands1415```bash16jq . file.json17jq '.fieldName' file.json18jq '{id, name, status}' file.json19jq '[.items[] | {id, name}]' file.json20jq '.items | length' file.json21jq '.items[] | select(.status == "active")' file.json22jq '.name // "unknown"' file.json23jq -r '.name' file.json24jq -c '.items[]' file.json25jq -e '.token' file.json26```2728## Safe Defaults2930- Start with `jq .` to confirm valid JSON.31- Use `-r` for raw strings passed to other commands.32- Use `-e` where null/false must fail a pipeline step.3334## Common Pitfalls3536- Missing keys return `null` instead of raising an error.37- Quoted JSON strings are not suitable when raw output is required.38- Large one-liner filters become brittle without iterative checks.3940## Output Interpretation4142- Pretty JSON by default; use `-c` for compact JSON lines.43- `-e` returns non-zero on null/false, useful for guard conditions.4445## Why It Matters For Agents4647- jq is the standard adapter between JSON output and shell automation.48- It reduces custom parser code and keeps pipelines deterministic.4950## Repo Conventions5152- Prefer jq over ad-hoc JSON parsing scripts.53- Keep filters readable and scoped to required fields.5455## Trigger Examples5657- Should trigger: "Extract tool names from this JSON report."58- Should trigger: "Convert API JSON into a compact table-friendly shape."59- Should not trigger: "Lint shell scripts for quoting errors."
Run npx skillmds@latest add niksavis/tool-jq-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
tool-jq It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
niksavis (@niksavis) published this skill. Their other Agent Skills are listed on their SkillMD profile.