What is Diff Scope?

Diff scope controls how much context the AI considers when analyzing your changes. By default, AI Diff Review focuses on the lines you actually changed, but you can expand this scope to include nearby lines or even the entire file. This setting affects both the analysis quality and commit gate scoring.

Scope Modes

STRICT Mode

In STRICT mode, the AI only considers findings that are directly on changed lines. This is the most focused approach and ensures that commit gate scoring only reflects issues you actually introduced.

Best for:

  • Precise commit gate scoring
  • Focusing only on new issues
  • Small, focused commits
  • When you want to ignore pre-existing issues

Considerations:

  • May miss issues related to your changes but not directly on changed lines
  • Less context for the AI to understand your changes
  • May produce fewer findings overall

NEARBY Mode

NEARBY mode includes a configurable window of lines around your changes (default: ±N lines). This provides more context while still focusing on the area you modified.

Best for:

  • Balanced analysis with context
  • Understanding impact of changes on surrounding code
  • Most general-purpose use cases
  • When you want some context without analyzing entire files

Considerations:

  • Window size affects analysis scope—larger windows include more context
  • May flag issues in nearby code that you didn't change
  • Commit gate scoring includes nearby findings

RELAXED Mode

RELAXED mode considers the entire file when analyzing changes. This provides maximum context and helps the AI understand the full impact of your modifications.

Best for:

  • Comprehensive analysis
  • Understanding how changes affect the entire file
  • Refactoring efforts
  • When you want maximum AI insight

Considerations:

  • May flag many pre-existing issues
  • Commit gate scoring includes all file findings
  • Larger analysis scope means more processing time
  • May be overwhelming for large files

Configuring Scope

To configure diff scope:

  1. Go to Settings → Tools → AI Diff Review
  2. Navigate to the Diff Scope Controls section
  3. Select your preferred mode (STRICT, NEARBY, or RELAXED)
  4. If using NEARBY, set the window size (number of lines to include on each side)

Impact on Commit Gate

Diff scope directly affects commit gate scoring:

  • STRICT: Only findings on changed lines contribute to scoring
  • NEARBY: Findings within the window contribute to scoring
  • RELAXED: All findings in changed files contribute to scoring

By default, global or untargeted INFO items are ignored for gating, regardless of scope mode. This ensures the gate focuses on issues related to your changes.

Choosing the Right Mode

For Security-Sensitive Projects

Use STRICT or NEARBY with a small window. This ensures the commit gate only blocks based on issues you actually introduced, not pre-existing problems.

For Code Quality Improvement

Use RELAXED mode to get comprehensive feedback on entire files. This helps identify areas for improvement beyond just your changes.

For Large Teams

Use STRICT mode to ensure commit gates are fair and only block based on new issues. This prevents frustration from being blocked by pre-existing code problems.

For Refactoring

Use RELAXED mode to understand how your refactoring affects the entire file. This provides better context for making informed decisions.

Best Practices

Start with Default

The default RELAXED mode works well for most use cases. Start there and adjust based on your needs.

Match Your Workflow

Choose a scope mode that matches how your team works. If you prefer focused commits, use STRICT. If you do comprehensive reviews, use RELAXED.

Consider File Size

For very large files, RELAXED mode may be overwhelming. Consider using NEARBY with a reasonable window size instead.

Review Findings

Regardless of scope mode, review findings carefully. Even in RELAXED mode, focus on addressing issues related to your changes first.

Combining with Other Settings

Diff scope works together with other settings:

  • Full content inclusion: When enabled, RELAXED mode has more context to work with
  • Related context cap: Limits how much related code is included, working alongside scope controls
  • Commit gate level: Scope affects what contributes to gate scoring

Conclusion

Diff scope controls give you fine-grained control over how AI Diff Review analyzes your code. By choosing the right mode for your needs, you can balance comprehensive analysis with focused feedback.

STRICT mode ensures precision, NEARBY provides balanced context, and RELAXED offers comprehensive insights. Experiment with different modes to find what works best for your workflow.

Remember that you can change the scope mode at any time in settings, so don't feel locked into your initial choice. Adjust as needed based on the type of work you're doing.

Ready to configure your analysis scope? Install AI Diff Review and explore the different scope modes available.