Skip to content

fix: use git diff --stat in commit-commands to avoid context bloat#58842

Open
daniel769 wants to merge 1 commit into
anthropics:mainfrom
daniel769:fix/commit-commands-diff-stat
Open

fix: use git diff --stat in commit-commands to avoid context bloat#58842
daniel769 wants to merge 1 commit into
anthropics:mainfrom
daniel769:fix/commit-commands-diff-stat

Conversation

@daniel769
Copy link
Copy Markdown

Summary

  • Replace !`git diff HEAD` with !`git diff HEAD --stat` in plugins/commit-commands/commands/commit.md and plugins/commit-commands/commands/commit-push-pr.md
  • The full unified diff was being loaded into Claude's context on every /commit or /commit-push-pr invocation
  • On large commits (e.g. SQL regen with 50+ auto-generated files) this bloated context by 700KB+, slowing all subsequent LLM responses in the session
  • The --stat summary (file names + insertion/deletion counts) is sufficient for generating a commit message; full per-file diffs can be fetched on demand if needed

Fixes #58372

Test plan

  • Run /commit on a repo with a small diff — stat summary appears in context, commit message is generated correctly
  • Run /commit on a repo with a large diff (many files) — context stays small, no 700KB+ injection
  • Run /commit-push-pr — same behaviour, PR is created successfully

🤖 Generated with Claude Code

Replace `git diff HEAD` with `git diff HEAD --stat` in both
commit.md and commit-push-pr.md. The full unified diff was
loading into Claude's context on every invocation, bloating
sessions by 700KB+ on large commits (e.g. SQL regen with
50+ auto-generated files). The --stat summary is sufficient
for generating a commit message; full per-file diffs can be
fetched on demand if needed.

Fixes anthropics#58372

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] commit-commands:commit plugin loads full git diff into context — causes context bloat on large commits

1 participant