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

Add auto-close functionality for duplicate issuesBrowse files
- Update dedupe command to include auto-close warning
- Add commit-push-pr command for streamlined workflow
- Add GitHub workflow to automatically close duplicates

๐Ÿค– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Boris Cherny authored on Aug 5, 2025 parent 5faa082 ยท commit 3d5ef4e8c010
3 changed files+116 -0compared with 5faa082
A.claude/commands/commit-push-pr.md
M.claude/commands/dedupe.md
A.github/workflows/auto-close-duplicates.yml
@@ -1,0 +1,19 @@
1+---
2+allowed-tools: Bash(git checkout --branch:*), Bash(git add:*), Bash(git status:*), Bash(git push:*), Bash(git commit:*), Bash(gh pr create:*)
3+description: Commit, push, and open a PR
4+---
5+
6+## Context
7+
8+- Current git status: !`git status`
9+- Current git diff (staged and unstaged changes): !`git diff HEAD`
10+- Current branch: !`git branch --show-current`
11+
12+## Your task
13+
14+Based on the above changes:
15+1. Create a new branch if on main
16+2. Create a single commit with an appropriate message
17+3. Push the branch to origin
18+4. Create a pull request using `gh pr create`
19+5. You have the capability to call multiple tools in a single response. You MUST do all of the above in a single message. Do not use any other tools or do anything else. Do not send any other text or messages besides these tool calls.
@@ -30,6 +30,8 @@
3030
3131 If your issue is a duplicate, please close it and ๐Ÿ‘ the existing issue instead.
3232
33+<sub>This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please ๐Ÿ‘Ž this comment.</sub>
34+
3335 ๐Ÿค– Generated with [Claude Code](https://claude.ai/code)
3436
3537 ---
@@ -1,0 +1,95 @@
1+name: Auto-close duplicate issues
2+description: Auto-close issues marked as duplicates after 3 days if no response
3+on:
4+ schedule:
5+ - cron: '0 9 * * *'
6+
7+jobs:
8+ auto-close-duplicates:
9+ runs-on: ubuntu-latest
10+ timeout-minutes: 10
11+ permissions:
12+ contents: read
13+ issues: write
14+
15+ steps:
16+ - name: Auto-close duplicate issues
17+ uses: actions/github-script@v7
18+ with:
19+ script: |
20+ const threeDaysAgo = new Date();
21+ threeDaysAgo.setDate(threeDaysAgo.getDate() - 3);
22+
23+ // Get all open issues
24+ const { data: issues } = await github.rest.issues.listForRepo({
25+ owner: context.repo.owner,
26+ repo: context.repo.repo,
27+ state: 'open',
28+ per_page: 100
29+ });
30+
31+ for (const issue of issues) {
32+ // Get comments for this issue
33+ const { data: comments } = await github.rest.issues.listComments({
34+ owner: context.repo.owner,
35+ repo: context.repo.repo,
36+ issue_number: issue.number
37+ });
38+
39+ // Find duplicate comments (look for "Found 1 possible duplicate" or "Found X possible duplicate")
40+ const dupeComments = comments.filter(comment =>
41+ comment.body.includes('Found') &&
42+ comment.body.includes('possible duplicate') &&
43+ comment.user.type === 'Bot'
44+ );
45+
46+ if (dupeComments.length === 0) continue;
47+
48+ // Get the most recent duplicate comment
49+ const lastDupeComment = dupeComments[dupeComments.length - 1];
50+ const dupeCommentDate = new Date(lastDupeComment.created_at);
51+
52+ // Check if the duplicate comment is 3+ days old
53+ if (dupeCommentDate > threeDaysAgo) continue;
54+
55+ // Check if there are any comments after the duplicate comment
56+ const commentsAfterDupe = comments.filter(comment =>
57+ new Date(comment.created_at) > dupeCommentDate
58+ );
59+
60+ if (commentsAfterDupe.length > 0) continue;
61+
62+ // Check if issue author reacted with thumbs down to the duplicate comment
63+ const { data: reactions } = await github.rest.reactions.listForIssueComment({
64+ owner: context.repo.owner,
65+ repo: context.repo.repo,
66+ comment_id: lastDupeComment.id
67+ });
68+
69+ const authorThumbsDown = reactions.some(reaction =>
70+ reaction.user.id === issue.user.id && reaction.content === '-1'
71+ );
72+
73+ if (authorThumbsDown) continue;
74+
75+ // Auto-close the issue as duplicate
76+ await github.rest.issues.update({
77+ owner: context.repo.owner,
78+ repo: context.repo.repo,
79+ issue_number: issue.number,
80+ state: 'closed',
81+ state_reason: 'duplicate'
82+ });
83+
84+ // Add closing comment
85+ await github.rest.issues.createComment({
86+ owner: context.repo.owner,
87+ repo: context.repo.repo,
88+ issue_number: issue.number,
89+ body: `This issue has been automatically closed as a duplicate after 3 days with no response. If this was closed in error, please reopen it.
90+
91+๐Ÿค– Generated with Claude Code`
92+ });
93+
94+ console.log(`Auto-closed issue #${issue.number} as duplicate`);
95+ }