Skip to content

Prompt review agents to gather codebase context before judging diffs#22

Merged
justinmoon merged 1 commit intomasterfrom
review-gather-context
Mar 5, 2026
Merged

Prompt review agents to gather codebase context before judging diffs#22
justinmoon merged 1 commit intomasterfrom
review-gather-context

Conversation

@justinmoon
Copy link
Copy Markdown
Contributor

@justinmoon justinmoon commented Mar 5, 2026

Summary

  • Adds a "gather context" block to both step review and final review instructions
  • Tells reviewers to read modified files in full, trace callers/consumers, and check codebase conventions before evaluating the diff

Test plan

  • cargo build passes
  • CI green

🤖 Generated with Claude Code


Open with Devin

Summary by CodeRabbit

  • Documentation
    • Enhanced review instructions with added contextual guidance to help users better prepare for code diff reviews, including reminders to review modified files, identify callers/consumers, and check consistency with existing patterns.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

Warning

Rate limit exceeded

@justinmoon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9bcc65ae-c984-4675-b7dd-057c9fb79dce

📥 Commits

Reviewing files that changed from the base of the PR and between 22bcbfa and 58105e3.

📒 Files selected for processing (1)
  • crates/rally-workflow-build/src/lib.rs
📝 Walkthrough

Walkthrough

The PR adds contextual guidance to instruction strings returned by the get_instruction function in the workflow build system. A "Before judging the diff, gather context:" preface with three guidance items is prepended to instruction messages in both the FinalReview and Review code paths, without altering control flow or functionality.

Changes

Cohort / File(s) Summary
Instruction Guidance Updates
crates/rally-workflow-build/src/lib.rs
Added "Before judging the diff, gather context:" guidance block with three bulleted items (reading modified files, identifying callers/consumers, checking pattern consistency) to instruction strings in both FinalReview and Review paths.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit nudges reviewers near,
"Gather context first, that's clear!" 🐰
Read the files, find who calls,
Check the patterns in the halls,
Before you judge, these steps enthrall! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding guidance to review agents to gather codebase context before evaluating diffs, which aligns with the actual modifications to the instruction strings.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch review-gather-context

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
crates/rally-workflow-build/src/lib.rs (2)

219-227: Duplicated guidance text; consider extracting to a constant.

The "Before judging the diff, gather context:" block is identical in both FinalReview and step Review branches. Extracting this to a shared constant improves maintainability and ensures the guidance stays consistent across review types.

♻️ Suggested extraction

Add a constant at module level:

const REVIEW_CONTEXT_GUIDANCE: &str = r#"
Before judging the diff, gather context:
- Read modified files in full to understand the surrounding code, not just the changed lines.
- Identify callers and consumers of any new or changed functions, types, or APIs.
- Check that the changes are consistent with patterns and conventions used elsewhere in the codebase.
"#;

Then reference it in both format strings to avoid duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/rally-workflow-build/src/lib.rs` around lines 219 - 227, Duplicate
"Before judging the diff, gather context:" block should be extracted to a shared
module-level constant (e.g., REVIEW_CONTEXT_GUIDANCE) and referenced in both
places that build the review message (the FinalReview branch and the Review step
branch where the format! call uses
step.number/step.title/checkpoint.commit_sha/format_criteria(&step.acceptance_criteria)/state.name/agent).
Replace the repeated multiline text in those format! invocations with the
constant to remove duplication and keep messages consistent across FinalReview
and step Review.

213-216: Consider using a multiline raw string for readability.

This instruction string is quite long and hard to read with embedded \n characters. A raw string literal or indoc macro would improve maintainability.

♻️ Suggested refactor using raw string
             if state.phase == SessionPhase::FinalReview {
-                Some(format!(
-                    "Final holistic review of full implementation\nCommit: {}\nReview the complete change for cross-step integration, architecture consistency, and missing risks.\n\nBefore judging the diff, gather context:\n- Read modified files in full to understand the surrounding code, not just the changed lines.\n- Identify callers and consumers of any new or changed functions, types, or APIs.\n- Check that the changes are consistent with patterns and conventions used elsewhere in the codebase.\n\nWhen done, run these commands IN ORDER:\n1. rally build review --session {} --as {} --verdict APPROVE|CHANGES_REQUESTED|BLOCKED\n2. /rally (to get your next instruction — do NOT stop here)",
-                    checkpoint.commit_sha, state.name, agent
-                ))
+                Some(format!(
+                    r#"Final holistic review of full implementation
+Commit: {}
+Review the complete change for cross-step integration, architecture consistency, and missing risks.
+
+Before judging the diff, gather context:
+- Read modified files in full to understand the surrounding code, not just the changed lines.
+- Identify callers and consumers of any new or changed functions, types, or APIs.
+- Check that the changes are consistent with patterns and conventions used elsewhere in the codebase.
+
+When done, run these commands IN ORDER:
+1. rally build review --session {} --as {} --verdict APPROVE|CHANGES_REQUESTED|BLOCKED
+2. /rally (to get your next instruction — do NOT stop here)"#,
+                    checkpoint.commit_sha, state.name, agent
+                ))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/rally-workflow-build/src/lib.rs` around lines 213 - 216, Replace the
long escaped string inside the Some(format!(...)) call with a multiline raw
string (or indoc::formatdoc!) to improve readability; specifically, in the
expression that uses checkpoint.commit_sha, state.name, and agent in lib.rs (the
Some(format!(...)) block), change the format! invocation to use a raw string
literal (e.g. format!(r#"Final holistic review...Commit: {} ..."#,
checkpoint.commit_sha, state.name, agent)) or indoc::formatdoc! so the embedded
newlines become actual lines and the text is easier to maintain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/rally-workflow-build/src/lib.rs`:
- Around line 219-227: Duplicate "Before judging the diff, gather context:"
block should be extracted to a shared module-level constant (e.g.,
REVIEW_CONTEXT_GUIDANCE) and referenced in both places that build the review
message (the FinalReview branch and the Review step branch where the format!
call uses
step.number/step.title/checkpoint.commit_sha/format_criteria(&step.acceptance_criteria)/state.name/agent).
Replace the repeated multiline text in those format! invocations with the
constant to remove duplication and keep messages consistent across FinalReview
and step Review.
- Around line 213-216: Replace the long escaped string inside the
Some(format!(...)) call with a multiline raw string (or indoc::formatdoc!) to
improve readability; specifically, in the expression that uses
checkpoint.commit_sha, state.name, and agent in lib.rs (the Some(format!(...))
block), change the format! invocation to use a raw string literal (e.g.
format!(r#"Final holistic review...Commit: {} ..."#, checkpoint.commit_sha,
state.name, agent)) or indoc::formatdoc! so the embedded newlines become actual
lines and the text is easier to maintain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 112e7f19-c958-4c82-bd20-c43c692fe3c4

📥 Commits

Reviewing files that changed from the base of the PR and between 1043bca and 22bcbfa.

📒 Files selected for processing (1)
  • crates/rally-workflow-build/src/lib.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@justinmoon justinmoon force-pushed the review-gather-context branch from 22bcbfa to 58105e3 Compare March 5, 2026 01:45
@justinmoon justinmoon merged commit 89405d8 into master Mar 5, 2026
3 checks passed
@justinmoon justinmoon deleted the review-gather-context branch March 5, 2026 01:47
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.

1 participant