Skip to content

Commit f52a8af

Browse files
committed
Add more CLAUDE
1 parent 847498c commit f52a8af

File tree

5 files changed

+270
-0
lines changed

5 files changed

+270
-0
lines changed

.claude/commands/label-issues.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
allowed-tools: Bash(gh label list:*),Bash(gh issue view:*),Bash(gh issue edit:*),Bash(gh search:*)
3+
description: Apply labels to GitHub issues
4+
---
5+
6+
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
7+
8+
IMPORTANT: Don't post any comments or messages to the issue. Your only action should be to apply labels.
9+
10+
Issue Information:
11+
12+
- REPO: ${{ github.repository }}
13+
- ISSUE_NUMBER: ${{ github.event.issue.number }}
14+
15+
TASK OVERVIEW:
16+
17+
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
18+
19+
2. Next, use gh commands to get context about the issue:
20+
21+
- Use `gh issue view ${{ github.event.issue.number }}` to retrieve the current issue's details
22+
- Use `gh search issues` to find similar issues that might provide context for proper categorization
23+
- You have access to these Bash commands:
24+
- Bash(gh label list:\*) - to get available labels
25+
- Bash(gh issue view:\*) - to view issue details
26+
- Bash(gh issue edit:\*) - to apply labels to the issue
27+
- Bash(gh search:\*) - to search for similar issues
28+
29+
3. Analyze the issue content, considering:
30+
31+
- The issue title and description
32+
- The type of issue (bug report, feature request, question, etc.)
33+
- Technical areas mentioned
34+
- Severity or priority indicators
35+
- User impact
36+
- Components affected
37+
38+
4. Select appropriate labels from the available labels list provided above:
39+
40+
- Choose labels that accurately reflect the issue's nature
41+
- Be specific but comprehensive
42+
- IMPORTANT: Add a priority label (P1, P2, or P3) based on the label descriptions from gh label list
43+
- Consider platform labels (android, ios) if applicable
44+
- If you find similar issues using gh search, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
45+
46+
5. Apply the selected labels:
47+
- Use `gh issue edit` to apply your selected labels
48+
- DO NOT post any comments explaining your decision
49+
- DO NOT communicate directly with users
50+
- If no labels are clearly applicable, do not apply any labels
51+
52+
IMPORTANT GUIDELINES:
53+
54+
- Be thorough in your analysis
55+
- Only select labels from the provided list above
56+
- DO NOT post any comments to the issue
57+
- Your ONLY action should be to apply labels using gh issue edit
58+
- It's okay to not add any labels if none are clearly applicable
59+
60+
---

.github/workflows/claude-code-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
with:
3838
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
3939
use_sticky_comment: true
40+
track_progress: true
4041
prompt: |
4142
REPO: ${{ github.repository }}
4243
PR NUMBER: ${{ github.event.pull_request.number }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Issue Deduplication
3+
4+
on:
5+
issues:
6+
types: [opened]
7+
8+
jobs:
9+
deduplicate:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
permissions:
13+
contents: read
14+
issues: write
15+
id-token: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 1
22+
23+
- name: Check for duplicate issues
24+
uses: anthropics/claude-code-action@v1
25+
with:
26+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
27+
prompt: |
28+
Analyze this new issue and check if it's a duplicate of existing issues in the repository.
29+
30+
Issue: #${{ github.event.issue.number }}
31+
Repository: ${{ github.repository }}
32+
33+
Your task:
34+
1. Use mcp__github__get_issue to get details of the current issue (#${{ github.event.issue.number }})
35+
2. Search for similar existing issues using mcp__github__search_issues with relevant keywords from the issue title and body
36+
3. Compare the new issue with existing ones to identify potential duplicates
37+
38+
Criteria for duplicates:
39+
- Same bug or error being reported
40+
- Same feature request (even if worded differently)
41+
- Same question being asked
42+
- Issues describing the same root problem
43+
44+
If you find duplicates:
45+
- Add a comment on the new issue linking to the original issue(s)
46+
- Apply a "duplicate" label to the new issue
47+
- Be polite and explain why it's a duplicate
48+
- Suggest the user follow the original issue for updates
49+
50+
If it's NOT a duplicate:
51+
- Don't add any comments
52+
- You may apply appropriate topic labels based on the issue content
53+
54+
Use these tools:
55+
- mcp__github__get_issue: Get issue details
56+
- mcp__github__search_issues: Search for similar issues
57+
- mcp__github__list_issues: List recent issues if needed
58+
- mcp__github__create_issue_comment: Add a comment if duplicate found
59+
- mcp__github__update_issue: Add labels
60+
61+
Be thorough but efficient. Focus on finding true duplicates, not just similar issues.
62+
63+
claude_args: |
64+
--allowedTools "mcp__github__get_issue,mcp__github__search_issues,mcp__github__list_issues,mcp__github__create_issue_comment,mcp__github__update_issue,mcp__github__get_issue_comments"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Claude Issue Triage
3+
description: Run Claude Code for issue triage in GitHub Actions
4+
on:
5+
issues:
6+
types: [opened]
7+
8+
jobs:
9+
triage-issue:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
permissions:
13+
contents: read
14+
issues: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Run Claude Code for Issue Triage
23+
uses: anthropics/claude-code-action@v1
24+
with:
25+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
# NOTE: /label-issue here requires a .claude/commands/label-issue.md file in your repo (see this repo's .claude directory for an example)
28+
prompt: "/label-issue REPO: ${{ github.repository }} ISSUE_NUMBER${{ github.event.issue.number }}"
29+
30+
allowed_non_write_users: "*" # Required for issue triage workflow, if users without repo write access create issues
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
name: Auto-Retry Flaky Tests
3+
4+
# This example demonstrates using structured outputs to detect flaky test failures
5+
# and automatically retry them, reducing noise from intermittent failures.
6+
#
7+
# Use case: When CI fails, automatically determine if it's likely flaky and retry if so.
8+
9+
on:
10+
workflow_run:
11+
workflows: ["CI"]
12+
types: [completed]
13+
14+
permissions:
15+
contents: read
16+
actions: write
17+
18+
jobs:
19+
detect-flaky:
20+
runs-on: ubuntu-latest
21+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Detect flaky test failures
27+
id: detect
28+
uses: anthropics/claude-code-action@main
29+
with:
30+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
31+
prompt: |
32+
The CI workflow failed: ${{ github.event.workflow_run.html_url }}
33+
34+
Check the logs: gh run view ${{ github.event.workflow_run.id }} --log-failed
35+
36+
Determine if this looks like a flaky test failure by checking for:
37+
- Timeout errors
38+
- Race conditions
39+
- Network errors
40+
- "Expected X but got Y" intermittent failures
41+
- Tests that passed in previous commits
42+
43+
Return:
44+
- is_flaky: true if likely flaky, false if real bug
45+
- confidence: number 0-1 indicating confidence level
46+
- summary: brief one-sentence explanation
47+
claude_args: |
48+
--json-schema '{"type":"object","properties":{"is_flaky":{"type":"boolean","description":"Whether this appears to be a flaky test failure"},"confidence":{"type":"number","minimum":0,"maximum":1,"description":"Confidence level in the determination"},"summary":{"type":"string","description":"One-sentence explanation of the failure"}},"required":["is_flaky","confidence","summary"]}'
49+
50+
# Auto-retry only if flaky AND high confidence (>= 0.7)
51+
- name: Retry flaky tests
52+
if: |
53+
fromJSON(steps.detect.outputs.structured_output).is_flaky == true &&
54+
fromJSON(steps.detect.outputs.structured_output).confidence >= 0.7
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
run: |
58+
OUTPUT='${{ steps.detect.outputs.structured_output }}'
59+
CONFIDENCE=$(echo "$OUTPUT" | jq -r '.confidence')
60+
SUMMARY=$(echo "$OUTPUT" | jq -r '.summary')
61+
62+
echo "🔄 Flaky test detected (confidence: $CONFIDENCE)"
63+
echo "Summary: $SUMMARY"
64+
echo ""
65+
echo "Triggering automatic retry..."
66+
67+
gh workflow run "${{ github.event.workflow_run.name }}" \
68+
--ref "${{ github.event.workflow_run.head_branch }}"
69+
70+
# Low confidence flaky detection - skip retry
71+
- name: Low confidence detection
72+
if: |
73+
fromJSON(steps.detect.outputs.structured_output).is_flaky == true &&
74+
fromJSON(steps.detect.outputs.structured_output).confidence < 0.7
75+
run: |
76+
OUTPUT='${{ steps.detect.outputs.structured_output }}'
77+
CONFIDENCE=$(echo "$OUTPUT" | jq -r '.confidence')
78+
79+
echo "⚠️ Possible flaky test but confidence too low ($CONFIDENCE)"
80+
echo "Not retrying automatically - manual review recommended"
81+
82+
# Comment on PR if this was a PR build
83+
- name: Comment on PR
84+
if: github.event.workflow_run.event == 'pull_request'
85+
env:
86+
GH_TOKEN: ${{ github.token }}
87+
run: |
88+
OUTPUT='${{ steps.detect.outputs.structured_output }}'
89+
IS_FLAKY=$(echo "$OUTPUT" | jq -r '.is_flaky')
90+
CONFIDENCE=$(echo "$OUTPUT" | jq -r '.confidence')
91+
SUMMARY=$(echo "$OUTPUT" | jq -r '.summary')
92+
93+
pr_number=$(gh pr list --head "${{ github.event.workflow_run.head_branch }}" --json number --jq '.[0].number')
94+
95+
if [ -n "$pr_number" ]; then
96+
if [ "$IS_FLAKY" = "true" ]; then
97+
TITLE="🔄 Flaky Test Detected"
98+
ACTION="✅ Automatically retrying the workflow"
99+
else
100+
TITLE="❌ Test Failure"
101+
ACTION="⚠️ This appears to be a real bug - manual intervention needed"
102+
fi
103+
104+
gh pr comment "$pr_number" --body "$(cat <<EOF
105+
## $TITLE
106+
107+
**Analysis**: $SUMMARY
108+
**Confidence**: $CONFIDENCE
109+
110+
$ACTION
111+
112+
[View workflow run](${{ github.event.workflow_run.html_url }})
113+
EOF
114+
)"
115+
fi

0 commit comments

Comments
 (0)