-
Notifications
You must be signed in to change notification settings - Fork 53
Add Claude Code command for automated bug labeling through MCP JIRA server #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ricky-rav
wants to merge
2
commits into
openshift:main
Choose a base branch
from
ricky-rav:applyLabelsWithClaude
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+455
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| # Auto-Label JIRA Bugs | ||
|
|
||
| You are helping automate bug labeling for the networking team. | ||
|
|
||
| ## Usage | ||
|
|
||
| - `/label-bugs` - Analyze and apply labels to unlabeled bugs (uses MCP JIRA server) | ||
| - `/label-bugs --dry-run` - Analyze bugs and show what labels would be applied WITHOUT actually applying them | ||
| - `/label-bugs --api` - Use Python API instead of MCP JIRA server (fallback mode) | ||
| - `/label-bugs --api --dry-run` - Use Python API in dry-run mode | ||
|
|
||
| ## Mode Selection | ||
|
|
||
| **Default (MCP Mode)**: Uses the MCP JIRA server tools (`mcp__jira-atlassian__*`) | ||
|
|
||
| **API Mode** (`--api` flag): Falls back to Python script using direct JIRA API via `jira-scripts/network_bugs_overview` | ||
|
|
||
| If the user specifies `--api`, you MUST use the Python script instead of MCP tools for both fetching bugs and applying labels. | ||
|
|
||
| ## Dry Run Mode | ||
|
|
||
| If the user invokes this command with `--dry-run`, `dry-run`, or `-n`: | ||
| - Perform all analysis steps normally | ||
| - Show what label would be applied to each bug | ||
| - **DO NOT** apply any labels to JIRA | ||
| - **DO NOT** ask user questions (no AskUserQuestion tool calls) | ||
| - Just analyze and display results for all bugs, including medium and low confidence ones | ||
| - Clearly indicate in the output that this is a dry run | ||
| - Mark items with `[DRY RUN]` prefix in the summary | ||
|
|
||
| ## Your Task | ||
|
|
||
| 1. **Read the label mapping** from `jira-scripts/area_labels.csv`: | ||
| - First column: Feature/area description | ||
| - Second column: Label to apply | ||
|
|
||
| 2. **Fetch unlabeled bugs** from JIRA: | ||
|
|
||
| **MCP Mode (default - when --api is NOT specified)**: | ||
| - Use the `mcp__jira-atlassian__jira_search` tool | ||
| - Use this JQL query: | ||
| ``` | ||
| project = OCPBUGS AND component in ("Networking / openshift-sdn", "Networking / ovn-kubernetes", "Networking / cloud-network-config-controller", "Networking / ingress-node-firewall", "Networking / cluster-network-operator", "Networking / network-tools") AND resolution = Unresolved AND (assignee = "bbennett@redhat.com" OR assignee is EMPTY) ORDER BY Rank DESC | ||
| ``` | ||
| - Request fields: `summary,description,labels,components,issuelinks` | ||
|
|
||
| **API Mode (when --api is specified)**: | ||
| - Use the Bash tool to run: `cd jira-scripts && ./network_bugs_overview --query "YOUR_JQL_QUERY_HERE"` | ||
| - Use the same JQL query as above | ||
| - The script will output detailed bug information including ID, summary, description, labels, components, issue links, and comments | ||
|
|
||
| 3. **For each bug without an area label**: | ||
| - **In MCP mode**: Read additional details using `mcp__jira-atlassian__jira_get_issue` if needed | ||
| - **In API mode**: All details are already available from step 2 | ||
| - **Check if it's a backport**: If the bug has dependencies (depends on another bug), it's a backport → apply `SDN:Backport` label | ||
| - Otherwise, analyze the content and determine which ONE label from the CSV best fits | ||
| - **Confidence levels**: | ||
| - **High confidence** (>80% sure): Automatically apply the label | ||
| - **Medium confidence** (40-80% sure): Present top 2-3 candidates to user for selection | ||
| - **Low confidence** (<40% sure): Ask user to review and choose | ||
|
|
||
| 4. **For medium and low confidence bugs** (SKIP THIS STEP ENTIRELY in dry-run mode): | ||
| - **In normal mode**: After displaying the summary, use the AskUserQuestion tool to ask the user which label to apply for each bug. Present the top 2-3 alternatives as options. | ||
| - **In dry-run mode**: DO NOT use AskUserQuestion. Just display the analysis with proposed label and alternatives. | ||
| - **IMPORTANT**: Always include a "Skip/Defer" option that allows the user to skip applying any label to the bug | ||
| - **CRITICAL**: The "Skip/Defer" option MUST ALWAYS be option 1 (the first option) so users can quickly press 1 to skip bugs they want to defer | ||
| - **In the question text**: Include a brief summary of the bug description (2-3 sentences max) and a clickable link to the bug | ||
| - **Format**: "OCPBUGS-XXXXX: [Brief summary of the issue]. Link: https://issues.redhat.com/browse/OCPBUGS-XXXXX" | ||
| - Example question: "OCPBUGS-64932: Time drift during Chrony configuration causes ovnkube-controller certificate to become invalid, causing pods to crash. The certificate NotBefore time is ahead of worker node time. Link: https://issues.redhat.com/browse/OCPBUGS-64932 - Which label should be applied?" | ||
|
|
||
| 5. **Apply the labels** to JIRA (skip this step if in dry-run mode): | ||
| - **In MCP mode**: Use `mcp__jira-atlassian__jira_update_issue` to apply labels | ||
| - **In API mode**: Use the Bash tool to run: `cd jira-scripts && ./network_bugs_overview --label-bug OCPBUGS-XXXXX --label "SDN:LabelName"` | ||
|
|
||
| 6. **Display analysis results** using this standardized format for EACH bug: | ||
|
|
||
| ``` | ||
| OCPBUGS-12345 - Bug title here (truncated to 80 chars if needed) | ||
| - Proposed label: SDN:OVNK:EgressIP | ||
| - Confidence: 95% | ||
| - Reasoning: Brief explanation of why this label was chosen | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12345 | ||
| ``` | ||
|
|
||
| For medium and low confidence bugs, also show: | ||
| ``` | ||
| - Top alternatives: SDN:Platform:OVNK, SDN:OVNK:AdminNetworkPolicy | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12345 | ||
| ``` | ||
|
|
||
| 7. **Print final summary** at the end grouped by confidence level: | ||
|
|
||
| Normal mode: | ||
| ``` | ||
| 🟢 High confidence (auto-applied): | ||
| OCPBUGS-12345 - Bug title here | ||
| - Proposed label: SDN:OVNK:EgressIP | ||
| - Confidence: 95% | ||
| - Reasoning: Explicitly about EgressIP failover issues with IPv6 | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12345 | ||
|
|
||
| OCPBUGS-12346 - Another bug title | ||
| - Proposed label: SDN:Platform:CNO | ||
| - Confidence: 85% | ||
| - Reasoning: CNO configuration and deployment issue | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12346 | ||
|
|
||
| 🟡 Medium confidence (review recommended): | ||
| OCPBUGS-12347 - Third bug | ||
| - Proposed label: SDN:OVNK:NetworkPolicy | ||
| - Confidence: 70% | ||
| - Reasoning: Network policy enforcement behavior | ||
| - Top alternatives: SDN:Platform:OVNK, SDN:OVNK:AdminNetworkPolicy | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12347 | ||
|
|
||
| 🔴 Low confidence (user input needed): | ||
| OCPBUGS-12349 - Fifth bug | ||
| - Proposed label: SDN:Tooling | ||
| - Confidence: 35% | ||
| - Reasoning: May be related to must-gather or debugging tools | ||
| - Top alternatives: SDN:Platform:CNO, SDN:Metrics | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12349 | ||
|
|
||
| User selected: | ||
| OCPBUGS-12350 - Sixth bug - SDN:OVNK:EgressIP (user confirmed) | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12350 | ||
|
|
||
| OCPBUGS-12351 - Seventh bug - Skipped (no label applied) | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12351 | ||
| ``` | ||
|
|
||
| Dry-run mode (same format with [DRY RUN] prefix, no user interaction): | ||
| ``` | ||
| 🟢 High confidence: | ||
| [DRY RUN] OCPBUGS-12345 - Bug title here | ||
| - Proposed label: SDN:OVNK:EgressIP | ||
| - Confidence: 95% | ||
| - Reasoning: Explicitly about EgressIP failover issues with IPv6 | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12345 | ||
|
|
||
| 🟡 Medium confidence: | ||
| [DRY RUN] OCPBUGS-12347 - Third bug | ||
| - Proposed label: SDN:OVNK:NetworkPolicy | ||
| - Confidence: 70% | ||
| - Reasoning: Network policy enforcement behavior | ||
| - Top alternatives: SDN:Platform:OVNK, SDN:OVNK:AdminNetworkPolicy | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12347 | ||
|
|
||
| 🔴 Low confidence: | ||
| [DRY RUN] OCPBUGS-12349 - Fifth bug | ||
| - Proposed label: SDN:Tooling | ||
| - Confidence: 35% | ||
| - Reasoning: May be related to must-gather or debugging tools | ||
| - Top alternatives: SDN:Platform:CNO, SDN:Metrics | ||
| - URL: https://issues.redhat.com/browse/OCPBUGS-12349 | ||
| ``` | ||
|
|
||
| ## Important Rules | ||
|
|
||
| - **Use MCP JIRA server tools by default** (`mcp__jira-atlassian__*`). Only use Python scripts when `--api` flag is specified | ||
| - Each bug gets **exactly ONE** area label | ||
| - Backports always get `SDN:Backport` (check bug dependencies/links) | ||
| - If a bug already has an area label (any label starting with "SDN:" or "SDN-"), skip it | ||
| - **In dry-run mode**: NEVER use AskUserQuestion tool - just analyze and display all results | ||
| - **In normal mode**: Be conservative - when in doubt, ask the user rather than applying wrong label | ||
| - **Always provide a "Skip/Defer" option** when asking the user about medium/low confidence bugs (normal mode only) | ||
| - **The "Skip/Defer" option MUST be option 1 (first option) in every user question dialog** so users can quickly press 1 to skip | ||
| - **In AskUserQuestion dialogs**: Include a brief bug summary (2-3 sentences) and a link to the bug (https://issues.redhat.com/browse/OCPBUGS-XXXXX) | ||
| - Consider all available context: title, description, affected components, issue links | ||
| - Use the standardized output format for each bug (key, title, proposed label, confidence %, reasoning) | ||
| - **ALWAYS include the bug URL as the LAST item** for each bug in the format: `- URL: https://issues.redhat.com/browse/OCPBUGS-XXXXX` | ||
| - Group bugs by confidence level in the summary: high, medium, low, and user selected (in normal mode) | ||
| - In dry-run mode, group by: high, medium, and low confidence only (no "user selected" section) | ||
| - Show emoji once at the beginning of each confidence group: 🟢 🟡 🔴 | ||
| - For medium and low confidence bugs, show the top 2-3 alternative labels considered | ||
| - Skip groups that have no bugs (e.g., if no low confidence bugs, don't show that section) | ||
| - Track skipped bugs separately in the summary | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| ALL Backports,SDN:Backport | ||
| Bug caused due to lack of test coverage?,SDN:LackingTestCoverage | ||
| All SDN Bugs (no need to split on Area),SDN:Platform:SDN | ||
| CNO,SDN:Platform:CNO | ||
| HyperShift Specific,SDN:Platform:HyperShift | ||
| MicroShift Specific,SDN:Platform:MicroShift | ||
| CNCC,SDN:Platform:CNCC | ||
| Ingress Node Firewall,SDN:Platform:IngressNodeFirewall | ||
| OVNK/OVN (anything that doesn't fit on the feature level),SDN:Platform:OVNK | ||
| "MCO, ConfigureOVS",SDN:Platform:OVS-Configure | ||
| SAST Scans,SDN-SAST-SCAN | ||
| Scale,SDN:Scale | ||
| "RBAC, NodeIdentity, Certificates",SDN:Security | ||
| CVE,SDN:CVE | ||
| CI,SDN:CI | ||
| "ART Bumps, Dockerfile changes, OVN Bump",SDN-ART-BUMP | ||
| "MustGather, NetworkTools",SDN:Tooling | ||
| Metrics,SDN:Metrics | ||
| SNO,SDN:Platform:SNO | ||
| Secondary Networks (NAD),SDN:OVNK:SecondaryNetworks | ||
| UDN Primary,SDN:OVNK:UserDefinedNetworks:Primary | ||
| UDN Secondary,SDN:OVNK:UserDefinedNetworks:Secondary | ||
| BGP Area,SDN:OVNK:BGP | ||
| QE can reproduce from customer bug,QE:Reproduced | ||
| EgressQoS,SDN:OVNK:EgressQoS | ||
| EgressIP,SDN:OVNK:EgressIP | ||
| EgressFirewall,SDN:OVNK:EgressFirewall | ||
| IPSEC,SDN:OVNK:IPSEC | ||
| APBRoute,SDN:OVNK:APBR | ||
| NetworkPolicy,SDN:OVNK:NetworkPolicy | ||
| AdminNetworkPolicy,SDN:OVNK:AdminNetworkPolicy | ||
| Multicast,SDN:OVNK:Multicast | ||
| HCP Live Migration,SDN:OVNK:KubevirtVMLiveMigration | ||
| CNI Live Migration,SDN:OVNK:CNILiveMigration | ||
| CNI Offline Migration,SDN:OVNK:CNIOfflineMigration | ||
| OVNK MTU Migration,SDN:OVNK:MTUMigration | ||
| EgressRouter,SDN:OVNK:EgressRouter | ||
| "Services, EndpointSlices",SDN:OVNK:SVC&EPS | ||
| "IPAM, AddLogicalPort, PodCNI",SDN:OVNK:Pods | ||
| "Anything in NodePkg, Gateway",SDN:OVNK:NodeController | ||
| Anything in DefaultNetController,SDN:OVNK:ZoneController | ||
| Anything in ClusterManager,SDN:OVNK:ClusterManager | ||
| old ICNI ones <=4.13,SDN:OVNK:ICNI | ||
| DPU,SDN:OVNK:DPU | ||
| Egress service,SDN:OVNK:EgressService |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can dry-run option run from network_bugs_overview script ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, but I can add it if you think you'll need it.