Skip to content

[CLI] Add hf repos ls command#4283

Merged
Wauplin merged 8 commits into
mainfrom
cli-repos-ls
May 28, 2026
Merged

[CLI] Add hf repos ls command#4283
Wauplin merged 8 commits into
mainfrom
cli-repos-ls

Conversation

@Wauplin

@Wauplin Wauplin commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add hf repos ls / hf repos list CLI command to list all repos (models, datasets, spaces, buckets) for the authenticated user or an organization, with storage info. Uses the /api/settings/repositories endpoint (shipped in https://github.com/huggingface-internal/moon-landing/pull/17996).

  • Adds list_user_repos() to HfApi (returns Iterable[RepoStorageInfo], forward-compatible with pagination)
  • Supports --type, --search, --namespace, --limit (defaults to 30, same as hf models ls) and --format flags
  • Docs updated (cli.md guide, repository.md guide, auto-generated CLI reference)
$ hf repos ls
REPOSITORY                                        TYPE     UPDATED     VISIBILITY    STORAGE  % OF TOTAL
------------------------------------------------  -------  ----------  ----------  ---------  ----------
Wauplin/bucket-raw                                bucket   2026-04-29  public         1.7 TB       85.8%
Wauplin/noaa-ghcn-pds                             bucket   2026-05-18  private      265.9 GB       13.8%
Wauplin/test-upload-v2                            model    2026-05-06  public         4.8 GB        0.2%
Wauplin/alphageometry                             model    2024-01-18  public         1.2 GB        0.1%
Wauplin/my-cool-mamba                             model    2024-07-16  public       516.6 MB        0.0%
Wauplin/example-space-to-dataset-image-zip        dataset  2023-06-13  public       214.0 MB        0.0%
Wauplin/test-cloudfront-unauth                    model    2026-03-09  public       125.2 MB        0.0%
Wauplin/gradio-oauth                              space    2024-07-31  private      120.6 MB        0.0%
Wauplin/gpt-oss-rag-dev                           dataset  2025-08-15  private       83.1 MB        0.0%
Wauplin/example-space-to-dataset-parquet          dataset  2023-06-29  public        65.4 MB        0.0%
...
ℹ Showing 30 of 69 repos. Use `--limit 0` to list all.

🤖 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 list and 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 RepoStorageInfo dataclass and HfApi.list_user_repos() / top-level list_user_repos() call the settings repositories endpoints (user or --namespace org), with paginated responses.

CLI: repo_list fetches the full list, applies client-side --type, --search, and --limit (default 30, --limit 0 for all), then prints a table with human-readable storage; standard --format json / -q work via existing output helpers.

Docs & tests: CLI guide, repository guide, and package CLI reference document the command; an integration test exercises repos ls with type/search filters.

Reviewed by Cursor Bugbot for commit ed7f4cb. Bugbot is set up for automated code reviews on this repo. Configure here.

Wauplin and others added 2 commits May 27, 2026 17:40
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Wauplin Wauplin marked this pull request as ready for review May 27, 2026 15:50
@Wauplin Wauplin requested a review from hanouticelina May 27, 2026 15:50
@bot-ci-comment

Copy link
Copy Markdown

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.

Comment thread src/huggingface_hub/hf_api.py Outdated
Comment thread src/huggingface_hub/cli/repos.py

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! mainly nits in the review

Comment thread src/huggingface_hub/cli/repos.py
Comment thread tests/test_cli.py
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'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the command was broken

Suggested change
>>> hf repos ls --limit 0 --format json | jq '.[].id'
>>> hf repos ls --limit 0 --format json | jq '.[].repository'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe rename it to id to match the other ls commands

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good catch, addressed in 8281aa6

Comment thread src/huggingface_hub/cli/repos.py Outdated
Comment thread docs/source/en/guides/cli.md Outdated
@Wauplin

Wauplin commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all comments, thanks!

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread tests/test_cli.py Outdated
@Wauplin Wauplin merged commit 06d2a3f into main May 28, 2026
24 of 26 checks passed
@Wauplin Wauplin deleted the cli-repos-ls branch May 28, 2026 14:09
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.17.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants