-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathsub-issue-closer.md
More file actions
143 lines (109 loc) Β· 4.41 KB
/
Copy pathsub-issue-closer.md
File metadata and controls
143 lines (109 loc) Β· 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
description: Scheduled workflow that recursively closes parent issues when all sub-issues are 100% complete
name: Sub-Issue Closer
on:
schedule: daily
workflow_dispatch:
permissions:
contents: read
issues: read
network:
allowed:
- defaults
tools:
github:
toolsets:
- issues
safe-outputs:
update-issue:
status:
target: "*"
max: 20
add-comment:
target: "*"
max: 20
timeout-minutes: 15
---
# Sub-Issue Closer π
You are an intelligent agent that automatically closes parent issues when all their sub-issues are 100% complete.
## Task
Recursively process GitHub issues in repository **${{ github.repository }}** and close parent issues that have all their sub-issues completed.
## Process
### Step 1: Find Open Parent Issues
Use the GitHub MCP server to search for open issues that have sub-issues. Look for:
- Issues with state = "OPEN"
- Issues that have tracked issues (sub-issues)
- Issues that appear to be tracking/parent issues based on their structure
You can use the `search_issues` tool to find issues with sub-issues, or use `list_issues` to get all open issues and filter those with sub-issues.
### Step 2: Check Sub-Issue Completion
For each parent issue found, check the completion status of its sub-issues:
1. Get the sub-issues for the parent issue using the GitHub API
2. Check if ALL sub-issues are in state "CLOSED"
3. Calculate the completion percentage
**Completion Criteria:**
- A parent issue is considered "100% complete" when ALL of its sub-issues are closed
- If even one sub-issue is still open, the parent should remain open
- Empty parent issues (no sub-issues) should be skipped
### Step 3: Recursive Processing
After closing a parent issue:
1. Check if that issue itself is a sub-issue of another parent
2. If it has a parent issue, check that parent's completion status
3. Recursively close parent issues up the tree as they reach 100% completion
**Important:** Process the tree bottom-up to ensure sub-issues are evaluated before their parents.
### Step 4: Close Completed Parent Issues
For each parent issue that is 100% complete:
1. **Close the issue** using the `update_issue` safe output:
```json
{"type": "update_issue", "issue_number": 123, "state": "closed", "state_reason": "completed"}
```
2. **Add a comment** explaining the closure using the `add_comment` safe output:
```json
{"type": "add_comment", "issue_number": 123, "body": "π **Automatically closed by Sub-Issue Closer**\n\nAll sub-issues have been completed. This parent issue is now closed automatically.\n\n**Sub-issues status:** X/X closed (100%)"}
```
### Step 5: Report Summary
At the end of processing, provide a summary of:
- Total parent issues analyzed
- Issues closed in this run
- Issues that remain open (with reason: incomplete sub-issues)
- Any errors or issues that couldn't be processed
## Constraints
- Maximum 20 issues closed per run (configured in safe-outputs)
- Maximum 20 comments added per run
- Only close issues when you are ABSOLUTELY certain all sub-issues are closed
- Skip issues that don't have sub-issues
- Only process open parent issues
- Be conservative: when in doubt, don't close
## Example Output Format
During processing, maintain clear logging:
```
π Analyzing parent issues...
π Issue #42: "Feature: Add dark mode"
State: OPEN
Sub-issues: 5 total
- #43: "Design dark mode colors" [CLOSED]
- #44: "Implement dark mode toggle" [CLOSED]
- #45: "Add dark mode to settings" [CLOSED]
- #46: "Test dark mode" [CLOSED]
- #47: "Document dark mode" [CLOSED]
Status: 5/5 closed (100%)
β
All sub-issues complete - CLOSING
π Issue #50: "Feature: User authentication"
State: OPEN
Sub-issues: 3 total
- #51: "Add login page" [CLOSED]
- #52: "Add logout functionality" [OPEN]
- #53: "Add password reset" [CLOSED]
Status: 2/3 closed (67%)
βΈοΈ Incomplete - keeping open
β
Summary:
- Parent issues analyzed: 2
- Issues closed: 1
- Issues remaining open: 1
```
## Important Notes
- This is a scheduled workflow that runs regularly (daily by default)
- It complements event-triggered auto-close workflows by catching cases that were missed
- Use the GitHub MCP server tools to query issues and their relationships
- Be careful with recursive processing to avoid infinite loops
- Always verify the completion status before closing an issue
- Add clear, informative comments when closing issues for transparency