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

Read issue number from workflow event in helper scripts (#40969)Browse files
Updates edit-issue-labels.sh and comment-on-duplicates.sh to read the
issue number from GITHUB_EVENT_PATH (the workflow event payload) instead
of accepting it as a CLI argument. Simplifies the call signature and
keeps the scripts aligned with the triggering issue.

Also updates the /triage-issue and /dedupe command docs to match.

:house: Remote-Dev: homespace
Octavian Guzu authored on Mar 31, 2026 · GitHub committed on Mar 31, 2026 parent 2d5c1ba · commit 4411cbae0982
6 changed files+32 -38compared with 2d5c1ba
M.claude/commands/dedupe.md
M.claude/commands/triage-issue.md
M.github/workflows/claude-dedupe-issues.yml
M.github/workflows/claude-issue-triage.yml
Mscripts/comment-on-duplicates.sh
Mscripts/edit-issue-labels.sh
@@ -13,7 +13,7 @@
1313 4. Next, feed the results from #1 and #2 into another agent, so that it can filter out false positives, that are likely not actually duplicates of the original issue. If there are no duplicates remaining, do not proceed.
1414 5. Finally, use the comment script to post duplicates:
1515 ```
16- ./scripts/comment-on-duplicates.sh --base-issue <issue-number> --potential-duplicates <dup1> <dup2> <dup3>
16+ ./scripts/comment-on-duplicates.sh --potential-duplicates <dup1> <dup2> <dup3>
1717 ```
1818
1919 Notes (be sure to tell this to your agents, too):
@@ -20,7 +20,7 @@
2020 - `./scripts/gh.sh issue list --state open --limit 20` — list issues
2121 - `./scripts/gh.sh search issues "query"` — find similar or duplicate issues
2222 - `./scripts/gh.sh search issues "query" --limit 10` — search with limit
23-- `./scripts/edit-issue-labels.sh --issue NUMBER --add-label LABEL --remove-label LABEL` — add or remove labels
23+- `./scripts/edit-issue-labels.sh --add-label LABEL --remove-label LABEL` — add or remove labels (issue number is read from the workflow event)
2424
2525 TASK:
2626
@@ -48,15 +48,15 @@
4848 The goal is to avoid issues lingering without a clear next step.
4949
5050 7. Apply all selected labels:
51- `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --add-label "label1" --add-label "label2"`
51+ `./scripts/edit-issue-labels.sh --add-label "label1" --add-label "label2"`
5252
5353 **If EVENT is "issue_comment" (comment on existing issue):**
5454
5555 4. Evaluate lifecycle labels based on the full conversation:
5656 - If the issue has `stale` or `autoclose`, remove the label — a new human comment means the issue is still active:
57- `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --remove-label "stale" --remove-label "autoclose"`
57+ `./scripts/edit-issue-labels.sh --remove-label "stale" --remove-label "autoclose"`
5858 - If the issue has `needs-repro` or `needs-info` and the missing information has now been provided, remove the label:
59- `./scripts/edit-issue-labels.sh --issue ISSUE_NUMBER --remove-label "needs-repro"`
59+ `./scripts/edit-issue-labels.sh --remove-label "needs-repro"`
6060 - 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.
6161 - 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.
6262 - Do NOT add or remove category labels (bug, enhancement, etc.) on comment events.
@@ -26,6 +26,7 @@
2626 uses: anthropics/claude-code-action@v1
2727 env:
2828 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+ CLAUDE_CODE_SCRIPT_CAPS: '{"comment-on-duplicates.sh":1}'
2930 with:
3031 github_token: ${{ secrets.GITHUB_TOKEN }}
3132 allowed_non_write_users: "*"
@@ -29,6 +29,7 @@
2929 env:
3030 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131 GH_REPO: ${{ github.repository }}
32+ CLAUDE_CODE_SCRIPT_CAPS: '{"edit-issue-labels.sh":2}'
3233 with:
3334 github_token: ${{ secrets.GITHUB_TOKEN }}
3435 allowed_non_write_users: "*"
@@ -1,22 +1,28 @@
11 #!/usr/bin/env bash
22 #
33 # Comments on a GitHub issue with a list of potential duplicates.
4-# Usage: ./comment-on-duplicates.sh --base-issue 123 --potential-duplicates 456 789 101
4+# Usage: ./comment-on-duplicates.sh --potential-duplicates 456 789 101
55 #
6+# The base issue number is read from the workflow event payload.
7+#
68
79 set -euo pipefail
810
911 REPO="anthropics/claude-code"
10-BASE_ISSUE=""
12+
13+# Read from event payload so the issue number is bound to the triggering event.
14+# Falls back to workflow_dispatch inputs for manual runs.
15+BASE_ISSUE=$(jq -r '.issue.number // .inputs.issue_number // empty' "${GITHUB_EVENT_PATH:?GITHUB_EVENT_PATH not set}")
16+if ! [[ "$BASE_ISSUE" =~ ^[0-9]+$ ]]; then
17+ echo "Error: no issue number in event payload" >&2
18+ exit 1
19+fi
20+
1121 DUPLICATES=()
1222
1323 # Parse arguments
1424 while [[ $# -gt 0 ]]; do
1525 case $1 in
16- --base-issue)
17- BASE_ISSUE="$2"
18- shift 2
19- ;;
2026 --potential-duplicates)
2127 shift
2228 while [[ $# -gt 0 && ! "$1" =~ ^-- ]]; do
@@ -25,23 +31,12 @@
2531 done
2632 ;;
2733 *)
28- echo "Unknown option: $1" >&2
34+ echo "Error: unknown argument (only --potential-duplicates is accepted)" >&2
2935 exit 1
3036 ;;
3137 esac
3238 done
3339
34-# Validate base issue
35-if [[ -z "$BASE_ISSUE" ]]; then
36- echo "Error: --base-issue is required" >&2
37- exit 1
38-fi
39-
40-if ! [[ "$BASE_ISSUE" =~ ^[0-9]+$ ]]; then
41- echo "Error: --base-issue must be a number, got: $BASE_ISSUE" >&2
42- exit 1
43-fi
44-
4540 # Validate duplicates
4641 if [[ ${#DUPLICATES[@]} -eq 0 ]]; then
4742 echo "Error: --potential-duplicates requires at least one issue number" >&2
@@ -1,22 +1,27 @@
11 #!/usr/bin/env bash
22 #
33 # Edits labels on a GitHub issue.
4-# Usage: ./edit-issue-labels.sh --issue 123 --add-label bug --add-label needs-triage --remove-label untriaged
4+# Usage: ./edit-issue-labels.sh --add-label bug --add-label needs-triage --remove-label untriaged
55 #
6+# The issue number is read from the workflow event payload.
7+#
68
79 set -euo pipefail
810
9-ISSUE=""
11+# Read from event payload so the issue number is bound to the triggering event.
12+# Falls back to workflow_dispatch inputs for manual runs.
13+ISSUE=$(jq -r '.issue.number // .inputs.issue_number // empty' "${GITHUB_EVENT_PATH:?GITHUB_EVENT_PATH not set}")
14+if ! [[ "$ISSUE" =~ ^[0-9]+$ ]]; then
15+ echo "Error: no issue number in event payload" >&2
16+ exit 1
17+fi
18+
1019 ADD_LABELS=()
1120 REMOVE_LABELS=()
1221
1322 # Parse arguments
1423 while [[ $# -gt 0 ]]; do
1524 case $1 in
16- --issue)
17- ISSUE="$2"
18- shift 2
19- ;;
2025 --add-label)
2126 ADD_LABELS+=("$2")
2227 shift 2
@@ -26,20 +31,12 @@
2631 shift 2
2732 ;;
2833 *)
34+ echo "Error: unknown argument (only --add-label and --remove-label are accepted)" >&2
2935 exit 1
3036 ;;
3137 esac
3238 done
3339
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-
4340 if [[ ${#ADD_LABELS[@]} -eq 0 && ${#REMOVE_LABELS[@]} -eq 0 ]]; then
4441 exit 1
4542 fi