surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
Changes the workflow to be event-driven and process fewer issues: - Triggers on issue events (opened, edited, labeled, reopened) and comments - When triggered by event, processes only that specific issue - When running on schedule, only checks issues created in last 7 days - Only adds oncall label, never removes it - Uses search_issues instead of list_issues for better filtering This dramatically reduces the dataset size and makes the workflow more efficient and scalable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| @@ -1,15 +1,19 @@ | ||
| 1 | 1 | name: Claude Oncall Issue Triage |
| 2 | 2 | description: Identify critical issues that require oncall attention |
| 3 | 3 | on: |
| 4 | + issues: | |
| 5 | + types: [opened, edited, labeled, reopened] | |
| 6 | + issue_comment: | |
| 7 | + types: [created] | |
| 4 | 8 | schedule: |
| 5 | - # Run every 6 hours | |
| 9 | + # Run every 6 hours to catch issues that recently crossed the threshold | |
| 6 | 10 | - cron: '0 */6 * * *' |
| 7 | 11 | workflow_dispatch: # Allow manual trigger |
| 8 | 12 | |
| 9 | 13 | jobs: |
| 10 | 14 | oncall-triage: |
| 11 | 15 | runs-on: ubuntu-latest |
| 12 | - timeout-minutes: 15 | |
| 16 | + timeout-minutes: 10 | |
| 13 | 17 | permissions: |
| 14 | 18 | contents: read |
| 15 | 19 | issues: write |
| @@ -27,15 +31,20 @@ | ||
| 27 | 31 | IMPORTANT: Don't post any comments or messages to the issues. Your only action should be to apply the "oncall" label to qualifying issues. |
| 28 | 32 | |
| 29 | 33 | Repository: ${{ github.repository }} |
| 34 | + Triggered by: ${{ github.event_name }} | |
| 35 | + Issue number (if triggered by issue event): ${{ github.event.issue.number }} | |
| 30 | 36 | |
| 31 | 37 | TASK OVERVIEW: |
| 32 | 38 | |
| 33 | - 1. Use mcp__github__list_issues to get all open issues in the repository. | |
| 39 | + 1. Determine which issues to process: | |
| 40 | + - If this workflow was triggered by an issue event (issue number provided above), process ONLY that issue | |
| 41 | + - If triggered by schedule or manual trigger, use mcp__github__search_issues to find issues created in the last 7 days (use query: "is:issue is:open created:>=$(date -d '7 days ago' +%Y-%m-%d)") | |
| 42 | + - This keeps the dataset small and focused on recent activity | |
| 34 | 43 | |
| 35 | - 2. For each issue, gather the following information using the GitHub MCP tools: | |
| 44 | + 2. For each issue to process, gather information using GitHub MCP tools: | |
| 36 | 45 | - Issue details (title, body, labels) using mcp__github__get_issue |
| 37 | 46 | - All comments using mcp__github__get_issue_comments |
| 38 | - - Reaction counts from the issue data (available in the reactionGroups field) | |
| 47 | + - Reaction counts from the reactionGroups field | |
| 39 | 48 | |
| 40 | 49 | 3. Evaluate each issue against the oncall criteria. An issue is oncall-worthy if ALL of the following are true: |
| 41 | 50 | |
| @@ -58,21 +67,20 @@ | ||
| 58 | 67 | - Count total number of comments |
| 59 | 68 | - Sum must be >= 5 |
| 60 | 69 | |
| 61 | - 4. For issues that meet ALL criteria above: | |
| 70 | + 4. For issues that meet ALL criteria above AND don't already have the "oncall" label: | |
| 62 | 71 | - Use mcp__github__update_issue to add the "oncall" label |
| 63 | 72 | - DO NOT post any comments |
| 64 | 73 | - DO NOT remove any existing labels |
| 65 | 74 | |
| 66 | - 5. For issues that already have the "oncall" label but NO LONGER meet the criteria: | |
| 67 | - - Use mcp__github__update_issue to remove the "oncall" label | |
| 68 | - - This keeps the oncall board current | |
| 75 | + 5. Do NOT remove the "oncall" label from any issues | |
| 69 | 76 | |
| 70 | 77 | IMPORTANT GUIDELINES: |
| 71 | 78 | - Be conservative in your assessment - only flag truly critical blocking issues |
| 72 | 79 | - ALL four criteria must be met for an issue to receive the "oncall" label |
| 73 | 80 | - DO NOT post any comments to issues |
| 74 | - - Your ONLY action should be to apply or remove the "oncall" label using mcp__github__update_issue | |
| 75 | - - Process issues systematically and thoroughly | |
| 81 | + - Your ONLY action should be to apply the "oncall" label using mcp__github__update_issue | |
| 82 | + - Only add the label, never remove it | |
| 83 | + - Process efficiently - only check recent issues (last 7 days) when running on schedule | |
| 76 | 84 | EOF |
| 77 | 85 | |
| 78 | 86 | - name: Setup GitHub MCP Server |
| @@ -103,7 +111,7 @@ | ||
| 103 | 111 | uses: anthropics/claude-code-base-action@beta |
| 104 | 112 | with: |
| 105 | 113 | prompt_file: /tmp/claude-prompts/oncall-triage-prompt.txt |
| 106 | - allowed_tools: "mcp__github__list_issues,mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue" | |
| 114 | + allowed_tools: "mcp__github__search_issues,mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue" | |
| 107 | 115 | timeout_minutes: "10" |
| 108 | 116 | anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 109 | 117 | mcp_config: /tmp/mcp-config/mcp-servers.json |