bugeffort-smallfilter-qualitygood first issue
Description
Problem
rtk git diff prepends a diffstat summary before the actual diff output. This breaks git apply because the diffstat lines are not valid patch format.
Example output:
CLAUDE.local.md | 11 +++++++++++
src/lib/badges.ts | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/CLAUDE.local.md b/CLAUDE.local.md
index 15f4045..b9901bd 100644
...
The first 3 lines (file stats + summary) are not part of the unified diff format. When piping to git apply, it fails to parse.
Impact
This is particularly problematic when using Claude Code agents in worktrees. The typical workflow is:
- Spawn an agent in a worktree
- Extract its changes with
git diff - Apply the patch to the main worktree with
git apply
Step 3 fails because of the prepended diffstat. The current workaround is:
git diff --no-color -U3 2>/dev/null | sed -n '/^diff --git/,$p' > /tmp/patch.patch
Expected behavior
rtk git diff should output a clean unified diff without prepending a diffstat, so the output remains compatible with git apply, git am, and other tools that consume patches.
Alternatively, the diffstat could be sent to stderr instead of stdout.
Environment
- rtk 0.35.0
- Hook version: 3 (freshly updated via
rtk init -g) - macOS (Apple Silicon)
- Claude Code