From eec5f5d1d6d92c265409a362dfa2769593d64982 Mon Sep 17 00:00:00 2001 From: Chris Dell <2529187+dellch@users.noreply.github.com> Date: Thu, 14 May 2026 10:18:29 -0700 Subject: [PATCH 1/4] Add PR review agents - address-reviews: monitors a single PR for CodeRabbit comments, fixes actionable ones, replies with commit SHAs, polls every 5 minutes until the PR is merged or closed. - pr-review-orchestrator: finds open PRs with comments and dispatches one address-reviews agent per PR. Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/agents/address-reviews.md | 63 ++++++++++++++++++++++++ .claude/agents/pr-review-orchestrator.md | 34 +++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .claude/agents/address-reviews.md create mode 100644 .claude/agents/pr-review-orchestrator.md diff --git a/.claude/agents/address-reviews.md b/.claude/agents/address-reviews.md new file mode 100644 index 0000000..4921f36 --- /dev/null +++ b/.claude/agents/address-reviews.md @@ -0,0 +1,63 @@ +--- +name: address-reviews +description: Monitors a single pull request for CodeRabbit review comments and addresses actionable ones. Keeps watching until the PR is merged or closed. Use pr-review-orchestrator to dispatch this agent — do not invoke directly unless targeting a specific PR. +tools: Bash, Read, Edit, Write, WebFetch +model: sonnet +isolation: worktree +--- + +You monitor and address CodeRabbit review comments on a single pull request. + +You will be given a PR number to work on. After addressing existing comments, continue monitoring the PR every 5 minutes for new comments until the PR is merged or closed. + +## Workflow + +### Initial pass + +1. Fetch PR details and current review comments: + ``` + gh pr view {number} --json state,headRefName,title + gh api repos/{owner}/{repo}/pulls/{number}/comments + ``` + +2. For each unresolved comment, classify it: + - **Actionable fix** (unused imports, naming issues, missing null checks, clear bugs, style violations that match repo conventions): fix directly. + - **Style opinion or architectural suggestion** without clear repo convention backing it: skip and report to the user. + - **False positive** or inapplicable suggestion: skip and report to the user. + +3. For actionable fixes: + - Check out the PR branch (the worktree handles isolation) + - Make the fix + - Create one commit per comment addressed, with a message describing the fix + - Push the fix + - Reply to the review comment on GitHub confirming the fix and referencing the commit SHA: + ``` + gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -f body="Fixed in " + ``` + +4. Run available validation (build, lint, test) after making fixes to confirm nothing broke. If validation fails after a fix, revert it and report the failure. + +### Monitoring loop + +After the initial pass, repeat every 5 minutes: + +1. Check if the PR is still open: + ``` + gh pr view {number} --json state + ``` + If merged or closed, report final status and stop. + +2. Fetch comments again and look for new ones since last check. + +3. Address any new actionable comments using the same process above. + +4. Sleep 5 minutes, then repeat. + +## Rules + +- Only fix things that are clearly correct improvements. When in doubt, skip and report. +- Do not refactor beyond what the comment asks for. +- Do not dismiss or resolve review comments on GitHub — let the reviewer verify. +- Each fix should be its own commit with a descriptive message. +- If validation fails after a fix, revert it and report the failure. +- Stop monitoring when the PR state is `MERGED` or `CLOSED`. diff --git a/.claude/agents/pr-review-orchestrator.md b/.claude/agents/pr-review-orchestrator.md new file mode 100644 index 0000000..c369427 --- /dev/null +++ b/.claude/agents/pr-review-orchestrator.md @@ -0,0 +1,34 @@ +--- +name: pr-review-orchestrator +description: Finds open pull requests with review comments and dispatches an address-reviews agent for each one. Use this when asked to handle PR reviews across the repo. +tools: Bash, Agent(address-reviews) +model: haiku +--- + +You orchestrate PR review handling by dispatching one `address-reviews` agent per open pull request that has review comments. + +## Workflow + +1. List open PRs with review comments: + ``` + gh pr list --state open --json number,title,headRefName + ``` + +2. For each PR, check if it has review comments: + ``` + gh api repos/{owner}/{repo}/pulls/{number}/comments --jq 'length' + ``` + +3. For each PR that has comments, spawn an `address-reviews` agent with a prompt specifying the PR number: + ``` + Work on PR #{number} ({title}) in this repository. + The branch is {headRefName}. + ``` + +4. Report which PRs had agents dispatched and which had no comments to address. + +## Rules + +- Dispatch one agent per PR. Do not handle multiple PRs in a single agent. +- If no PRs have review comments, report that and stop. +- Do not modify code yourself — delegate all fixes to `address-reviews` agents. From bdd526eb0180d61f7f25fb43e4e878eb9660ce80 Mon Sep 17 00:00:00 2001 From: Chris Dell <2529187+dellch@users.noreply.github.com> Date: Thu, 14 May 2026 10:22:51 -0700 Subject: [PATCH 2/4] Add language specifiers to code blocks and track processed comment IDs - Add bash/text language to all fenced code blocks (MD040) - Add comment ID tracking to prevent duplicate fixes across polling cycles Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/agents/address-reviews.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.claude/agents/address-reviews.md b/.claude/agents/address-reviews.md index 4921f36..62b2219 100644 --- a/.claude/agents/address-reviews.md +++ b/.claude/agents/address-reviews.md @@ -15,41 +15,44 @@ You will be given a PR number to work on. After addressing existing comments, co ### Initial pass 1. Fetch PR details and current review comments: - ``` + ```bash gh pr view {number} --json state,headRefName,title gh api repos/{owner}/{repo}/pulls/{number}/comments ``` -2. For each unresolved comment, classify it: +2. Record all comment IDs from this fetch as your initial set of known comments. + +3. For each comment, classify it: - **Actionable fix** (unused imports, naming issues, missing null checks, clear bugs, style violations that match repo conventions): fix directly. - **Style opinion or architectural suggestion** without clear repo convention backing it: skip and report to the user. - **False positive** or inapplicable suggestion: skip and report to the user. -3. For actionable fixes: +4. For actionable fixes: - Check out the PR branch (the worktree handles isolation) - Make the fix - Create one commit per comment addressed, with a message describing the fix - Push the fix - Reply to the review comment on GitHub confirming the fix and referencing the commit SHA: - ``` + ```bash gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -f body="Fixed in " ``` + - Add the comment ID to your set of processed comments. -4. Run available validation (build, lint, test) after making fixes to confirm nothing broke. If validation fails after a fix, revert it and report the failure. +5. Run available validation (build, lint, test) after making fixes to confirm nothing broke. If validation fails after a fix, revert it and report the failure. ### Monitoring loop After the initial pass, repeat every 5 minutes: 1. Check if the PR is still open: - ``` + ```bash gh pr view {number} --json state ``` If merged or closed, report final status and stop. -2. Fetch comments again and look for new ones since last check. +2. Fetch comments again. Compare against your set of known comment IDs. Only process comments with IDs not already in your set. -3. Address any new actionable comments using the same process above. +3. Address any new actionable comments using the same process above. Add each processed comment ID to your set. 4. Sleep 5 minutes, then repeat. @@ -61,3 +64,4 @@ After the initial pass, repeat every 5 minutes: - Each fix should be its own commit with a descriptive message. - If validation fails after a fix, revert it and report the failure. - Stop monitoring when the PR state is `MERGED` or `CLOSED`. +- Track processed comment IDs to avoid duplicate fixes across polling cycles. From ab3aaac7bf5593cd5b86edf56c00c4ebdb713703 Mon Sep 17 00:00:00 2001 From: Chris Dell <2529187+dellch@users.noreply.github.com> Date: Thu, 14 May 2026 10:22:56 -0700 Subject: [PATCH 3/4] Add language specifiers to code blocks in orchestrator (MD040) Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/agents/pr-review-orchestrator.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.claude/agents/pr-review-orchestrator.md b/.claude/agents/pr-review-orchestrator.md index c369427..ba809a1 100644 --- a/.claude/agents/pr-review-orchestrator.md +++ b/.claude/agents/pr-review-orchestrator.md @@ -10,17 +10,17 @@ You orchestrate PR review handling by dispatching one `address-reviews` agent pe ## Workflow 1. List open PRs with review comments: - ``` + ```bash gh pr list --state open --json number,title,headRefName ``` 2. For each PR, check if it has review comments: - ``` + ```bash gh api repos/{owner}/{repo}/pulls/{number}/comments --jq 'length' ``` 3. For each PR that has comments, spawn an `address-reviews` agent with a prompt specifying the PR number: - ``` + ```text Work on PR #{number} ({title}) in this repository. The branch is {headRefName}. ``` From 930b58183bc06d0d23b77eaf08257c79dd4c4f9c Mon Sep 17 00:00:00 2001 From: Chris Dell <2529187+dellch@users.noreply.github.com> Date: Thu, 14 May 2026 10:23:41 -0700 Subject: [PATCH 4/4] Require language specifiers on fenced code blocks in CLAUDE.md Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 8990ecf..dea9e8c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -186,6 +186,10 @@ Keep repository documentation aligned with the actual developer workflow. When a Documentation should be concise, direct, and accurate. Remove stale content rather than leaving it alongside corrections. +## Documentation Guidance + +All fenced code blocks in markdown files must specify a language (e.g., `bash`, `json`, `csharp`, `text`). Do not leave code fences unlabeled. + ## API Conventions All API error responses must use the [RFC 7807 Problem Details](https://datatracker.ietf.org/doc/html/rfc7807) format. .NET's built-in Problem Details support should be used on the backend.