Saltar al contenido
Skillpedia
Análisis y hojas de cálculo29 mil · #9767

jq

Qué hace

Esta habilidad te ayuda a extraer, filtrar y reestructurar información de datos JSON. Es para quien trabaja con respuestas de API, archivos de configuración o registros y necesita un dato específico.

Cuándo usarla

  • ✓Cuando necesitas extraer un campo o una lista filtrada de una respuesta JSON.
  • ✓Cuando quieres reestructurar datos JSON en una estructura diferente.
  • ✓Cuando lees un archivo de configuración o un registro en JSON y necesitas una respuesta rápida.

Link de la skill

https://github.com/charmbracelet/crush/blob/main/internal/skills/builtin/jq/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/charmbracelet/crush/blob/main/internal/skills/builtin/jq/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“De esta respuesta de API, dame solo los nombres y correos electrónicos de todos los usuarios activos en forma de lista.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Tu agente escribe un filtro de jq que selecciona, filtra o reconstruye el JSON y devuelve el resultado. El jq integrado admite banderas comunes, como la salida sin formato y la salida compacta.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

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
-r, --raw-output Output strings without quotes
-j, --join-output Like -r but no trailing newline
-c, --compact-output One-line JSON output
-s, --slurp Read all inputs into an array
-n, --null-input Use null as input (ignore stdin)
-e, --exit-status Exit 1 if last output is false or null
-R, --raw-input Read each line as a string, not JSON
--arg name value Bind $name to a string value
--argjson name value Bind $name 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; keys_unsorted and -S are unavailable.
  • Arbitrary-precision integers — large integers keep full precision (addition, subtraction, multiplication, modulo, division when divisible).
  • String indexing — "abcde"[2] returns "c".
  • Not supported — --ascii-output, --seq, --stream, --stream-errors, -f/--from-file, --slurpfile, --rawfile, --args, --jsonargs, input_line_number, $__loc__, some regex features (backreferences, look-around).
  • YAML — gojq supports --yaml-input/--yaml-output but the built-in does not currently expose these flags.

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 try to suppress errors on missing keys: jq 'try .foo.bar'
  • Use // "default" for fallback values: jq '.name // "unknown"'
  • Use @csv, @tsv, @base64, @html, @uri for format strings.
Preguntas frecuentes

¿Necesito instalar jq por separado?

No. El comando jq viene integrado y no necesita un programa externo.

¿Funciona exactamente igual que el jq estándar?

En su mayoría sí, pero las claves de los objetos se ordenan por defecto y algunas banderas estándar no están disponibles.

¿Puede leer archivos además de datos encadenados por tubería?

Sí. Puedes pasar el nombre de un archivo después del filtro.

Detalles

Descripción original del autor

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.

repo: charmbracelet/crush

Popularidad

Estrellas en GitHub
29 mil
Posición en el ranking
#9767
Licencia
—
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas