Send Code Review Slack send-code-review-slack
Post a #code-review Slack message for the current branch's PR with the Jira ticket, test environment link and per-component summaries.
Works in Claude, ChatGPT, Codex and more
- Our test
- —
- not tested yet
- GitHub stars
- 24k
- comet-ml/opik
- Added by
- 0
- members
- Updated
- Dec 6
- commit 316de6f
- Content
- 2 files
- no scripts · 18 KB
- License
- Apache 2.0
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: send-code-review-slack description: "Post a #code-review Slack message for the current branch's PR with the Jira ticket, test environment link and per-component summaries." disable-model-invocation: true
Send Code Review Slack Message
Overview
Send a formatted Slack message to the #code-review channel with PR information, Jira ticket, test environment link, and optional component summaries (FE, BE, Python, TypeScript). Automatically extracts information from the GitHub PR for the current branch.
- Execution model: Automatically extracts information from GitHub PR, prompts only for missing information, formats the message according to the template, and sends it through the Slack MCP.
This workflow will:
- Find the GitHub PR for the current branch
- Extract Jira ticket from PR title
- Extract test environment link from PR description
- Extract component summaries (FE, BE, Python, TypeScript) from PR description
- Prompt only for missing information
- Allow user to customize the message slightly
- Format the message according to the code review template
- Send the message to the #code-review channel through the Slack MCP
- Verify successful delivery
Inputs
Required Information (auto-extracted from PR, prompted if missing)
- Jira ticket: Extracted from PR title (format:
[OPIK-1234]) or prompted if not found - PR link: Automatically determined from current branch's PR or prompted if no PR found
- Test env link: Extracted from PR description (Testing or Details section) or prompted if not found
Optional Information (auto-extracted from PR, prompted if missing)
- FE summary: Extracted from PR description (looks for frontend/React/FE mentions) or prompted if not found
- BE summary: Extracted from PR description (looks for backend/Java/BE mentions) or prompted if not found
- Python summary: Extracted from PR description (looks for Python/Python SDK mentions) or prompted if not found
- TypeScript summary: Extracted from PR description (looks for TypeScript/TypeScript SDK/TS mentions) or prompted if not found
- Baz approved status: Extracted from PR status checks (optional, may not be available)
Configuration
- Slack MCP: Required. Slack's official MCP server, connected in your own tool (Claude Code: the Slack plugin, signed in with
/mcp; Cursor: its Slack integration). It posts as you.
Steps
1. Preflight & Environment Check
- Check GitHub CLI: Run
gh auth status. > Ifghis missing or not logged in, respond with: "This command needs the GitHub CLI: installghand rungh auth login, then retry." > Stop here. - Check Git repository: Verify we're in a Git repository
- Check current branch: Get current branch name
- Check Slack MCP: The Slack tools (
slack_search_channels,slack_send_message) must be available. > If they are not, respond with: "This command needs Slack's MCP: connect Slack in your agent (Claude Code: the Slack plugin, then/mcp), then retry. To post by hand, use/generate-code-review-slack-command." > Stop here.
2. Find GitHub PR for Current Branch
- Search for PR: Find the open PR for the current branch in
comet-ml/opikwithgh pr view --json number,url,title,body(fails when the current branch has no open PR) - If PR found:
- Extract PR number, URL, title, and description
- Store PR information for extraction steps
- If no PR found: > "No open PR found for this branch. Please provide the PR link manually:"
- Prompt for PR link and validate URL format
- If provided, fetch PR details with
gh pr view <url> --json number,url,title,body - If PR cannot be fetched, stop with error message
- After successfully fetching PR by manual link: Extract PR number, URL, title, and description and store PR information for extraction steps (same as "PR found" branch)
3. Extract Information from PR
- Extract Jira ticket from PR title:
- Parse PR title for pattern
[OPIK-\d+]or[issue-\d+]or[NA] - Extract ticket number (e.g.,
OPIK-1234from[OPIK-1234] [BE] feat(api): add trace request validation endpoint) - If not found in title, check PR description "## Issues" section for
OPIK-\d+pattern - If still not found, prompt: "Jira ticket not found in PR. Enter Jira ticket number (e.g., OPIK-1234):"
- Validate format and store
- Build Jira URL: Construct Jira link as
https://comet-ml.atlassian.net/browse/{TICKET}(e.g.,https://comet-ml.atlassian.net/browse/OPIK-1234)
- Extract Baz approved status (optional):
- Fetch the PR's checks with
gh pr checks <number> - Look for status checks or CI checks that might indicate "Baz approved" or similar approval status
- If found, store the status (e.g., "Baz approved: ✅" or "Baz status: pending")
- If not found or unavailable, skip this field (it\'s optional)
- Extract PR size: Follow the shared steps in
.agents/docs/PR_SIZE_EXTRACTION.md(read thesize/*label; fall back to changed lines using the workflow's own ignore list + thresholds). Store the bucket as{emoji} {BUCKET}(e.g.🟠 L).
- Extract test environment link from PR description and comments:
- First, search PR comments for test environment deployment messages (look for "Test environment is now available!" or similar)
- When fetching PR comments via
gh api, always use--paginateto ensure all results are fetched:
# Issue comments (general PR comments, including deployment bot messages)
gh api repos/comet-ml/opik/issues/{pr_number}/comments --paginate
# Review comments (inline code comments)
gh api repos/comet-ml/opik/pulls/{pr_number}/comments --paginateWhy pagination is required: GitHub API returns 30 items per page by default. Opik PRs regularly exceed this — 17 CI test group comments + deployment bot comments + reviewer comments can push past 30 total. Without --paginate, the deployment bot comment with the test environment link may end up on page 2 and get silently missed.- Extract URL from comment body (typically in format
https://pr-XXXX.dev.comet.comorhttps://test.opik.com) - If not found in comments, search PR description for URLs in "## Testing" section
- Look for common test environment patterns:
https://pr-*.dev.comet.com,https://test.opik.com,https://*.opik.com, or anyhttps://URL - If multiple URLs found, prefer the first one that looks like a test environment
- If not found, search in "## Details" section for URLs
- If still not found, prompt: "Test environment link not found in PR. Enter test environment link (e.g., <https://pr-4743.dev.comet.com>):"
- Validate URL format and store
- Extract component summaries from PR description:
- FE summary:
- Look for mentions of "frontend", "FE", "React", "UI", or
[FE]tag in PR description - Extract relevant one-line summary from "## Details" section or component-specific mentions
- If not found, prompt: "Frontend summary not found in PR. Enter frontend summary (one line, optional - press Enter to skip):"
- BE summary:
- Look for mentions of "backend", "BE", "Java", "API", or
[BE]tag in PR description - Extract relevant one-line summary from "## Details" section or component-specific mentions
- If not found, prompt: "Backend summary not found in PR. Enter backend summary (one line, optional - press Enter to skip):"
- Python summary:
- Look for mentions of "Python", "Python SDK", "SDK", or Python-related changes in PR description
- Extract relevant one-line summary from "## Details" section or component-specific mentions
- If not found, prompt: "Python summary not found in PR. Enter Python summary (one line, optional - press Enter to skip):"
- TypeScript summary:
- Look for mentions of "TypeScript", "TypeScript SDK", "TS", "TS SDK", or
[TS]tag in PR description - Extract relevant one-line summary from "## Details" section or component-specific mentions
- If not found, prompt: "TypeScript summary not found in PR. Enter TypeScript summary (one line, optional - press Enter to skip):"
- Store extracted information: Keep all extracted and prompted values for message formatting
4. Prompt for Message Customization
- Allow user to customize message: After extracting all information, prompt the user: > "Would you like to customize the message? (Enter any additional text to prepend/append, or press Enter to use default message):"
- If user provides customization text: Store it for inclusion in the final message
- If user presses Enter (empty): Proceed with default message format
- Note: User can add context, emphasize certain points, or include additional information
5. Format Slack Message
- Use PR link: Use the PR URL extracted from Step 2 (or provided manually)
- Build message text according to the template:
Hi team,
Please review the following PR:
{{user_customization_text_if_provided}}
:jira_epic: jira link: {{Jira_URL}}
:github: pr link: {{PR_link}}
:straight_ruler: pr size: {{pr_size}}
:test_tube: test env link: {{test_env}}
{{baz_approved_status_if_available}}
:react: fe summary (optional): {{description_in_one_line}}
:java: be summary (optional): {{description_in_one_line}}
:python: python summary (optional): {{description_in_one_line}}
:typescript: typescript summary (optional): {{description_in_one_line}}- Message structure:
- Start with greeting: Always begin with "Hi team,\n\nPlease review the following PR:\n"
- User customization: If user provided customization text in Step 4, include it after the greeting (before the structured fields)
- Jira link: Include full Jira URL with ticket (e.g.,
https://comet-ml.atlassian.net/browse/OPIK-1234) - PR link: Include GitHub PR URL
- PR size: Include the size bucket extracted in Step 3 (e.g.,
🟠 L). Always included — size is always available from GitHub. - Test env link: Include test environment URL
- Baz approved status: Only include if extracted from PR status checks (optional field)
- Component summaries: Only include optional fields that were provided (skip empty ones)
- Only include optional fields that were provided (skip empty ones)
- Format example:
Hi team,
Please review the following PR:
:jira_epic: jira link: https://comet-ml.atlassian.net/browse/OPIK-1234
:github: pr link: https://github.com/comet-ml/opik/pull/1234
:straight_ruler: pr size: 🟠 L
:test_tube: test env link: https://test.opik.com
:react: fe summary (optional): Added new metrics dashboard UI
:java: be summary (optional): Implemented metrics aggregation endpoint
:typescript: typescript summary (optional): Added TypeScript SDK support for metrics- Note about videos: Slack has limitations on sending videos directly. Videos should be added to the PR description, and the link can be shared in Slack. For easier communication with the product team, consider using the
/generate-code-review-slack-commandcommand to generate a copiable Slack command that you can edit before sending (allowing you to add @ mentions, media links, and final proof editing).
6. Send Slack Message
- Find the channel ID of
#code-reviewwithslack_search_channels. - Show the message and ask before sending. Send it with
slack_send_message(channel_id,message; standard Markdown), or, if the user wants to edit it in Slack first (to add @ mentions or media), save it as a draft withslack_send_message_draftand give them the link. - Messages are posted as your own account.
- If it fails, show the error and stop.
not_in_channelmeans you have to join#code-reviewfirst.
7. Verification & Summary
- Display confirmation: > "✅ Slack message sent successfully to #code-review channel"
- Show message preview: Display the formatted message that was sent
- Provide next steps: Remind user to check Slack channel for delivery
Error Handling
Slack MCP Errors
- Slack tools not available: connect Slack in your agent (see Step 1), or draft the message with
/generate-code-review-slack-commandand post it yourself. - `not_in_channel` / `channel_not_found`: join
#code-review, then retry.
GitHub CLI Errors
- `gh` missing or not logged in: Stop after the check and give the setup instructions
- PR not found: Prompt for manual PR link or stop if user cancels
- PR fetch failure: Show error details and suggest manual input
Extraction Errors
- Jira ticket not found: Prompt user for ticket number
- Test env link not found: Prompt user for test environment URL
- Component summaries not found: Prompt user for summaries (optional)
Input Validation Errors
- Invalid Jira ticket format: Show expected format (e.g.,
OPIK-1234) and re-prompt - Invalid PR URL: Show expected format and re-prompt
- Invalid test env URL: Show expected format and re-prompt
Success Criteria
The command is successful when:
- ✅ The GitHub CLI is authenticated
- ✅ PR is found for current branch (or manually provided)
- ✅ The Slack MCP is connected
- ✅ Jira ticket is extracted from PR or provided manually
- ✅ Test environment link is extracted from PR or provided manually
- ✅ Component summaries are extracted from PR or provided manually (optional)
- ✅ Message is formatted according to template (with greeting and Jira link)
- ✅ The message is sent with
slack_send_message(posts as your account) - ✅ User receives confirmation of successful delivery
Notes
- GitHub CLI required: Uses
ghto fetch PR information automatically - Slack MCP required: Slack's official MCP server, connected in your own tool (Claude Code: the Slack plugin, signed in with
/mcp; Cursor: its Slack integration). It posts as you. - Message format: Follows the exact template provided with emoji prefixes, includes greeting and Jira link
- Automatic extraction: Extracts information from PR title and description to minimize manual input
- Fallback to prompts: Only prompts for information that cannot be extracted from PR
- Optional fields: Only included in message if extracted from PR or provided by user
- Channel: Message is always sent to
#code-reviewchannel - PR detection: Automatically finds PR for current branch, falls back to manual input if needed
- Smart extraction: Uses heuristics to find test environment links and component summaries in PR description
- Slack setup: see
.agents/docs/SLACK_MCP_SETUP.md - Video limitations: Slack cannot send videos directly. Use
/generate-code-review-slack-commandto generate a copiable command that you can edit before sending (allowing you to add @ mentions, media links, and final proof editing)
Example Usage
Setup and Usage
# 1. Connect Slack in your agent (Claude Code: the Slack plugin, then /mcp). See .agents/docs/SLACK_MCP_SETUP.md
# 2. Run command (on a branch with an open PR)
/send-code-review-slack
# Command execution flow:
# 1. Find PR for current branch: https://github.com/comet-ml/opik/pull/1234
# 2. Extract Jira ticket from PR title: [OPIK-1234] [BE] feat(api): add metrics dashboard
# 3. Extract test env from PR comments or description: https://pr-1234.dev.comet.com (from PR comments or Testing section)
# Extract PR size from the size/* label (or additions+deletions): 🟠 L
# 4. Extract summaries from PR description:
# - FE: Added new metrics dashboard UI (from Details section)
# - BE: Implemented metrics aggregation endpoint (from Details section)
# - Python: (not found, prompts user)
# - TypeScript: (not found, prompts user)
# 5. Prompt for message customization (optional)
# 6. Format message according to template (with greeting and Jira link)
# 7. Send the formatted message with slack_send_message (posts as your account)
# Output:
# ✅ Slack message sent successfully to #code-review channel
#
# Message sent:
# :jira_epic: jira link: https://comet-ml.atlassian.net/browse/OPIK-1234
# :github: pr link: https://github.com/comet-ml/opik/pull/1234
# :straight_ruler: pr size: 🟠 L
# :test_tube: test env link: https://test.opik.com
# :react: fe summary (optional): Added new metrics dashboard UI
# :java: be summary (optional): Implemented metrics aggregation endpoint
# :typescript: typescript summary (optional): Added TypeScript SDK support for metricsExample with Missing Information
If some information cannot be extracted from PR, the command will prompt:
/send-code-review-slack
# Found PR: https://github.com/comet-ml/opik/pull/1234
# Extracted Jira ticket: OPIK-1234
# Test environment link not found in PR. Enter test environment link (e.g., https://test.opik.com): https://test.opik.com
# Frontend summary not found in PR. Enter frontend summary (one line, optional - press Enter to skip): [Enter pressed - skipped]
# Backend summary not found in PR. Enter backend summary (one line, optional - press Enter to skip): Implemented metrics endpoint
# Python summary not found in PR. Enter Python summary (one line, optional - press Enter to skip): [Enter pressed - skipped]
# TypeScript summary not found in PR. Enter TypeScript summary (one line, optional - press Enter to skip): [Enter pressed - skipped]
# Would you like to customize the message? (Enter any additional text to prepend/append, or press Enter to use default message): [Enter pressed - using default]End Command