Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Huggingface Hub Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-huggingface-hub-knowledge-patch-nevaberry-plugins)
---
name: huggingface-hub-knowledge-patch
description: Hugging Face Hub
version: null
license: MIT
metadata:
author: Nevaberry
---
# Hugging Face Hub knowledge patch
Load this skill when migrating Hub clients or working with repository APIs,
authentication, file transfers, inference, Spaces, Jobs, or sandboxes.
Use the topic references for the complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Client migration and packaging](references/client-migration.md) | Removed APIs and commands; HTTP clients, trust, and logging; packaging; CLI portability; model loading and metadata |
| [Inference, endpoints, and Spaces](references/inference-spaces.md) | Endpoint hardware, images, lifecycle, and access; inference providers; Space configuration and OAuth; Jobs; experimental sandboxes |
| [Repository operations and authentication](references/repositories-auth.md) | OpenAPI; tokens and gated access; configured endpoints; commits; repository metadata; discussions; webhooks |
| [Storage, cache, and transfer operations](references/storage-transfers.md) | Downloads and revisions; cache cleanup; filesystem listings; uploads; bucket transactions; Xet; dataset queries |
## Breaking changes and deprecations
### Client migration to v1
- Replace `configure_http_backend` with `set_client_factory` and
`set_async_client_factory`; move per-call `proxies=` to the HTTPX client configuration.
- Replace `requests.HTTPError` handlers with the Hub exception appropriate to the
operation, or catch `httpx.HTTPError` for HTTPX failures generally.
- `force_filename` was removed. Open downloads using the path returned by
`hf_hub_download`.
- Replace `InferenceApi` with `InferenceClient` for synchronous calls or
`AsyncInferenceClient` for asynchronous calls.
- Deprecated TensorFlow and Keras utilities were removed. Handle serialization
and callbacks in the framework, then publish the resulting files through `HfApi`.
- Remove the `hf_transfer` extra and `HF_HUB_ENABLE_HF_TRANSFER`.
Set `HF_XET_HIGH_PERFORMANCE=1` to opt into Xet's high-performance transfer mode.
### Python API migration to 2.0
- Replace `upload_large_folder` and `HfApi.upload_large_folder` with `upload_folder`.
- Use `duplicate_repo` to duplicate a Space. For `create_repo` and `duplicate_repo`,
replace `space_storage` with `space_volumes`.
- Replace `request_space_storage` and `delete_space_storage` with
`set_space_volumes` and `delete_space_volumes`.
- Replace `repo_type_and_id_from_hf_id` with `parse_hf_uri`.
- Replace `InferenceEndpointType.PROTECTED` with `InferenceEndpointType.AUTHENTICATED`.
`create_inference_endpoint(type="protected")` raises `ValueError`.
- In `list_models`, replace `model_name` with `search`.
- In `text_generation`, replace `stop_sequences` with `stop`.
- Pass a token string or `None` to `InferenceClient(token=...)`;
boolean token values were removed.
### CLI migration to 2.0
- Replace `huggingface-cli` with `hf`, `hf repo` with `hf repos`, and
`hf repo-files delete` with `hf repos delete-files`.
- Replace `hf upload-large-folder` with `hf upload`.
- For `hf repos create` and `hf repos duplicate`, replace `--storage` with `--volume`.
- Replace `hf jobs ps` with `hf jobs ls`. Replace `hf jobs scheduled ps -f/--filter`
with `hf jobs scheduled ls` using `--status` or `--label`.
- Drop `--claude` from `hf skills add` and `hf skills update`;
installation for that client is automatic.
### Other compatibility checks
- Remove dependencies on `huggingface_hub.constants.INFERENCE_ENDPOINT_IMAGE_KEYS`;
direct access raises `AttributeError`.
- Organization API tokens are deprecated. Use a personal token with the required
resource and operation scope, issued to a user with the required organization role.
- In 2.3.0, Python 3.15 is officially supported and the minimum is Python 3.10.
- In 2.2.0, catch `FileNotFoundError` for a missing checkpoint passed to
`load_torch_model`; `model_index_to_eval_results` raises `ValueError` for an empty list.
- In 2.3.0, handle inference request timeouts with `InferenceTimeoutError`.
- Catch `EgressLimitError` for HTTP 402 responses with the `EgressLimitReached` code.
## Configure HTTP transport
Version 2.0 uses `httpx2` and `httpcore2` clients and transport exceptions.
For compatibility with late 1.x releases starting at 1.30.0 and with 2.x,
import `httpx` from `huggingface_hub.utils` in custom factories and exception handlers.
```python
from huggingface_hub import set_async_client_factory, set_client_factory
from huggingface_hub.utils import httpx
set_client_factory(httpx.Client)
set_async_client_factory(httpx.AsyncClient)
```
`httpx2` uses the operating system certificate store by default and honors
`SSL_CERT_FILE` and `SSL_CERT_DIR`. Configure logging for `httpx2` and `httpcore2`.
Use `authlib>=1.8.0` with the `oauth` extra.
## Download, upload, and cache behavior
- Use `dry_run=True` with `hf_hub_download` or `snapshot_download` to obtain
the download plan without transferring file contents.
- `HF_HUB_ETAG_TIMEOUT` controls the wait for metadata before falling back to
available cached state. A short timeout can resolve a mutable branch or tag
to an older cached commit.
- Downloads using `local_dir` store reuse metadata in `.cache/huggingface` inside
the destination. Exclude that directory when publishing the downloaded tree.
- `snapshot_download(force_download=True)` surfaces Hub resolution failures
even when a cached snapshot exists.
- `run_as_future=True` queues uploads in order on the same client. Keep the
process alive and call `future.result()` to surface upload errors.
- `hf cache ls`, `hf cache rm`, and `hf cache prune` inspect, remove selected
entries, and remove unreferenced content. They can leave chunks in `HF_XET_CACHE`.
- Cache revision totals count each shared blob once; the cache CLI also
deduplicates shared blobs with `--limit` and `--filter`.
The storage reference also covers repository-scoped `ResolvedRevision` objects,
offline downloads at pinned revisions, legacy large-folder upload progress,
and Git LFS interoperability with Xet-backed repositories.
## Authentication and repository writes
- Set `HF_HUB_DISABLE_IMPLICIT_TOKEN=1` for anonymous ordinary Hub reads by default.
Use `token=True` for a private read with the resolved token, or `token=False`
to force anonymous access where supported.
- `HF_TOKEN_PATH` selects the saved token file while preserving cache locations;
`HF_TOKEN` takes precedence over that file.
- On HTTP downloads through Hub `/resolve/` URLs, follow redirects and strip the
Hub `Authorization` header if the origin changes. SDK downloads handle this flow.
- Gated access checks approval for the token's issuing user. A not-found response
can mean an inaccessible repository; check identity, repository type, and token scope.
- Use `AccessRequest.request_id` with `accept_access_request`, `reject_access_request`,
or `cancel_access_request` when requester identities are hidden.
`username` and `fullname` can be `None`.
- `hf auth revoke` accepts raw tokens without login. The top-level
`revoke_tokens([...])` sends batches of 1,000; owners receive email, and existing
and unknown tokens receive the same acknowledgment.
- Pass the inspected branch head as `parent_commit` to `HfApi.create_commit`;
the commit fails if another writer advances the branch before the write.
- Webhook updates require the complete configuration, including settings to retain.
## Inference endpoints and Spaces
- `hf endpoints hardware` lists deployable hardware combinations, hourly prices
per replica, and accelerator quotas for your namespace by default.
- Endpoint creation and updates accept `custom_image` as a flat dictionary with
top-level `url`, or as an engine-keyed dictionary such as `vLLM`, `sGLang`, `tgi`, or `tei`.
- vLLM and SGLang default to one accelerator. Configure parallelism to use all
allocated accelerators on multi-accelerator instances; the API rejects the default there.
- Creating or updating an endpoint can return before replicas are ready.
Wait for readiness and handle terminal failures before sending traffic.
- `scale_to_zero` preserves endpoint configuration and permits request-triggered
cold starts. Paused endpoints require explicit resume.
- With a Hub token and explicit `provider`, `chat_completion` uses the Hub router's
`/v1/chat/completions` with `model` set to `org/model:provider`.
Calls using a provider API key go directly to that provider.
- Space `suggested_hardware` and `suggested_storage` are recommendations.
Allocate resources through Space settings or the Hub API.
- Pin the source revision for files fetched during a Space build with `preload_from_hub`.
- Space OAuth provisions the OAuth client and callback configuration;
configure server credentials separately for private Hub repository access.
- Space OAuth always uses S256 PKCE. Without `OAUTH_CLIENT_SECRET`, it uses a public
client with `token_endpoint_auth_method="none"`. Cookies use a key derived from
`SPACE_SIGNING_SECRET`, which persists across restarts and replicas;
existing users must sign in again after upgrading.
- Access wakes a sleeping Space and can incur a cold start. Paused Spaces need
explicit restart; hardware requests are asynchronous, so check runtime state.
## Jobs and experimental sandboxes
- `hf jobs scheduled ls` defaults to active jobs; use `--status active|suspended`,
repeatable `-l`/`--label key=value`, or `--name NAME` for `--label name=NAME`.
In 1.30, `-f`/`--filter` becomes a no-op with a warning.
- In 2.2.0, `hf jobs stats` and `HfApi.fetch_job_metrics` return the latest sample
per job by default. Use `-f`/`--follow` or `follow=True` to stream until completion.
- `hf jobs run` reconnects to logs until a final stage. Ctrl+C exits the CLI
immediately while leaving the remote job running.
- Handle both enum members and raw strings for `JobStatus.stage` and `SpaceRuntime.stage`.
- The Sandbox API and CLI are experimental. Share only among workloads within
the same trust boundary.
- Pass `network="none"` to `Sandbox.create` or `pool.create` to block outbound
connections while retaining volumes. Use `network={"allow": [...]}` for selected
CIDRs, IP addresses, or hostnames, with optional ports on individual addresses or hostnames.
The policy covers every process; creation raises `SandboxError` if the server cannot enforce it.
## Filesystem listings, buckets, and dataset queries
- `HfFileSystem(live_follow=True)` opens a background connection per listed bucket
and invalidates affected caches on changes. It defaults to off and works as an
fsspec storage option. Use `refresh=True` for new commits in model, dataset, and Space repos.
- `HfFileSystem(max_workers=16)` is the parallel recursive-listing default;
`max_workers=1` is sequential. `find()` and `glob()` apply `maxdepth` during traversal.
- `HfFileSystem.transaction` uploads staged bucket writes on successful block exit
and discards them if the block raises. Commit uploads files individually and can
leave earlier files uploaded after failure. Repository writes, `rm`, and `cp_file`
raise `NotImplementedError` inside transactions.
- `hf datasets sql` installs and loads the DuckDB extension for `hf_dataset('org/name')`
and supports `COPY ... TO 'hf://datasets/username/dataset-name/...'`.
The extension requires DuckDB 2.0 or later; `read_parquet(...)` remains available
if extension installation fails.