← 返回 Skills 市场
yevhendiachenko0

Hugging Face CLI

作者 Yevhen Diachenko · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
311
总下载
1
收藏
0
当前安装
8
版本数
在 OpenClaw 中安装
/install hugging-face-cli
功能描述
Manage Hugging Face Hub via hf CLI. Use when working with HF AI models, datasets, spaces, or repos.
使用说明 (SKILL.md)

Hugging Face CLI

Hugging Face (https://huggingface.co) is the leading platform for sharing and collaborating on AI models, datasets, and spaces. This skill enables interaction with the Hub through the official hf CLI.

Installation

Check if hf is available by running hf version. If not installed:

pip install -U "huggingface_hub[cli]"
# or
brew install hf

If the options above do not work, follow the official installation guide.

After installation, run hf version to verify. If the command is not found, run source ~/.bashrc (or source ~/.zshrc for zsh) to reload the PATH, then try again.

Authentication

A Hugging Face User Access Token is required. The token is provided via the HF_TOKEN environment variable.

If authentication fails or the token is missing, instruct the user to:

  1. Go to https://huggingface.co/settings/tokens
  2. Create a new token — there are two permission levels:
    • Read (safer): sufficient for searching, downloading models/datasets, listing repos, browsing papers, and most read-only operations. Choose this if you only need to explore and download.
    • Write (less safe, broader access): required for creating/deleting repos, uploading files, managing discussions, deploying endpoints, and running jobs. Example 3 (create a repo and upload weights) requires a write token.
  3. Set it as an environment variable: export HF_TOKEN="hf_..." (add to shell profile for persistence)

Important: Do NOT run hf auth login interactively — it requires terminal input. Instead, use the environment variable directly. The hf CLI automatically picks up HF_TOKEN from the environment for all commands. To verify authentication, run:

hf auth whoami

Key Commands

Task Command
Check current user hf auth whoami
Download files hf download \x3Crepo_id> [files...] [--local-dir \x3Cpath>]
Download specific revision hf download \x3Crepo_id> --revision \x3Cbranch|tag|commit>
Download with filters hf download \x3Crepo_id> --include "*.safetensors" --exclude "*.bin"
Upload files hf upload \x3Crepo_id> \x3Clocal_path> [path_in_repo]
Upload as PR hf upload \x3Crepo_id> \x3Clocal_path> [path_in_repo] --create-pr
Upload (private repo) hf upload \x3Crepo_id> \x3Clocal_path> [path_in_repo] --private
Upload large folder hf upload-large-folder \x3Crepo_id> \x3Clocal_path>
Create a repo hf repos create \x3Cname> [--repo-type model|dataset|space] [--private]
Delete a repo hf repos delete \x3Crepo_id>
Delete files from repo hf repos delete-files \x3Crepo_id> \x3Cpath>...
Duplicate a repo hf repos duplicate \x3Crepo_id> [--type model|dataset|space]
Repo settings hf repos settings \x3Crepo_id> [--private|--public]
Manage branches hf repos branch create|delete \x3Crepo_id> \x3Cbranch>
Manage tags hf repos tag create|delete \x3Crepo_id> \x3Ctag>
List models hf models ls [--search \x3Cquery>] [--sort downloads] [--limit N]
Model info hf models info \x3Crepo_id>
List datasets hf datasets ls [--search \x3Cquery>]
Dataset info hf datasets info \x3Crepo_id>
Run SQL on data hf datasets sql "\x3CSQL>"
List spaces hf spaces ls [--search \x3Cquery>]
Space info hf spaces info \x3Crepo_id>
Space dev mode hf spaces dev-mode \x3Crepo_id>
List papers hf papers ls [--limit N]
List collections hf collections ls [--owner \x3Cuser>] [--sort trending]
Create collection hf collections create "\x3Ctitle>"
Collection info hf collections info \x3Ccollection_slug>
Add to collection hf collections add-item \x3Ccollection_slug> \x3Crepo_id> \x3Ctype>
Delete collection hf collections delete \x3Ccollection_slug>
Run a cloud job hf jobs run \x3Cdocker_image> \x3Ccommand>
List jobs hf jobs ps
Job logs hf jobs logs \x3Cjob_id>
Cancel a job hf jobs cancel \x3Cjob_id>
Job hardware hf jobs hardware
Deploy endpoint hf endpoints deploy \x3Cname> --repo \x3Crepo_id> --framework \x3Cfw> --accelerator \x3Chw> ...
List endpoints hf endpoints ls
Endpoint info hf endpoints describe \x3Cname>
Pause/resume endpoint hf endpoints pause|resume \x3Cname>
Delete endpoint hf endpoints delete \x3Cname>
List discussions hf discussions ls \x3Crepo_id>
Create discussion hf discussions create \x3Crepo_id> --title "\x3Ctitle>"
Comment on discussion hf discussions comment \x3Crepo_id> \x3Cnum> --body "\x3Ctext>"
Close discussion hf discussions close \x3Crepo_id> \x3Cnum>
Merge PR hf discussions merge \x3Crepo_id> \x3Cnum>
Manage cache hf cache ls, hf cache rm \x3Cid>, hf cache prune
Delete bucket / files hf buckets delete \x3Cuser>/\x3Cbucket>, hf buckets rm \x3Cuser>/\x3Cbucket>/\x3Cpath>
Sync to bucket hf sync \x3Clocal_path> hf://buckets/\x3Cuser>/\x3Cbucket>
Print environment hf env

End-to-End Examples

Example 1: Explore trending models, pick one, and preview a download

hf models ls --sort trending_score --limit 5
hf models info openai-community/gpt2
hf download --dry-run openai-community/gpt2 config.json tokenizer.json
hf download openai-community/gpt2 config.json tokenizer.json --local-dir ./gpt2

Example 2: Browse today's papers and find related datasets

hf papers ls --limit 5
hf datasets ls --search "code" --sort downloads --limit 5
hf datasets info bigcode/the-stack

Example 3: Create a private model repo and upload weights

hf repos create my-fine-tuned-model --private
# create returns \x3Cyour-username>/my-fine-tuned-model — use that full ID below
hf upload \x3Cusername>/my-fine-tuned-model ./output --commit-message "Add fine-tuned weights"
hf repos tag create \x3Cusername>/my-fine-tuned-model v1.0 -m "Initial release"

Further Reference

Reference version: hf CLI v1.x

For the full list of commands and options, use built-in help:

hf --help
hf \x3Ccommand> --help

Safety Rules

  • Destructive commands require explicit user confirmation. Before running any of the following, describe what will happen and ask the user to confirm:
    • hf repos delete — permanently deletes a repository
    • hf repos delete-files — deletes files from a repository
    • hf buckets delete / hf buckets rm — deletes buckets or bucket files
    • hf discussions close / hf discussions merge — closes or merges PRs/discussions
    • hf collections delete — permanently deletes a collection
    • hf endpoints delete — permanently deletes an Inference Endpoint
    • hf jobs cancel — cancels a running compute job
    • Any command with --delete flag (e.g., sync with deletion)
    • hf cache rm / hf cache prune — removes cached data from disk (re-downloadable, but may waste bandwidth)
  • Never expose or log the HF_TOKEN value. Do not include it in command output or commit it to files.
  • When uploading, warn the user if the target repo is public and the upload may contain sensitive data.
安全使用建议
This skill is what it says: a wrapper around the official hf CLI. Before installing or enabling it: 1) Only provide HF_TOKEN (no other creds needed). Use a read-scoped token if you only need to browse/download; use write-scoped tokens only when necessary. 2) Be cautious persisting the token in shared shell profiles — prefer per-session or least-privilege tokens. 3) Review any hf commands the agent plans to run (some are destructive: delete repo, delete buckets, upload, deploy). 4) Install hf from official sources (pip install "huggingface_hub[cli]" or Homebrew). 5) If you want to limit risk, disable autonomous invocation for this skill or supply a read-only token while exploring.
功能分析
Type: OpenClaw Skill Name: hugging-face-cli Version: 1.1.0 The skill is a legitimate and well-documented wrapper for the official Hugging Face CLI (hf). It includes clear instructions for installation, authentication via the HF_TOKEN environment variable, and a comprehensive list of standard commands. Notably, it incorporates explicit 'Safety Rules' requiring user confirmation for destructive operations (e.g., deleting repositories or endpoints) and warns against exposing sensitive tokens, demonstrating a defensive and non-malicious design (SKILL.md).
能力评估
Purpose & Capability
Name/description (Hugging Face CLI) align with declared requirements: it needs the 'hf' binary and HF_TOKEN. Those are expected and proportional to managing Hub models, datasets, repos, spaces, and jobs.
Instruction Scope
SKILL.md is an instruction-only skill listing many hf commands (including create/delete repo, delete buckets, deploy endpoints, run jobs). The instructions do not ask the agent to read unrelated files or env vars, but they do advise persisting HF_TOKEN in shell profiles and enumerate destructive operations—so the user/agent must limit which commands are run and prefer least-privilege tokens for non-write tasks.
Install Mechanism
No install spec is embedded in the skill (lowest risk). The doc suggests installing via pip or Homebrew (official, expected methods). Nothing in the skill attempts to download arbitrary code or write files.
Credentials
Only HF_TOKEN is requested, which is appropriate. However, a write-scoped HF_TOKEN grants broad power (create/delete/upload, manage endpoints, run jobs). The README correctly distinguishes read vs write scopes — recommend using read-only tokens for exploration and minimal-scope tokens for other tasks.
Persistence & Privilege
always is false and the skill does not request system-wide config changes. Autonomous invocation is allowed (platform default) — combined with a write-token this increases blast radius, so token scope matters.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install hugging-face-cli
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /hugging-face-cli 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
Add alternative installation methods (pip, Homebrew), simplify section structure
v1.0.6
Fix PATH issue: source shell profile instead of restarting terminal
v1.0.5
Move cache rm/prune to end of destructive list
v1.0.4
Remove When to Use section, shorten description, use AI models
v1.0.3
Simplify install section, remove brew metadata
v1.0.2
Remove numbered headings and When NOT to Use section
v1.0.1
Shorten description to fit ClawHub display
v1.0.0
Initial release: 48 commands covering repos, models, datasets, spaces, jobs, endpoints, papers, collections, discussions, buckets, cache, and sync
元数据
Slug hugging-face-cli
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 8
常见问题

Hugging Face CLI 是什么?

Manage Hugging Face Hub via hf CLI. Use when working with HF AI models, datasets, spaces, or repos. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 311 次。

如何安装 Hugging Face CLI?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install hugging-face-cli」即可一键安装,无需额外配置。

Hugging Face CLI 是免费的吗?

是的,Hugging Face CLI 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Hugging Face CLI 支持哪些平台?

Hugging Face CLI 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Hugging Face CLI?

由 Yevhen Diachenko(@yevhendiachenko0)开发并维护,当前版本 v1.1.0。

💬 留言讨论