Repository navigation
Description
rtk gh pr diff --name-only returns empty output. The --name-only flag changes gh pr diff output from a unified diff to a plain filename list, but the filter applies compact_diff() regardless — which expects diff --git headers, @@ hunks, and +/- lines. A plain filename list matches none of these patterns, so the filter produces empty output.
Reproduction
On any PR with changed files:
# Raw gh — lists 39 changed files
gh pr diff 1815 --repo quarto-dev/quarto-web --name-only
# Through rtk — empty output
rtk gh pr diff 1815 --repo quarto-dev/quarto-web --name-only
Claude Code with the rtk hook sees empty output and concludes "no changed files" or retries with different flags — all hitting the same empty result.
Cause
pr_diff passes --name-only through to gh (line 1125-1127), so the raw output is a filename list. But line 1144 unconditionally runs git::compact_diff(&raw, 500) on whatever comes back:
compact_diff only emits lines matching diff structure (diff --git, @@, +, -). Plain filenames match nothing, so result is empty.
Suggestion
Flags like --name-only, --stat, and --name-status change the output format away from unified diff. When any of these are present, passthrough unfiltered — the output is already compact (just filenames) and doesn't benefit from diff compaction.
Broader Pattern
This is the same class of bug as #720 — a filter that doesn't account for a flag silently produces wrong output, and the hook makes it invisible to the AI agent. The agent trusts the output and draws false conclusions.
Both could be mitigated by a general principle: when a filter produces empty output from non-empty input, emit a warning to stderr rather than silently returning nothing.
Related
- rtk gh issue view --comments silently drops comments, misleading AI agents #720 —
--commentssilently dropped ongh issue/pr view(same pattern: flag ignored by filter) - gh PR comments/reviews and git diff output still truncated, causing repeated fetch attempts by AI agents #354 — gh output truncation (different: partial output vs empty output)
Environment
- rtk 0.30.1 (master, commit 48e53cb)
- gh 2.74.1
- Claude Code
- Windows 11
Activity
cderv commentedon Mar 20, 2026
Same workaround as #720 — we've excluded
ghfrom the rtk hook viaconfig.toml:gh pr diff --name-onlyworks correctly when unproxied. The filter-level fix is still relevant — both for users without this config, and to allow re-enabling rtk's token savings on gh commands where filtering works correctly.pszymkowiak commentedon Mar 20, 2026
🔍 Automated Triage
bughighSummary
compact_diff filter unconditionally applied to gh pr diff output even when --name-only/--stat flags produce non-diff format, resulting in silent empty output; skip filtering when output format flags are present.
📁 Relevant files
src/gh_cmd.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff
mvanhorn commentedon Mar 21, 2026
Implemented in #773 - added passthrough for --name-only, --stat, --name-status, --numstat, and --shortstat flags in pr_diff().
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff
aeppling commentedon Mar 22, 2026
#773 merged, closing this issue, thanks for reporting & contribution !
Will be available in next release, probably by tonight : #780
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff
fix(gh): skip compact_diff for --name-only/--stat flags in pr diff