unstarring 197 repos in 9 minutes
I had 197 starred repos and 12 star lists cluttering my GitHub. I knew Claude Code could clean it out. 9 minutes later it was done.
Here’s the full transcript.
what would it take to unstar and remove my star lists completely on github? I want 0 stars on anything; don't do it yet, just tell me what it would take/use the CLI to understand (you can start/unstart lostmygithubaccount/lostmygithubaccount to test)
Scoping the problem:
$ gh api /user/starred --paginate -q '.[].full_name' | wc -l
197
$ gh api graphql -f query=‘{ viewer { lists(first: 20) { nodes { id name slug } } } }’
197 starred repos and 12 star lists.
Testing the round-trip:
$ gh api /user/starred/lostmygithubaccount/lostmygithubaccount --method DELETE
# unstarred
$ gh api /user/starred/lostmygithubaccount/lostmygithubaccount –method PUT -H “Content-Length: 0”
re-starred
#
Works both ways. Here's the plan:
1. Unstar all 197 repos via DELETE /user/starred/{repo} in a loop
2. Delete all 12 star lists via GraphQL deleteUserList mutation — requires the user OAuth scope, so you'll need to run gh auth refresh -s user
do it
$ gh api /user/starred --paginate -q '.[].full_name' | while read repo; do
gh api /user/starred/$repo --method DELETE && echo "Unstarred: $repo"
done
Unstarred: lostmygithubaccount/lostmygithubaccount
Unstarred: dkdc-io/dkdc.sh
Unstarred: dkdc-io/bookmarks
Unstarred: ascend-io/ascend-tools
Unstarred: dkdc-io/zorto
Unstarred: dkdc-io/db
Unstarred: dbt-labs/dbt-core
Unstarred: ibis-project/ibis
Unstarred: apache/arrow
Unstarred: pola-rs/polars
...
Unstarred: lightgbm-org/LightGBM
All 197 unstarred. Now for the star lists — I need the user OAuth scope for GraphQL mutations:
$ gh api graphql -f query='mutation { deleteUserList(input: {listId: "test"}) { clientMutationId } }'
Your token has not been granted the required scopes to execute this query.
The 'deleteUserList' field requires one of the following scopes: ['user'],
but your token has only been granted the: ['gist', 'read:org', 'repo', 'workflow'] scopes.
Run gh auth refresh -s user in your terminal — it needs a browser for the OAuth flow.
do it
$ gh auth refresh -s user
error: --hostname required when not running interactively
Can't do it non-interactively — needs your browser. Run this in your terminal: gh auth refresh -s user
try now
Fetching all star lists:
$ gh api graphql -f query='{ viewer { lists(first: 20) { nodes { id name } } } }' \
-q '.data.viewer.lists.nodes[] | "\(.id) \(.name)"'
UL_kwDOA0Rnac4AHIkl Python data/ML
UL_kwDOA0Rnac4AHMAC to investigate
UL_kwDOA0Rnac4AJSk8 ops
UL_kwDOA0Rnac4AJSlF viz
UL_kwDOA0Rnac4AJSlU APIs/data sources
UL_kwDOA0Rnac4AGyXJ web9
UL_kwDOA0Rnac4AHC2H streaming
UL_kwDOA0Rnac4AJSlB dev
UL_kwDOA0Rnac4AJSli benchmarking?
UL_kwDOA0Rnac4AG5OS non-Python data/ML
UL_kwDOA0Rnac4AJSlA cool cloud-y stuff
Deleting all 11:
$ for id in UL_kwDOA0Rnac4AHIkl UL_kwDOA0Rnac4AHMAC \
UL_kwDOA0Rnac4AJSk8 UL_kwDOA0Rnac4AJSlF \
UL_kwDOA0Rnac4AJSlU UL_kwDOA0Rnac4AGyXJ \
UL_kwDOA0Rnac4AHC2H UL_kwDOA0Rnac4AJSlB \
UL_kwDOA0Rnac4AJSli UL_kwDOA0Rnac4AG5OS \
UL_kwDOA0Rnac4AJSlA; do
gh api graphql \
-f query="mutation { deleteUserList(input: {listId: \"$id\"}) { clientMutationId } }"
done
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
{"data":{"deleteUserList":{"clientMutationId":null}}}
Verifying:
$ gh api /user/starred --paginate -q '.[].full_name' | wc -l
0
$ gh api graphql -f query=‘{ viewer { lists(first: 20) { nodes { id name } } } }’
-q ‘.data.viewer.lists.nodes | length’
0
0 starred repos (was 197). 0 star lists (was 11). 9 minutes start to finish.
4 messages from me. Hundreds of API calls from Claude. A menial task done.