feat: add `rtk jq` command for compressing large JSON extraction output
#1,364 opened on Apr 17, 2026
Repository metrics
- Stars
- (48,085 stars)
- PR merge metrics
- (Avg merge 11d 1h) (45 merged PRs in 30d)
Description
Summary
Add rtk jq to compress large JSON outputs from jq queries — currently a transparent fallback with 0% savings.
Searched existing issues (#229, #294, #538, PR #100) — didn't find existing jq coverage. Apologies if I missed one.
Motivation
rtk discover on my workstation over the past 30 days (152 Claude Code sessions, 2,653 Bash invocations) shows jq as one of the top uncovered commands:
| Command | Count | Example |
|---|---|---|
jq |
24 | jq -r '.paths | keys[]' swagger_coverage/openapi.json |
Caveat per #538: some of these may have gone through Claude Code's native tools rather than Bash. But jq specifically almost always runs via Bash (no native jq equivalent), so the count is likely close to real.
Typical use cases in my sessions — working with an openapi.json for a Go backend:
jq '.paths | keys[]' openapi.json→ can return hundreds of route pathsjq '.definitions | keys' openapi.json→ large type listsjq '.' config.json→ pretty-print of multi-KB configs
All produce output that either floods context or gets truncated ad-hoc.
Proposed behavior
- Small results (<50 lines, configurable): pass through verbatim. No compression, no loss.
- Large arrays:
first_N + "… (X more omitted) …" + last_N, preserving valid-looking JSON structure so the LLM can still reason about shape. - Large object dumps: same strategy — head/tail with ellipsis in the middle, keeping brace balance readable.
- Respect
-r/--raw-output: when output is raw text rather than JSON, treat likertk read(line-based head/tail).
Based on compression ratios I see for rtk read and rtk grep on similar output shapes, I'd expect 40–70% savings on these calls. Not a huge category (~24/month in my data), but easy win with no parser complexity — jq output is already structured.
Offer
Happy to test patches against real sessions — rtk gain gives clean before/after and I can share anonymized rtk discover dumps if it helps prioritize. Let me know if there's a beta channel.
Environment
rtk0.37.0 (Homebrew)- macOS Darwin 23.6.0
- Claude Code with
rtk-rewrite.shhook in~/.claude/settings.jsonPreToolUse