Bulk deleting spam GitHub Issues

Posted by christian on 03 April 2026

This morning I woke up to find almost 300 emails relating to issues raised on one of my public GitHub repositories. Deleting the emails is relatively straightforward in GMail but the GitHub website provides no way to bulk-delete issues (it can be done one-by-one, but this is not an option for so many of them). So, for future reference (by myself if no one else), here's what to do:

  1. Install GitHub's command line interface (CLI) tool, which provides the gh command. I'm on a Mac, so brew install gh worked for me.
  2. Get a fine-grained Personal Access Token (PAT) with Repository Access and Repository Permissions: Issues set to Read and write. The actual GitHub account attached to the PAT must have an Admin or Owner role in the repository.
  3. Clone the repository locally if it isn't already there.
  4. From within the cloned repository authenticate to GitHub with the command gh auth login using the PAT when prompted.
  5. You can view up to 1000 open issues with gh issue list --state open --limit 1000.
  6. To delete issues via the API, your token specifically needs the delete_repo scope. By default, the gh CLI doesn't request this permission to keep your account safe from accidental deletions. So run gh auth refresh -s delete_repo and authenticate in a browser to grant the necessary permission.
  7. Finally, run the following command to delete each open issue. Note that it does not discriminate between spam issues and other issues: every open issue (up to the limit) will be deleted; you many need further filters if this is not the outcome you want.

gh issue list --state open --limit 1000 --json number -q '.[].number' | xargs -I {} gh issue delete {} --yes

The command does the following: