Skip to content

Add diff size limits and built-in file exclusions#16

Merged
matej merged 2 commits intomainfrom
matej/add-diff-size-limits
Feb 6, 2026
Merged

Add diff size limits and built-in file exclusions#16
matej merged 2 commits intomainfrom
matej/add-diff-size-limits

Conversation

@matej
Copy link
Copy Markdown
Member

@matej matej commented Feb 5, 2026

Summary

Adds safeguards to prevent context overflow and improve signal-to-noise ratio by:

  1. Limiting diff size to avoid exceeding Claude's context window
  2. Auto-excluding generated, binary, and vendor files

Changes

New input: max-diff-lines

  • Default: 5000 (keeps context under ~50% of 200k token limit)
  • Set to 0 to disable the limit
  • PRs exceeding the limit are skipped with a clear warning

Built-in file exclusions

Lock files:

  • package-lock.json, yarn.lock, pnpm-lock.yaml
  • Gemfile.lock, Pipfile.lock, poetry.lock, composer.lock
  • Cargo.lock, go.sum, pubspec.lock, Podfile.lock

Generated files:

  • *.min.js, *.min.css, *.bundle.js, *.chunk.js, *.map
  • *.pb.go, *.pb.swift, *.generated.*, *.g.dart, *.freezed.dart

Binary files:

  • Images: *.png, *.jpg, *.jpeg, *.gif, *.ico, *.webp, *.svg
  • Fonts: *.woff, *.woff2, *.ttf, *.eot
  • Archives: *.zip, *.tar.gz, *.jar
  • Compiled: *.pyc, *.so, *.dylib, *.dll, *.exe

Vendor directories:

  • node_modules, vendor, dist, build, .next
  • __pycache__, .gradle, Pods, DerivedData

User-specified exclude-directories are combined with built-in exclusions.

Test plan

  • Unit tests for built-in exclusions (14 new tests)
  • Unit tests for diff size limit parsing
  • Full test suite passes (187 tests)

🤖 Generated with Claude Code

- Add max-diff-lines input (default 5000) to skip overly large PRs
  that could exceed context limits or timeout
- Add built-in exclusions for:
  - Lock files (package-lock.json, yarn.lock, etc.)
  - Generated files (*.min.js, *.pb.go, *.generated.*, etc.)
  - Binary files (images, fonts, archives, etc.)
  - Vendor directories (node_modules, vendor, dist, build, etc.)
- User-specified exclusions are combined with built-in exclusions
- Add comprehensive tests for new functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@matej matej requested a review from neonspectra February 5, 2026 21:46
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. Changes look good.

Copy link
Copy Markdown
Collaborator

@neonspectra neonspectra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, just a heads up as background:

  • The way you are doing code reviews here is different from how I did them in my workflow.
  • You cloned the whole repo and are using the default action, while in my first-pass implementation, I called the action contained in the upstream repo as a Marketplace Action step.
  • This means that the issues I was experiencing with large diffs are going to be pretty fundamentally different from what's going on here.

That said, I do think there's still room for improvements. I like the use of exclusions, but I don't like ever truncating context. IMO, truncation is bad because if there is a situation that one needs to truncate, then that situation itself is probably blowing up claude's context window too much in the first place with the prompt design.

The better route here imo is to make sure Claude gets items passed as files and has the ability to read them using agentic mode to look for whatever Claude thinks is important. This way we should (almost) never encounter a scenario where we have diffs that are way too big because we'll be passing just files.

I stacked a PR to this PR with my suggestion for this: #19

@matej
Copy link
Copy Markdown
Member Author

matej commented Feb 6, 2026

That said, I do think there's still room for improvements. I like the use of exclusions, but I don't like ever truncating context. IMO, truncation is bad because if there is a situation that one needs to truncate, then that situation itself is probably blowing up claude's context window too much in the first place with the prompt design.

We're not truncating. We're skipping code review completely if the diff gets to about ~50% of the context size (where model performance would start to degrade in a lot of cases). I think this is a good pragmatic start before we explore other enhancements.

Instead of skipping reviews when the diff exceeds max-diff-lines,
  switch to agentic mode where Claude reads files on-demand. This
  ensures large PRs still get reviewed while managing context limits.

  Changes:
  - Large diffs trigger agentic mode instead of skipping review
  - `max-diff-lines=0` now forces agentic mode (always read files)
  - Updated prompts to give Claude clear file reading instructions
  - Preserved existing fallback for `PROMPT_TOO_LONG` errors

  Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>"
@matej matej merged commit 5901fe2 into main Feb 6, 2026
2 checks passed
@matej matej deleted the matej/add-diff-size-limits branch February 6, 2026 14:28
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.

2 participants