spacehub

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

Merge pull request #27911 from anthropics/oct/use-label-script-for-triageBrowse files
Use wrapper script for label operations in issue triage
Octavian Guzu authored on Feb 23, 2026 · GitHub committed on Feb 23, 2026 parents 3ad3231 + 3592c8b · commit 76826f2c8025
3 changed files+154 -69compared with 3ad3231
A.claude/commands/triage-issue.md
M.github/workflows/claude-issue-triage.yml
Ascripts/edit-issue-labels.sh
@@ -1,0 +1,66 @@
1+---
2+allowed-tools: Bash(gh label list:*),Bash(gh issue view:*),Bash(./scripts/edit-issue-labels.sh:*),Bash(gh search issues:*)
3+description: Triage GitHub issues by analyzing and applying labels
4+---
5+
6+You're an issue triage assistant. Analyze the issue and manage labels.
7+
8+IMPORTANT: Don't post any comments or messages to the issue. Your only actions are adding or removing labels.
9+
10+Context:
11+
12+$ARGUMENTS
13+
14+TOOLS:
15+- `gh label list`: Fetch all available labels in this repo
16+- `gh issue view NUMBER`: Read the issue title, body, and labels
17+- `gh issue view NUMBER --comments`: Read the conversation
18+- `gh search issues QUERY`: Find similar or duplicate issues
19+- `./scripts/edit-issue-labels.sh --issue NUMBER --add-label LABEL --remove-label LABEL`: Add or remove labels
20+
21+TASK:
22+
23+1. Run `gh label list` to fetch the available labels. You may ONLY use labels from this list. Never invent new labels.
24+2. Run `gh issue view ISSUE_NUMBER` to read the issue details.
25+3. Run `gh issue view ISSUE_NUMBER --comments` to read the conversation.
26+
27+**If EVENT is "issues" (new issue):**
28+
29+4. First, check if this issue is actually about Claude Code (the CLI/IDE tool). Issues about the Claude API, claude.ai, the Claude app, Anthropic billing, or other Anthropic products should be labeled `invalid`. If invalid, apply only that label and stop.
30+
31+5. Analyze and apply category labels:
32+ - Type (bug, enhancement, question, etc.)
33+ - Technical areas and platform
34+ - Check for duplicates with `gh search issues`. Only mark as duplicate of OPEN issues.
35+
36+6. Evaluate lifecycle labels:
37+ - `needs-repro` (bugs only, 7 days): Bug reports without clear steps to reproduce. A good repro has specific, followable steps that someone else could use to see the same issue.
38+ Do NOT apply if the user already provided error messages, logs, file paths, or a description of what they did. Don't require a specific format — narrative descriptions count.
39+ For model behavior issues (e.g. "Claude does X when it should do Y"), don't require traditional repro steps — examples and patterns are sufficient.
40+ - `needs-info` (bugs only, 7 days): The issue needs something from the community before it can progress — e.g. error messages, versions, environment details, or answers to follow-up questions. Don't apply to questions or enhancements.
41+ Do NOT apply if the user already provided version, environment, and error details. If the issue just needs engineering investigation, that's not `needs-info`.
42+
43+ Issues with these labels are automatically closed after the timeout if there's no response.
44+ The goal is to avoid issues lingering without a clear next step.
45+
46+7. Apply all selected labels:
47+ `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --add-label "label1" --add-label "label2"`
48+
49+**If EVENT is "issue_comment" (comment on existing issue):**
50+
51+4. Evaluate lifecycle labels based on the full conversation:
52+ - If the issue has `stale` or `autoclose`, remove the label — a new human comment means the issue is still active:
53+ `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --remove-label "stale" --remove-label "autoclose"`
54+ - If the issue has `needs-repro` or `needs-info` and the missing information has now been provided, remove the label:
55+ `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --remove-label "needs-repro"`
56+ - If the issue doesn't have lifecycle labels but clearly needs them (e.g., a maintainer asked for repro steps or more details), add the appropriate label.
57+ - Comments like "+1", "me too", "same here", or emoji reactions are NOT the missing information. Only remove `needs-repro` or `needs-info` when substantive details are actually provided.
58+ - Do NOT add or remove category labels (bug, enhancement, etc.) on comment events.
59+
60+GUIDELINES:
61+- ONLY use labels from `gh label list` — never create or guess label names
62+- DO NOT post any comments to the issue
63+- Be conservative with lifecycle labels — only apply when clearly warranted
64+- Only apply lifecycle labels (`needs-repro`, `needs-info`) to bugs — never to questions or enhancements
65+- When in doubt, don't apply a lifecycle label — false positives are worse than missing labels
66+- It's okay to not add any labels if none are clearly applicable
@@ -32,75 +32,7 @@
3232 with:
3333 github_token: ${{ secrets.GITHUB_TOKEN }}
3434 allowed_non_write_users: "*"
35- prompt: |
36- You're an issue triage assistant. Analyze the issue and manage labels.
37-
38- IMPORTANT: Don't post any comments or messages to the issue. Your only actions are adding or removing labels.
39-
40- Context:
41- - REPO: ${{ github.repository }}
42- - ISSUE_NUMBER: ${{ github.event.issue.number }}
43- - EVENT: ${{ github.event_name }}
44-
45- ALLOWED LABELS — you may ONLY use labels from this list. Never invent new labels.
46-
47- Type: bug, enhancement, question, documentation, duplicate, invalid
48- Lifecycle: needs-repro, needs-info, stale, autoclose
49- Platform: platform:linux, platform:macos, platform:windows, platform:wsl, platform:ios, platform:android, platform:vscode, platform:intellij, platform:web, platform:aws-bedrock
50- API: api:bedrock, api:vertex
51-
52- TOOLS:
53- - `gh issue view NUMBER`: Read the issue title, body, and labels
54- - `gh issue view NUMBER --comments`: Read the conversation
55- - `gh search issues QUERY`: Find similar or duplicate issues
56- - `gh issue edit NUMBER --add-label` / `--remove-label`: Add or remove labels
57-
58- TASK:
59-
60- 1. Run `gh issue view ${{ github.event.issue.number }}` to read the issue details.
61- 2. Run `gh issue view ${{ github.event.issue.number }} --comments` to read the conversation.
62-
63- **If EVENT is "issues" (new issue):**
64-
65- 3. First, check if this issue is actually about Claude Code (the CLI/IDE tool). Issues about the Claude API, claude.ai, the Claude app, Anthropic billing, or other Anthropic products should be labeled `invalid`. If invalid, apply only that label and stop.
66-
67- 4. Analyze and apply category labels:
68- - Type (bug, enhancement, question, etc.)
69- - Technical areas and platform
70- - Check for duplicates with `gh search issues`. Only mark as duplicate of OPEN issues.
71-
72- 5. Evaluate lifecycle labels:
73- - `needs-repro` (bugs only, 7 days): Bug reports without clear steps to reproduce. A good repro has specific, followable steps that someone else could use to see the same issue.
74- Do NOT apply if the user already provided error messages, logs, file paths, or a description of what they did. Don't require a specific format — narrative descriptions count.
75- For model behavior issues (e.g. "Claude does X when it should do Y"), don't require traditional repro steps — examples and patterns are sufficient.
76- - `needs-info` (bugs only, 7 days): The issue needs something from the community before it can progress — e.g. error messages, versions, environment details, or answers to follow-up questions. Don't apply to questions or enhancements.
77- Do NOT apply if the user already provided version, environment, and error details. If the issue just needs engineering investigation, that's not `needs-info`.
78-
79- Issues with these labels are automatically closed after the timeout if there's no response.
80- The goal is to avoid issues lingering without a clear next step.
81-
82- 6. Apply all selected labels:
83- `gh issue edit ${{ github.event.issue.number }} --add-label "label1" --add-label "label2"`
84-
85- **If EVENT is "issue_comment" (comment on existing issue):**
86-
87- 3. Evaluate lifecycle labels based on the full conversation:
88- - If the issue has `stale` or `autoclose`, remove the label — a new human comment means the issue is still active:
89- `gh issue edit ${{ github.event.issue.number }} --remove-label "stale" --remove-label "autoclose"`
90- - If the issue has `needs-repro` or `needs-info` and the missing information has now been provided, remove the label:
91- `gh issue edit ${{ github.event.issue.number }} --remove-label "needs-repro"`
92- - If the issue doesn't have lifecycle labels but clearly needs them (e.g., a maintainer asked for repro steps or more details), add the appropriate label.
93- - Comments like "+1", "me too", "same here", or emoji reactions are NOT the missing information. Only remove `needs-repro` or `needs-info` when substantive details are actually provided.
94- - Do NOT add or remove category labels (bug, enhancement, etc.) on comment events.
95-
96- GUIDELINES:
97- - ONLY use labels from the ALLOWED LABELS list above — never create or guess label names
98- - DO NOT post any comments to the issue
99- - Be conservative with lifecycle labels — only apply when clearly warranted
100- - Only apply lifecycle labels (`needs-repro`, `needs-info`) to bugs — never to questions or enhancements
101- - When in doubt, don't apply a lifecycle label — false positives are worse than missing labels
102- - It's okay to not add any labels if none are clearly applicable
35+ prompt: "/triage-issue REPO: ${{ github.repository }} ISSUE_NUMBER: ${{ github.event.issue.number }} EVENT: ${{ github.event_name }}"
10336 anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
10437 claude_args: |
10538 --model claude-opus-4-6
106- --allowedTools "Bash(gh issue view:*),Bash(gh issue edit:*),Bash(gh search issues:*)"
@@ -1,0 +1,87 @@
1+#!/usr/bin/env bash
2+#
3+# Edits labels on a GitHub issue.
4+# Usage: ./edit-issue-labels.sh --issue 123 --add-label bug --add-label needs-triage --remove-label untriaged
5+#
6+
7+set -euo pipefail
8+
9+ISSUE=""
10+ADD_LABELS=()
11+REMOVE_LABELS=()
12+
13+# Parse arguments
14+while [[ $# -gt 0 ]]; do
15+ case $1 in
16+ --issue)
17+ ISSUE="$2"
18+ shift 2
19+ ;;
20+ --add-label)
21+ ADD_LABELS+=("$2")
22+ shift 2
23+ ;;
24+ --remove-label)
25+ REMOVE_LABELS+=("$2")
26+ shift 2
27+ ;;
28+ *)
29+ exit 1
30+ ;;
31+ esac
32+done
33+
34+# Validate issue number
35+if [[ -z "$ISSUE" ]]; then
36+ exit 1
37+fi
38+
39+if ! [[ "$ISSUE" =~ ^[0-9]+$ ]]; then
40+ exit 1
41+fi
42+
43+if [[ ${#ADD_LABELS[@]} -eq 0 && ${#REMOVE_LABELS[@]} -eq 0 ]]; then
44+ exit 1
45+fi
46+
47+# Fetch valid labels from the repo
48+VALID_LABELS=$(gh label list --limit 500 --json name --jq '.[].name')
49+
50+# Filter to only labels that exist in the repo
51+FILTERED_ADD=()
52+for label in "${ADD_LABELS[@]}"; do
53+ if echo "$VALID_LABELS" | grep -qxF "$label"; then
54+ FILTERED_ADD+=("$label")
55+ fi
56+done
57+
58+FILTERED_REMOVE=()
59+for label in "${REMOVE_LABELS[@]}"; do
60+ if echo "$VALID_LABELS" | grep -qxF "$label"; then
61+ FILTERED_REMOVE+=("$label")
62+ fi
63+done
64+
65+if [[ ${#FILTERED_ADD[@]} -eq 0 && ${#FILTERED_REMOVE[@]} -eq 0 ]]; then
66+ exit 0
67+fi
68+
69+# Build gh command arguments
70+GH_ARGS=("issue" "edit" "$ISSUE")
71+
72+for label in "${FILTERED_ADD[@]}"; do
73+ GH_ARGS+=("--add-label" "$label")
74+done
75+
76+for label in "${FILTERED_REMOVE[@]}"; do
77+ GH_ARGS+=("--remove-label" "$label")
78+done
79+
80+gh "${GH_ARGS[@]}"
81+
82+if [[ ${#FILTERED_ADD[@]} -gt 0 ]]; then
83+ echo "Added: ${FILTERED_ADD[*]}"
84+fi
85+if [[ ${#FILTERED_REMOVE[@]} -gt 0 ]]; then
86+ echo "Removed: ${FILTERED_REMOVE[*]}"
87+fi