Crush jq
Use when the user needs to query, filter, reshape, extract, create, or construct JSON data — including API responses, config files, log output, or any structured data — or when helping the user write or debug JSON transformations.
install
source · Clone the upstream repo
git clone https://github.com/charmbracelet/crush
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/charmbracelet/crush "$T" && mkdir -p ~/.claude/skills && cp -r "$T/internal/skills/builtin/jq" ~/.claude/skills/charmbracelet-crush-jq && rm -rf "$T"
manifest:
internal/skills/builtin/jq/SKILL.mdsource content
jq — Built-in JSON Processor
Crush ships a built-in
jq command (via github.com/itchyny/gojq) available
in the bash tool. No external binary is required.
Supported Flags
| Flag | Description |
|---|---|
, | Output strings without quotes |
, | Like but no trailing newline |
, | One-line JSON output |
, | Read all inputs into an array |
, | Use as input (ignore stdin) |
, | Exit 1 if last output is or |
, | Read each line as a string, not JSON |
| Bind to a string value |
| Bind to a parsed JSON value |
File arguments after the filter are also supported:
jq '.foo' file.json.
Differences from Standard jq
The built-in uses gojq, which is a pure-Go jq implementation. Key differences:
- No object key ordering — keys are sorted by default;
andkeys_unsorted
are unavailable.-S - Arbitrary-precision integers — large integers keep full precision (addition, subtraction, multiplication, modulo, division when divisible).
- String indexing —
returns"abcde"[2]
."c" - Not supported —
,--ascii-output
,--seq
,--stream
,--stream-errors
/-f
,--from-file
,--slurpfile
,--rawfile
,--args
,--jsonargs
,input_line_number
, some regex features (backreferences, look-around).$__loc__ - YAML — gojq supports
/--yaml-input
but the built-in does not currently expose these flags.--yaml-output
Common Patterns
Extract a field:
echo '{"name":"crush"}' | jq '.name'
Filter an array:
echo '[1,2,3,4,5]' | jq '[.[] | select(. > 3)]'
Reshape objects:
echo '{"first":"Ada","last":"Lovelace"}' | jq '{full: (.first + " " + .last)}'
Use variables:
echo '{}' | jq --arg host localhost --argjson port 8080 '{host: $host, port: $port}'
Slurp multiple JSON values:
echo '{"a":1}{"b":2}' | jq -s '.'
Compact output for piping:
echo '{"a":1}' | jq -c '.a += 1'
Raw string output:
echo '["one","two","three"]' | jq -r '.[]'
Process a file:
jq '.dependencies | keys' package.json
Null input for constructing JSON:
jq -n --arg msg hello '{"message": $msg}'
Tips
- Pipe jq output to other commands:
jq -r '.url' data.json | xargs curl - Chain filters with
inside the expression, not shell pipes.| - Use
to suppress errors on missing keys:tryjq 'try .foo.bar' - Use
for fallback values:// "default"jq '.name // "unknown"' - Use
,@csv
,@tsv
,@base64
,@html
for format strings.@uri