Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
562defc
feat(examples): add automated issue cleanup workflow
cocosheng-g Apr 6, 2026
69bd8f0
fix(lint): YAML quoting in issue cleanup workflow
cocosheng-g Apr 6, 2026
a416cf5
feat(examples): optimize issue cleanup prompt for efficiency
cocosheng-g Apr 6, 2026
0d94b4b
feat(examples): instruct agent to explicitly clone the target repository
cocosheng-g Apr 6, 2026
0eedc99
fix(examples): apply PR review suggestions for issue cleanup workflow
cocosheng-g Apr 6, 2026
298d9d6
feat(examples): allow custom instructions for issue cleanup triage su…
cocosheng-g Apr 6, 2026
cf62bef
feat(examples): support fallback to standard triage summary if custom…
cocosheng-g Apr 6, 2026
1cdeb18
feat(examples): add staleness check and optimize cleanup bot
cocosheng-g Apr 6, 2026
225eca7
feat(examples): separate staleness check from agent via github-script
cocosheng-g Apr 6, 2026
6cee6e8
feat(examples): support explicit maintainers input for staleness check
cocosheng-g Apr 6, 2026
3652158
fix(examples): fix YAML syntax error for MAINTAINERS environment vari…
cocosheng-g Apr 6, 2026
d572273
feat(examples): enable AI to write and execute reproduction scripts t…
cocosheng-g Apr 6, 2026
d0904f5
feat(examples): add 1-month age check for issue cleanup
cocosheng-g Apr 6, 2026
2b10d1f
feat(examples): ask for detailed reproduction steps in 1-month age check
cocosheng-g Apr 6, 2026
55bf172
feat(examples): move 1-month age check to native github-script step
cocosheng-g Apr 6, 2026
67c9554
fix(examples): expand staleness maintainer check to include repositor…
cocosheng-g Apr 6, 2026
7892be4
feat(examples): update issue labels during staleness and inactivity c…
cocosheng-g Apr 6, 2026
fa2f699
fix(examples): only update labels when asking for repro, not when clo…
cocosheng-g Apr 6, 2026
7817cb2
feat(examples): close issue when asking for repro after 1 month inact…
cocosheng-g Apr 6, 2026
0345f07
feat(examples): instruct reporter to reopen issue if reproducible in …
cocosheng-g Apr 6, 2026
d966b7f
feat(examples): close stale and inactive issues as 'not planned'
cocosheng-g Apr 6, 2026
fc993bb
fix(examples): quote 'on' in workflow yaml to satisfy yamllint truthy…
cocosheng-g Apr 6, 2026
a5f1f4e
feat(examples): exempt P0/P1 issues from auto-closing and tag assignees
cocosheng-g Apr 6, 2026
d1c7784
feat(examples): customize 30-day inactivity comment for feature requests
cocosheng-g Apr 6, 2026
8867a8c
feat(examples): skip triage for issues tracked by epics or projects
cocosheng-g Apr 6, 2026
afec57e
feat(examples): ask reporter for clarification on unassigned feature …
cocosheng-g Apr 7, 2026
017c077
feat(examples): ask for repro on tracked non-feature issues with no a…
cocosheng-g Apr 7, 2026
3d7b3cd
feat(examples): check for resolved comments before asking for repro, …
cocosheng-g Apr 7, 2026
7b58e43
feat(examples): let AI agent analyze comments to identify resolved is…
cocosheng-g Apr 7, 2026
b5e9a4f
feat(examples): refactor triage prompt to action-first syntax to stop…
cocosheng-g Apr 7, 2026
399fae8
fix(examples): force triage bot to serialize setup operations and blo…
cocosheng-g Apr 7, 2026
ced7de3
feat(workflows): refactor issue cleanup to use single source of truth…
cocosheng-g Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/workflows/issue-cleanup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Issue Cleanup Workflow

This document describes a workflow to batch-process and clean up older open issues using Gemini CLI.

## Overview

The Issue Cleanup workflow is designed to automate the triage of stale issues by using the Gemini CLI to:

1. **Check Code Validity**: Determines if an issue is still relevant against the current codebase. If the issue has already been resolved implicitly, it will close the issue with an explanation.
2. **Find Duplicates**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
3. **Summarize for Triage**: If an issue is still valid and unique, it provides a summary comment categorizing it as either `Maintainer-only` (epic, sensitive, internal) or `Help-wanted` (community-friendly).

## Usage

This example is tailored to process issues in a specific repository (`google-gemini/gemini-cli`) matching specific labels (`area/core`, `area/extensions`, `area/site`, `area/non-interactive`), selecting the 10 issues with the oldest last update time.

To adapt this to your own repository:

1. Copy `gemini-issue-cleanup.yml` to your repository's `.github/workflows/` directory.
2. Update the repository name and search string in the `Find old issues for cleanup` step in `gemini-issue-cleanup.yml`.
3. Update the repository name in the `Checkout Target Repository Code` step in `gemini-issue-cleanup.yml`.
4. Copy `gemini-issue-cleanup.toml` to your `.github/commands/` directory.
5. Update the prompt instructions in `gemini-issue-cleanup.toml` replacing `google-gemini/gemini-cli` with your repository name.
35 changes: 35 additions & 0 deletions examples/workflows/issue-cleanup/gemini-issue-cleanup.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
description = "Analyzes and cleans up older issues by checking code validity, duplicates, and providing a triage summary."
prompt = """
## Role
You are an expert AI triage assistant and repository maintainer for the `google-gemini/gemini-cli` repository.
Comment thread
cocosheng-g marked this conversation as resolved.
Outdated

## Task
Your task is to analyze GitHub Issue #!{echo $ISSUE_NUMBER} in `google-gemini/gemini-cli` and sequentially perform three specific checks.
You MUST use your tools (like `grep_search`, `read_file`, and `run_shell_command(gh)`) to investigate the codebase and issue tracker. Do NOT guess or hallucinate.

### Step 1: Check Code Validity
- Use `gh issue view !{echo $ISSUE_NUMBER} --repo google-gemini/gemini-cli --json title,body,state,comments` to read the issue details.
- Search the local workspace (which contains the latest `google-gemini/gemini-cli` code) to determine if the issue is still valid.
- For example, if it's a bug, does the buggy code still exist? If it's a feature request, has it already been implemented?
- If you definitively determine the issue is NO LONGER VALID:
- Close the issue and leave a brief comment explaining why (e.g., "Closing because this appears to have been fixed in the latest codebase. <explanation>").
- Use `gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because this appears to have been fixed in the latest codebase. <explanation>" --repo google-gemini/gemini-cli`
- STOP execution. You are done with this issue.

### Step 2: Check for Duplicates
- If the issue is still valid, check if it's a duplicate of another issue that is already being tracked or worked on.
- Use `gh issue list --search "<keywords>" --repo google-gemini/gemini-cli --state all` with relevant keywords to find potential duplicates.
- If you find a clear duplicate that someone is working on or has already resolved:
- Close the issue as not planned, pointing to the duplicate.
- Use `gh issue close !{echo $ISSUE_NUMBER} --reason "not planned" --comment "Closing as duplicate of #<duplicate_number>." --repo google-gemini/gemini-cli`
- STOP execution. You are done with this issue.

### Step 3: Provide Triage Summary
- If the issue is still valid and NOT a duplicate, add a brief summary comment for further triaging.
- State whether the issue should be categorized as:
- **Maintainer-only**: (e.g., epic, core architecture, sensitive fixes, internal tasks)
- **Help-wanted**: (e.g., good for community, general bugs, features, or tasks ready for external help)
- Your comment should be brief and clearly explain *why* it fits that category.
- Use `gh issue comment !{echo $ISSUE_NUMBER} --body "### Triage Summary\n\n**Category:** <Maintainer-only OR Help-wanted>\n\n**Reasoning:** <brief explanation>" --repo google-gemini/gemini-cli`
- STOP execution. You are done with this issue.
"""
96 changes: 96 additions & 0 deletions examples/workflows/issue-cleanup/gemini-issue-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: '🧹 Gemini Issue Cleanup'

on:
schedule:
- cron: '0 0 * * 0' # Runs weekly at midnight on Sunday
workflow_dispatch:

concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: true

defaults:
run:
shell: 'bash'

jobs:
find-issues:
runs-on: 'ubuntu-latest'
outputs:
issue_numbers: '${{ steps.find_issues.outputs.issue_numbers }}'
steps:
- name: 'Find old issues for cleanup'
id: 'find_issues'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}'
run: |-
echo '🔍 Finding old issues for cleanup...'
# Query matches target: google-gemini/gemini-cli, open issues, sorted by oldest last update time
# with labels area/core, area/extensions, area/site, area/non-interactive
ISSUES="$(gh issue list \
--repo google-gemini/gemini-cli \
Comment thread
cocosheng-g marked this conversation as resolved.
Outdated
--state 'open' \
--search "label:area/core,area/extensions,area/site,area/non-interactive sort:updated-asc" \
--json number \
--limit 10 \
)"

# Convert to JSON array of integers
ISSUE_NUMBERS="$(echo "${ISSUES}" | jq -c '[.[].number | tostring]')"
Comment thread
cocosheng-g marked this conversation as resolved.
Outdated

if [ "${ISSUE_NUMBERS}" = "[]" ] || [ -z "${ISSUE_NUMBERS}" ]; then
echo "issue_numbers=[]" >> "${GITHUB_OUTPUT}"
echo "✅ No issues found to clean up."
else
echo "issue_numbers=${ISSUE_NUMBERS}" >> "${GITHUB_OUTPUT}"
echo "✅ Found $(echo "${ISSUES}" | jq 'length') issue(s) to process."
fi

process-issue:
needs: 'find-issues'
if: |-
needs.find-issues.outputs.issue_numbers != '[]' && needs.find-issues.outputs.issue_numbers != ''
runs-on: 'ubuntu-latest'
strategy:
matrix:
issue_number: '${{ fromJSON(needs.find-issues.outputs.issue_numbers) }}'
max-parallel: 3
fail-fast: false
permissions:
contents: 'read'
id-token: 'write'
issues: 'write'
steps:
- name: 'Checkout Target Repository Code'
uses: 'actions/checkout@v4'
with:
Comment thread
cocosheng-g marked this conversation as resolved.
repository: 'google-gemini/gemini-cli'

- name: 'Run Gemini Issue Cleanup'
uses: 'google-github-actions/run-gemini-cli@v0' # Replace with actual version when deploying
env:
ISSUE_NUMBER: '${{ matrix.issue_number }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}'
with:
# Modify the auth settings depending on your environment
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
workflow_name: 'gemini-issue-cleanup'
# Passing issue number to let the agent retrieve it
settings: |-
{
"model": {
"maxSessionTurns": 50
},
"tools": {
"core": [
"grep_search",
"read_file",
"run_shell_command(gh)"
]
}
}
prompt: '/gemini-issue-cleanup'
Loading