Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

hf-downloads

БесплатноБез исполняемых скриптовНе проверен

Hugging Face model downloads without filling root disk — HF_HOME/xet cache redirection, token/gated-repo auth, staging pattern. Use when downloading HF…

laurigatesот laurigates★ 61 звезда на GitHub

Об этом скилле

Hugging Face Downloads

Download Hugging Face models to a big disk without filling root, authenticate against gated repos, and verify transfers — the failure modes that make multi-GB hf download runs abort or 401.

Scoped to huggingface_hub / hf. For disk-full recovery in general — reclaiming space, hunting what filled the disk — use macos-plugin:macos-disk-usage instead.

The Core Trap: --local-dir Does Not Cover Transfer State

--local-dir only controls where the final file lands. HF still writes intermediate transfer state — the hub manifest and, critically, xet transfer chunks — to ~/.cache/huggingface/{hub,xet} regardless.

hf download <repo> <file> --local-dir /big/disk/staging

The <file> argument is required in practice, not optional: hf download <repo> with no file downloads the entire repo, including any demo/, examples/, or obsolete/ directories it carries — there is no listing or confirmation step first. To see what's in a repo before downloading, use the listing recipe below rather than dropping the file argument.

The final file lands on /big/disk/, but the xet chunks stage under ~/.cache/huggingface/xet/. Xet is HF's newer transfer protocol: it stages compressed blocks under ~/.cache while reconstructing the file, and those staged blocks are roughly file-sized. On a small root disk the symptom is:

OSError: I/O error: IO Error: No space left on device (os error 28)

Listing a Repo's Files Before Downloading

Reaching for a bare hf download <repo> to see what a repo contains fetches the whole thing instead — there is no listing subcommand. Use one of these instead:

# List files without downloading anything
python3 -c "from huggingface_hub import HfApi; print('\n'.join(HfApi().list_repo_files('<repo>')))"

# Download only a subset by glob, skipping demo/examples/obsolete directories
hf download <repo> --include 'model.safetensors' --include '*.json' --local-dir /big/disk/staging

--include / --exclude accept glob patterns and compose (--exclude 'demo/*' --exclude 'obsolete/*' to keep everything else). Prefer naming the files you want over excluding the ones you don't — the file argument stays load-bearing either way.

Fix: HF_HOME Is the Umbrella

Setting HF_HOME relocates both HF_HUB_CACHE ($HF_HOME/hub) and HF_XET_CACHE ($HF_HOME/xet) onto the same disk as the destination:

HF_HOME=/big/disk/hf-cache hf download <repo> <file> --local-dir /big/disk/staging

HF_HOME is a path, not a secret, so persist it by exporting in .zshenv/.zshrc, a mise [env] block, or a per-project .envrc (direnv). On a machine whose root is small:

export HF_HOME=/mnt/big-disk/hf-cache

Two-Stage Staging Pattern

hf download preserves the repo's directory structure under --local-dir, which is rarely what you want at the destination. Stage first, then move only the file:

mkdir -p /big/disk/staging /big/disk/hf-cache
HF_HOME=/big/disk/hf-cache hf download <repo> <path/in/repo> --local-dir /big/disk/staging
mv /big/disk/staging/<path/in/repo> /destination/
rm -rf /big/disk/staging

Never stage on /tmp. /tmp is sometimes tmpfs (RAM-backed), and on installs that put / on a small SSD it fills root fast. Always stage on a disk you've verified with df -h. The Claude Code harness also writes Bash output files to /tmp/claude-<uid>/, so a full /tmp stops Bash entirely.

Auth: Token Location Diverges Under HF_HOME

hf auth login writes the token to the fixed path ~/.cache/huggingface/token. But when HF_HOME is set, the SDK and CLI read their token from $HF_HOME/token instead. The two paths diverge silently: every gated download under HF_HOME=… 401s with GatedRepoError, even though hf auth whoami works fine (it reads ~/.cache/huggingface/token).

Signature of this mismatch: model_info() calls succeed (metadata is public), LICENSE.md fetches return 200, but *.safetensors fetches under the same auth return 401.

Two fixes — prefer HF_TOKEN scoped to one command for ephemeral use, copy the file for persistent setups:

# Ephemeral: HF_TOKEN is read directly, bypassing the file-location lookup.
# Set it on the one command rather than exporting it into the shell.
export HF_HOME=/big/disk/hf-cache
HF_TOKEN="$(cat ~/.cache/huggingface/token)" hf download <repo> <file> --local-dir /big/disk/staging

# Persistent: copy the token into the HF_HOME location after login
cp ~/.cache/huggingface/token "$HF_HOME/token"

Gated Repos: Three Independent Conditions

All three must be true to download a gated file:

  1. The HF account has clicked "Agree and access repository" on the repo's web page.
  2. The token in use belongs to that same account.
  3. The token was issued after (or refreshed after) the access was granted. Some HF setups cache permissions at issue time, so a pre-existing token may not pick up newly-granted g
Полный SKILL.md на GitHub

Установить hf-downloads в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(hf download *)
Bash(mkdir *)
Bash(mv *)
Bash(cp *)
Bash(stat *)
Read

Вложенные файлы

REFERENCE.md

FAQ

Что делает скилл hf-downloads?

Hugging Face model downloads without filling root disk — HF_HOME/xet cache redirection, token/gated-repo auth, staging pattern. Use when downloading HF models, hf download errors, ENOSPC during downloads, or GatedRepoError/401s.

Как установить скилл hf-downloads?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл hf-downloads запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить hf-downloads с