name: custom-process-reviews description: Scan #ai-code-review Slack for unaddressed bot reviews, triage, fix bugs, and report back. disable-model-invocation: true argument-hint: [--dry-run] allowed-tools: Bash, Read, Edit, Write, Grep, Glob, TodoWrite, Agent
Process AI Code Reviews from Slack
Scan the #ai-code-review Slack channel for unaddressed bot review posts, triage each finding against the current dev branch, fix real bugs, and post thread replies with status.
Constants
- Channel ID:
C0AJEPV0SNM(#ai-code-review) - Bot ID:
B0AHVEU97RR(Surfaced Art Releases) - Repo:
nickcjordan/surfaced-art - Base branch:
dev
Inputs
$ARGUMENTS— optional flags:- Empty or omitted: full workflow (scan, triage, fix, PR, Slack replies)
--dry-run: scan and triage only, print results to console, no code changes or Slack replies
Workflow
Phase 1: Scan Slack Channel
Read channel messages using
slack_read_channelon channelC0AJEPV0SNM. Request enough messages to cover the full backlog.Filter to bot review messages — keep messages where:
- The sender is bot
B0AHVEU97RR - The text contains
:robot_face: AI Review: - Exclude join/leave notifications and integration additions
- The sender is bot
Check each message for thread replies using
slack_read_threadwith the message's timestamp.- Unaddressed = zero thread replies, or only bot replies
- Already addressed = has a human thread reply — skip
Extract from each unaddressed message:
- PR number: parse
PR #(\d+)from the header line - Tool name:
sourcery-aiorgreptile-appsfrom the header - Message timestamp (
ts) for later thread replies - Whether it has inline comments (look for backtick-wrapped file paths)
- PR number: parse
Create a TodoWrite tracking list with one entry per unaddressed message.
Phase 2: Fetch Full Review Details from GitHub
For each unique PR number found in Phase 1:
Check PR state and merge status:
gh pr view <PR_NUMBER> --json state,merged,headRefName,baseRefName,urlFetch all bot review comments (full text, not truncated Slack versions):
gh api repos/nickcjordan/surfaced-art/pulls/<PR_NUMBER>/comments \ --jq '.[] | select(.user.login | test("sourcery-ai|greptile-apps")) | {user: .user.login, path: .path, line: .line, body: .body, html_url: .html_url}'Fetch bot review bodies (high-level feedback without inline comments):
gh api repos/nickcjordan/surfaced-art/pulls/<PR_NUMBER>/reviews \ --jq '.[] | select(.user.type == "Bot") | {user: .user.login, state: .state, body: .body}'
Phase 3: Triage Against Current Code
Check PR state first:
- If the PR was closed without merging — mark all findings as "PR closed without merge"
- If merged or open — proceed to code check
For each review comment, check if the issue still exists on
dev:git show dev:<file_path>- File no longer exists on
dev— stale - Flagged code pattern no longer appears near the referenced line — already resolved
- Code still has the issue — actionable
- File no longer exists on
Categorize each actionable finding:
- Bug / bug_risk / security — fix
- Sound improvement (missing validation, error handling gaps) — fix
- Style / opinion / info — skip
Deduplicate — when both Sourcery and Greptile flag the same file within ~10 lines, merge into a single fix item. Track which tools flagged it.
If
--dry-run: print the triage results as a formatted table and stop. Do not proceed to Phase 4.
Phase 4: Fix
Ensure
devis up to date:git checkout dev git pull origin devCreate the fix branch:
git checkout -b fix/ai-review-batch-$(date +%Y-%m-%d) devIf the branch already exists, append
-2,-3, etc.Group actionable findings by source PR number. For each PR's findings:
- Read the affected file(s)
- Understand surrounding code context
- Implement the fix
- Add or update tests if the change affects behavior
- Look for the same pattern elsewhere in the file
- Stage only the changed files
- Commit with message:
fix(<scope>): address <tool> review feedback from PR #<N> - Scope is derived from file path:
api,web,scripts,db,types,ci - Do NOT include Co-Authored-By lines
Run all quality gates after all commits:
npm run test npm run lint npm run typecheck npm run buildIf quality gates fail:
- Identify which commit caused the failure
- Attempt to fix the issue
- If the fix is non-trivial,
git revert <commit>the offending commit - Re-run quality gates until they pass
- Track reverted commits for Slack reporting
Phase 5: Open PR
Push and create PR:
git push -u origin <branch-name> gh pr create --base dev \ --title "fix: address AI code review findings (batch YYYY-MM-DD)" \ --body "<structured body>"PR body structure:
## Summary Batch fix addressing AI code review findings from #ai-code-review Slack channel. ## Fixes Applied | File | Issue | Source | Commit | |------|-------|--------|--------| | `path/to/file.ts` | Description of fix | Sourcery / Greptile | `abc1234` | ## Skipped (with reasoning) | File | Issue | Reason | |------|-------|--------| | `path/to/file.ts` | Description | Already fixed / Stale / Style-only | ## Source Reviews - PR #NNN: link to review
Phase 6: Slack Thread Replies
For every processed Slack message, post a thread reply using
slack_send_messagewiththread_tsset to the message's timestamp and channelC0AJEPV0SNM.Reply format varies by outcome:
Fixes applied:
Addressed in
Fixed:
file.ts— description (commitsha)
Skipped:
file.ts— reason
All findings stale or already resolved:
All findings already addressed on
dev.file.ts— code has changed since this review
No actionable bugs (style/info only):
Reviewed — no actionable bugs found.
file.ts— style/opinion, skipped per project conventions
PR was closed without merging:
PR was closed without merging — findings not applicable to
dev.Fix was attempted but reverted:
Partially addressed in
Fixed:
file.ts— description (commitsha)
Reverted (needs manual review):
file.ts— fix caused build failure
Summary-only review (no inline comments):
No inline comments in this review — nothing to address.
Edge Cases
- Multiple Slack messages for same PR — both tools post, Greptile sometimes posts twice. Group by PR, fetch GitHub comments once, but reply to each Slack message individually referencing only the findings relevant to that tool's comments.
- PR branches deleted — always read code from
devviagit show dev:<path>, never from PR branches. - Branch name collision — append counter (
-2,-3) iffix/ai-review-batch-YYYY-MM-DDalready exists. - Messages with no inline comments — some reviews are summary-only ("looks great!"). Reply with "No inline comments — nothing to address."
- Findings on code not yet on
dev— if a PR hasn't been merged todevyet (e.g., still on a feature branch), the findings can't be checked againstdev. Note this in the reply and skip.
Final Report
After all phases complete, print a summary to console:
- Total Slack messages scanned
- Messages already addressed (had thread replies) — skipped
- Messages processed this run
- Findings breakdown: X actionable, Y skipped (by reason)
- Commits made
- PR link (if created)
- Any reverted fixes requiring manual attention