Add diff size limits and built-in file exclusions#16
Conversation
- 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>
There was a problem hiding this comment.
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
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>"
Summary
Adds safeguards to prevent context overflow and improve signal-to-noise ratio by:
Changes
New input:
max-diff-lines5000(keeps context under ~50% of 200k token limit)0to disable the limitBuilt-in file exclusions
Lock files:
package-lock.json,yarn.lock,pnpm-lock.yamlGemfile.lock,Pipfile.lock,poetry.lock,composer.lockCargo.lock,go.sum,pubspec.lock,Podfile.lockGenerated files:
*.min.js,*.min.css,*.bundle.js,*.chunk.js,*.map*.pb.go,*.pb.swift,*.generated.*,*.g.dart,*.freezed.dartBinary files:
*.png,*.jpg,*.jpeg,*.gif,*.ico,*.webp,*.svg*.woff,*.woff2,*.ttf,*.eot*.zip,*.tar.gz,*.jar*.pyc,*.so,*.dylib,*.dll,*.exeVendor directories:
node_modules,vendor,dist,build,.next__pycache__,.gradle,Pods,DerivedDataUser-specified
exclude-directoriesare combined with built-in exclusions.Test plan
🤖 Generated with Claude Code