[CLI] Add hf repos ls command#4283
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
hanouticelina
left a comment
There was a problem hiding this comment.
Thanks! mainly nits in the review
| Use `--format json` for scripting or `-q` for IDs only. When piping, use `--limit 0` to export all repos: | ||
|
|
||
| ```bash | ||
| >>> hf repos ls --limit 0 --format json | jq '.[].id' |
There was a problem hiding this comment.
the command was broken
| >>> hf repos ls --limit 0 --format json | jq '.[].id' | |
| >>> hf repos ls --limit 0 --format json | jq '.[].repository' |
There was a problem hiding this comment.
or maybe rename it to id to match the other ls commands
|
Addressed all comments, thanks! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3334aae. Configure here.
|
This PR has been shipped as part of the v1.17.0 release. |

Summary
Add
hf repos ls/hf repos listCLI command to list all repos (models, datasets, spaces, buckets) for the authenticated user or an organization, with storage info. Uses the/api/settings/repositoriesendpoint (shipped in https://github.com/huggingface-internal/moon-landing/pull/17996).list_user_repos()toHfApi(returnsIterable[RepoStorageInfo], forward-compatible with pagination)--type,--search,--namespace,--limit(defaults to 30, same ashf models ls) and--formatflags🤖 Generated with Claude Code
Note
Low Risk
Read-only listing against new settings endpoints; no auth, upload, or repo mutation logic changed beyond exports and CLI wiring.
Overview
Adds
hf repos ls/hf repos listand a matching Python API so you can see all Hub repos you own (models, datasets, spaces, buckets) with storage size and % of namespace total, sorted by storage.API: New
RepoStorageInfodataclass andHfApi.list_user_repos()/ top-levellist_user_repos()call the settings repositories endpoints (user or--namespaceorg), with paginated responses.CLI:
repo_listfetches the full list, applies client-side--type,--search, and--limit(default 30,--limit 0for all), then prints a table with human-readable storage; standard--format json/-qwork via existing output helpers.Docs & tests: CLI guide, repository guide, and package CLI reference document the command; an integration test exercises
repos lswith type/search filters.Reviewed by Cursor Bugbot for commit ed7f4cb. Bugbot is set up for automated code reviews on this repo. Configure here.