mcpField
H
hugging-face-cli

hugging-face-cli

github.com/sickn33开发48.8k92 次安装今天更新
代码仓库

关于 hugging-face-cli

hugging-face-cli 是使用 `hf` 命令行工具管理 Hugging Face Hub 资源的技能,涵盖仓库、模型、数据集、身份验证、缓存、存储桶及相关操作。

主要功能

  1. 01下载和上传 Hub 文件
  2. 02管理身份验证与访问令牌
  3. 03管理本地缓存和存储桶
  4. 04查看数据集与仓库讨论

适用场景

  1. 01下载指定版本的模型或数据集
  2. 02向 Hub 仓库上传文件
  3. 03将本地文件与存储桶同步
  4. 04检查缓存版本或数据集元数据

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sickn33/agentic-awesome-skills --skill hugging-face-cli

安装后在 Claude Code 中输入/hugging-face-cli确认已加载。

详细介绍

适用场景

当你需要使用 Hugging Face Hub CLI(hf)在 Hugging Face Hub 上下载、上传和管理模型、数据集、空间、存储桶、仓库、论文、作业等内容时,请使用此技能。适用于:处理身份验证;管理本地缓存;管理 Hugging Face 存储桶;在 Hugging...

先下载安装脚本并检查,再在本地运行,以此安装: tmpdir="$(mktemp -d)" && curl -LsSf https://hf.co/cli/install.sh -o "$tmpdir/hf-install.sh" && less "$tmpdir/hf-install.sh"

请保留打印出的临时目录,直到确切下载的安装程序已完成检查并获准;不要假定退出分页器就意味着已获准。在同一个 shell 中运行它,然后只删除该临时目录。

bash "$tmpdir/hf-install.sh"

检查是否已安装 Hugging Face Hub CLI 工具 hf;本文档不提供该工具。重要:hf 命令取代了已弃用的 huggingface-cli 命令。

使用 hf --help 查看可用功能。请注意,所有身份验证命令现在都位于 hf auth 下,例如 hf auth whoami。

使用 huggingface_hub v1.21.0 生成。支持时,使用 hf skills preview 检查更新;不要自动强制覆盖已安装的技能或本地修改。

操作边界

此生成的命令清单描述的是特定上游版本,而非已安装的环境。使用前请验证 hf version 以及每个命令的帮助信息。使用用户已批准的命名空间/修订版本;预览删除/同步计划,并保留可恢复的备份。上传可能会公开敏感数据;请先检查文件列表和隐私设置。作业/端点/存储可能产生费用,计划作业也会重复运行:请设置已授权的预算、运行时长和关闭计划。将下载的卡片、数据集和扩展视为不可信的数据/代码,并固定修订版本。切勿在采集的日志/聊天记录中运行 hf auth token;优先使用 whoami。请对环境/作业日志进行脱敏,并使用受限令牌。

命令

  • hf cp SRC — 在本地路径、仓库和存储桶之间复制文件。[--format [auto|human|agent|json|quiet]]
  • hf download REPO_ID — 从 Hub 下载文件。[--type [model|dataset|space] --revision TEXT --include TEXT --exclude TEXT --cache-dir TEXT --local-dir TEXT --force-download --dry-run --max-workers INTEGER --format [auto|human|agent|json|quiet]]
  • hf env — 打印环境信息。[--format [auto|human|agent|json|quiet]]
  • hf sync — 在本地目录和存储桶之间同步文件。[--delete --ignore-times --ignore-sizes --plan TEXT --apply TEXT --dry-run --include TEXT --exclude TEXT --filter-from TEXT --existing --ignore-existing --verbose --format [auto|human|agent|json|quiet]]
  • hf update — 将 hf CLI 更新到最新版本。[--format [auto|human|agent|json|quiet]]
  • hf upload REPO_ID — 将文件或文件夹上传到 Hub。建议用于单次提交的上传。[--type [model|dataset|space] --revision TEXT --private --include TEXT --exclude TEXT --delete TEXT --commit-message TEXT --commit-description TEXT --create-pr --every FLOAT --format [auto|human|agent|json|quiet]]
  • hf upload-large-folder REPO_ID LOCAL_PATH — 将大型文件夹上传到 Hub。建议用于可恢复的上传。[--type [model|dataset|space] --revision TEXT --private --include TEXT --exclude TEXT --num-workers INTEGER --no-report --no-bars --format [auto|human|agent|json|quiet]]
  • hf version — 打印 hf 版本信息。[--format [auto|human|agent|json|quiet]]
hf auth — 管理身份验证(登录、退出等)。
  • hf auth list — 列出所有已存储的访问令牌。[--format [auto|human|agent|json|quiet]]
  • hf auth login — 通过浏览器登录,或使用来自 huggingface.co/settings/tokens 的令牌登录。[--add-to-git-credential --force --format [auto|human|agent|json|quiet]]
  • hf auth logout — 退出特定令牌的登录。[--token-name TEXT --format [auto|human|agent|json|quiet]]
  • hf auth switch — 在访问令牌之间切换。[--token-name TEXT --add-to-git-credential --format [auto|human|agent|json|quiet]]
  • hf auth token — 将当前访问令牌打印到 stdout。[--format [auto|human|agent|json|quiet]]
  • hf auth whoami — 查明当前登录的是哪个 huggingface.co 账户。[--format [auto|human|agent|json|quiet]]
hf buckets — 与存储桶交互的命令。
  • hf buckets cp SRC — 在本地路径、存储库和存储桶之间复制文件。[--format [auto|human|agent|json|quiet]]
  • hf buckets create BUCKET_ID — 创建新的存储桶。[--private --region [us|eu] --exist-ok --format [auto|human|agent|json|quiet]]
  • hf buckets delete BUCKET_ID — 删除存储桶。[--yes --missing-ok --format [auto|human|agent|json|quiet]]
  • hf buckets info BUCKET_ID — 获取存储桶信息。[--format [auto|human|agent|json|quiet]]
  • hf buckets list — 列出存储桶或存储桶中的文件。[--human-readable --tree --recursive --search TEXT --format [auto|human|agent|json|quiet]]
  • hf buckets move FROM_ID TO_ID — 将存储桶移动(重命名)到新的名称或命名空间。[--format [auto|human|agent|json|quiet]]
  • hf buckets remove ARGUMENT — 从存储桶中移除文件。[--recursive --yes --dry-run --include TEXT --exclude TEXT --format [auto|human|agent|json|quiet]]
  • hf buckets sync — 在本地目录和存储桶之间同步文件。[--delete --ignore-times --ignore-sizes --plan TEXT --apply TEXT --dry-run --include TEXT --exclude TEXT --filter-from TEXT --existing --ignore-existing --verbose --format [auto|human|agent|json|quiet]]
hf cache — 管理本地缓存目录。
  • hf cache list — 列出缓存的存储库或修订版本。[--cache-dir TEXT --revisions --filter TEXT --sort [accessed|accessed:asc|accessed:desc|modified|modified:asc|modified:desc|name|name:asc|name:desc|size|size:asc|size:desc] --limit INTEGER --format [auto|human|agent|json|quiet]]
  • hf cache prune — 从缓存中移除脱离的修订版本。[--cache-dir TEXT --yes --dry-run --format [auto|human|agent|json|quiet]]
  • hf cache rm TARGETS — 移除缓存的存储库或修订版本。[--cache-dir TEXT --yes --dry-run --format [auto|human|agent|json|quiet]]
  • hf cache verify REPO_ID — 校验缓存或本地目录中单个存储库修订版本的校验和。[--type [model|dataset|space] --revision TEXT --cache-dir TEXT --local-dir TEXT --fail-on-missing-files --fail-on-extra-files --format [auto|human|agent|json|quiet]]
hf collections — 与 Hub 上的集合交互。
  • hf collections add-item COLLECTION_SLUG ITEM_ID ITEM_TYPE — 将一个条目添加到集合中。[--note TEXT --exists-ok --format [auto|human|agent|json|quiet]]
  • hf collections create TITLE — 在 Hub 上创建一个新集合。[--namespace TEXT --description TEXT --private --exists-ok --format [auto|human|agent|json|quiet]]
  • hf collections delete COLLECTION_SLUG — 删除 Hub 上的一个集合。[--missing-ok --format [auto|human|agent|json|quiet]]
  • hf collections delete-item COLLECTION_SLUG ITEM_OBJECT_ID — 从集合中删除一个条目。[--missing-ok --format [auto|human|agent|json|quiet]]
  • hf collections info COLLECTION_SLUG — 获取 Hub 上某个集合的信息。[--format [auto|human|agent|json|quiet]]
  • hf collections list — 列出 Hub 上的集合。[--owner TEXT --item TEXT --sort [lastModified|trending|upvotes] --limit INTEGER --format [auto|human|agent|json|quiet]]
  • hf collections update COLLECTION_SLUG — 更新 Hub 上某个集合的元数据。[--title TEXT --description TEXT --position INTEGER --private --theme TEXT --format [auto|human|agent|json|quiet]]
  • hf collections update-item COLLECTION_SLUG ITEM_OBJECT_ID — 更新集合中的一个条目。[--note TEXT --position INTEGER --format [auto|human|agent|json|quiet]]
hf datasets — 与 Hub 上的数据集交互。
  • hf datasets card DATASET_ID — 获取 Hub 上某个数据集的数据集卡片(README)。[--metadata --text --format [auto|human|agent|json|quiet]]
  • hf datasets info DATASET_ID — 获取 Hub 上某个数据集的信息。[--revision TEXT --expand TEXT --format [auto|human|agent|json|quiet]]
  • hf datasets leaderboard DATASET_ID — 列出数据集排行榜中的模型分数。此命令可帮助查找适合某项任务的最佳模型,或根据基准测试分数比较模型。使用 'hf datasets ls --filter benchmark:official' 列出可用的排行榜。[--limit INTEGER --format [auto|human|agent|json|quiet]]
  • hf datasets list — 列出 Hub 上的数据集,或列出数据集仓库中的文件。[--search TEXT --author TEXT --filter TEXT --sort [created_at|downloads|last_modified|likes|trending_score] --limit INTEGER --expand TEXT --human-readable --tree --recursive --revision TEXT --format [auto|human|agent|json|quiet]]
  • hf datasets parquet DATASET_ID — 列出某个数据集可用的 Parquet 文件 URL。[--subset TEXT --split TEXT --format [auto|human|agent|json|quiet]]
  • hf datasets sql SQL — 使用 DuckDB 对数据集 Parquet URL 执行原始 SQL 查询。[--format [auto|human|agent|json|quiet]]
hf discussions — 管理 Hub 上的讨论和拉取请求。
  • hf discussions close REPO_ID NUM — 关闭讨论或拉取请求。[--comment TEXT --yes --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions comment REPO_ID NUM — 对讨论或拉取请求发表评论。[--body TEXT --body-file PATH --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions create REPO_ID --title TEXT — 在仓库中创建新讨论或拉取请求。[--body TEXT --body-file PATH --pull-request --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions diff REPO_ID NUM — 显示拉取请求的差异。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions info REPO_ID NUM — 获取讨论或拉取请求的信息。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions list REPO_ID — 列出仓库中的讨论和拉取请求。[--status [open|closed|merged|draft|all] --kind [all|discussion|pull_request] --author TEXT --limit INTEGER --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions merge REPO_ID NUM — 合并拉取请求。[--comment TEXT --yes --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions rename REPO_ID NUM NEW_TITLE — 重命名讨论或拉取请求。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf discussions reopen REPO_ID NUM — 重新打开已关闭的讨论或拉取请求。[--comment TEXT --yes --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
hf endpoints — 管理 Hugging Face Inference Endpoints。
  • hf endpoints catalog deploy --repo TEXT — 从 Model Catalog 部署 Inference Endpoint。[--name TEXT --accelerator TEXT --namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf endpoints catalog list — 列出可用的 Catalog 模型。[--format [auto|human|agent|json|quiet]]
  • hf endpoints delete NAME — 永久删除 Inference Endpoint。[--namespace TEXT --yes --format [auto|human|agent|json|quiet]]
  • hf endpoints deploy NAME --repo TEXT --framework TEXT --accelerator TEXT --instance-size TEXT --instance-type TEXT --region TEXT --vendor TEXT — 从 Hub 仓库部署 Inference Endpoint。[--namespace TEXT --task TEXT --min-replica INTEGER --max-replica INTEGER --scale-to-zero-timeout INTEGER --scaling-metric [pendingRequests|hardwareUsage] --scaling-threshold FLOAT --revision TEXT --custom-image TEXT --health-route TEXT --port INTEGER --container-command TEXT --container-args TEXT --env TEXT --env-file TEXT --secrets TEXT --secrets-file TEXT --type [public|protected|authenticated|private] --format [auto|human|agent|json|quiet]]
  • hf endpoints describe NAME — 获取现有端点的信息。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf endpoints list — 列出指定命名空间的所有 Inference Endpoints。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf endpoints pause NAME — 暂停 Inference Endpoint。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf endpoints resume NAME — 恢复 Inference Endpoint。[--namespace TEXT --fail-if-already-running --format [auto|human|agent|json|quiet]]
  • hf endpoints scale-to-zero NAME — 将 Inference Endpoint 缩容至零。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf endpoints update NAME — 更新现有端点。[--namespace TEXT --repo TEXT --accelerator TEXT --instance-size TEXT --instance-type TEXT --framework TEXT --revision TEXT --task TEXT --min-replica INTEGER --max-replica INTEGER --scale-to-zero-timeout INTEGER --scaling-metric [pendingRequests|hardwareUsage] --scaling-threshold FLOAT --format [auto|human|agent|json|quiet]]
hf extensions — 管理 hf CLI 扩展。
  • hf extensions exec NAME — 执行已安装的扩展。
  • hf extensions install REPO_ID — 从公开的 GitHub 仓库安装扩展。[--force --format [auto|human|agent|json|quiet]]
  • hf extensions list — 列出已安装的扩展命令。[--format [auto|human|agent|json|quiet]]
  • hf extensions remove NAME — 移除已安装的扩展。[--format [auto|human|agent|json|quiet]]
  • hf extensions search — 搜索 GitHub 上可用的扩展(带有 'hf-extension' 主题标签)。[--format [auto|human|agent|json|quiet]]
hf jobs — 在 Hub 上运行和管理 Jobs。
  • hf jobs cancel JOB_ID — 取消一个 Job [--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs hardware — 列出 Jobs 可用的硬件选项 [--format [auto|human|agent|json|quiet]]
  • hf jobs inspect JOB_IDS — 显示一个或多个 Job 的详细信息 [--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs labels JOB_ID — 更新 Job 上的标签。替换所有现有标签。[--label TEXT --clear --namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs list — 列出 Jobs。[--all --status [COMPLETED|CANCELED|ERROR|DELETED|SCHEDULING|RUNNING] --label TEXT --limit INTEGER --namespace TEXT --filter TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs logs JOB_ID — 获取 Job 的日志。[--follow --tail INTEGER --namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs run IMAGE COMMAND — 运行一个 Job。[--env TEXT --secrets TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|rtx-pro-6000|rtx-pro-6000x2|rtx-pro-6000x4|rtx-pro-6000x8] --timeout TEXT --detach --expose INTEGER --ssh --namespace TEXT]
  • hf jobs scheduled delete SCHEDULED_JOB_ID — 删除一个定时 Job。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled inspect SCHEDULED_JOB_IDS — 显示一个或多个定时 Job 的详细信息 [--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled labels SCHEDULED_JOB_ID — 更新定时 Job 上的标签。替换所有现有标签。[--label TEXT --clear --namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled list — 列出定时 Jobs [--all --namespace TEXT --filter TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled resume SCHEDULED_JOB_ID — 恢复(取消暂停)一个定时 Job。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled run SCHEDULE IMAGE COMMAND — 调度一个 Job。[--suspend --concurrency --env TEXT --secrets TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|rtx-pro-6000|rtx-pro-6000x2|rtx-pro-6000x4|rtx-pro-6000x8] --timeout TEXT --expose INTEGER --namespace TEXT]
  • hf jobs scheduled suspend SCHEDULED_JOB_ID — 暂停一个定时 Job。[--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs scheduled uv run SCHEDULE SCRIPT — 在 HF 基础设施上运行一个 UV 脚本(本地文件或 URL)[--suspend --concurrency --image TEXT --flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|rtx-pro-6000|rtx-pro-6000x2|rtx-pro-6000x4|rtx-pro-6000x8] --env TEXT --secrets TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --timeout TEXT --expose INTEGER --namespace TEXT --with TEXT --python TEXT]
  • hf jobs ssh JOB_ID — SSH 进入一个正在运行的 Job。[--identity-file PATH --dry-run --namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs stats — 获取 Jobs 的资源使用统计和指标 [--namespace TEXT --format [auto|human|agent|json|quiet]]
  • hf jobs uv run SCRIPT — 在 HF 基础设施上运行一个 UV 脚本(本地文件或 URL)[--image TEXT --flavor [cpu-basic|cpu-upgrade|cpu-performance|cpu-xl|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8|h200|h200x2|h200x4|h200x8|rtx-pro-6000|rtx-pro-6000x2|rtx-pro-6000x4|rtx-pro-6000x8] --env TEXT --secrets TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --timeout TEXT --detach --expose INTEGER --ssh --namespace TEXT --with TEXT --python TEXT]
  • hf jobs wait JOB_IDS — 等待一个或多个 Job 达到终止状态。[--timeout TEXT --namespace TEXT --format [auto|human|agent|json|quiet]]
hf models — 与 Hub 上的模型交互。
  • hf models card MODEL_ID — 获取 Hub 上某个模型的模型卡片(README)。[--metadata --text --format [auto|human|agent|json|quiet]]
  • hf models info MODEL_ID — 获取 Hub 上某个模型的信息。[--revision TEXT --expand TEXT --format [auto|human|agent|json|quiet]]
  • hf models list — 列出 Hub 上的模型,或某个模型仓库中的文件。[--search TEXT --author TEXT --filter TEXT --num-parameters TEXT --sort [created_at|downloads|last_modified|likes|trending_score] --limit INTEGER --expand TEXT --human-readable --tree --recursive --revision TEXT --format [auto|human|agent|json|quiet]]
hf papers — 与 Hub 上的论文交互。
  • hf papers info PAPER_ID — 获取 Hub 上某篇论文的信息。[--format [auto|human|agent|json|quiet]]
  • hf papers list — 列出 Hub 上的每日论文。[--date TEXT --week TEXT --month TEXT --submitter TEXT --sort [publishedAt|trending] --limit INTEGER --format [auto|human|agent|json|quiet]]
  • hf papers read PAPER_ID — 以 markdown 形式阅读论文。[--format [auto|human|agent|json|quiet]]
  • hf papers search QUERY — 搜索 Hub 上的论文。[--limit INTEGER --format [auto|human|agent|json|quiet]]
hf repos — 在 Hub 上管理仓库。
  • hf repos branch create REPO_ID BRANCH — 在 Hub 上为仓库创建新分支。[--revision TEXT --type [model|dataset|space] --exist-ok --format [auto|human|agent|json|quiet]]
  • hf repos branch delete REPO_ID BRANCH — 从 Hub 上的仓库删除分支。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf repos cp SRC — 在本地路径、仓库和存储桶之间复制文件。[--format [auto|human|agent|json|quiet]]
  • hf repos create REPO_ID — 在 Hub 上创建新仓库。[--type [model|dataset|space] --space-sdk TEXT --private --public --protected --exist-ok --resource-group-id TEXT --region [us|eu] --flavor [cpu-basic|cpu-upgrade|zero-a10g|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8] --storage [small|medium|large] --sleep-time INTEGER --secrets TEXT --secrets-file TEXT --env TEXT --env-file TEXT --volume TEXT --format [auto|human|agent|json|quiet]]
  • hf repos delete REPO_ID — 从 Hub 删除仓库。此操作不可逆。[--type [model|dataset|space] --missing-ok --yes --format [auto|human|agent|json|quiet]]
  • hf repos delete-files REPO_ID PATTERNS — 从 Hub 上的仓库删除文件。[--type [model|dataset|space] --revision TEXT --commit-message TEXT --commit-description TEXT --create-pr --format [auto|human|agent|json|quiet]]
  • hf repos duplicate FROM_ID — 在 Hub 上复制仓库(模型、数据集或 Space)。[--type [model|dataset|space] --private --public --protected --exist-ok --flavor [cpu-basic|cpu-upgrade|zero-a10g|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8] --storage [small|medium|large] --sleep-time INTEGER --secrets TEXT --secrets-file TEXT --env TEXT --env-file TEXT --volume TEXT --format [auto|human|agent|json|quiet]]
  • hf repos list — 列出所有仓库(模型、数据集、space、存储桶)及其存储信息。[--namespace TEXT --type [model|dataset|space|bucket] --search TEXT --limit INTEGER --explore --format [auto|human|agent|json|quiet]]
  • hf repos move FROM_ID TO_ID — 将仓库从一个命名空间移动到另一个命名空间。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf repos settings REPO_ID — 更新仓库的设置。[--gated [auto|manual|false] --private --public --protected --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf repos tag create REPO_ID TAG — 为仓库创建标签。[--message TEXT --revision TEXT --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf repos tag delete REPO_ID TAG — 删除仓库的标签。[--yes --type [model|dataset|space] --format [auto|human|agent|json|quiet]]
  • hf repos tag list REPO_ID — 列出仓库的标签。[--type [model|dataset|space] --format [auto|human|agent|json|quiet]]
hf skills — 为 AI 助手管理技能。
  • hf skills add — 下载 Hugging Face 技能并为 AI 助手安装。[--claude --global --dest PATH --force --format [auto|human|agent|json|quiet]]
  • hf skills list — 列出 Hugging Face 市场中可用的技能。[--format [auto|human|agent|json|quiet]]
  • hf skills preview — 将生成的 hf-cli SKILL.md 打印到 stdout。[--format [auto|human|agent|json|quiet]]
  • hf skills update — 更新已安装的 Hugging Face 市场技能。[--claude --global --dest PATH --format [auto|human|agent|json|quiet]]
hf spaces — 与 Hub 上的 Spaces 交互。
  • hf spaces card SPACE_ID — 获取 Hub 上某个 Space 的 Space card (README)。[--metadata --text --format [auto|human|agent|json|quiet]]
  • hf spaces dev-mode SPACE_ID — 启用或禁用某个 Space 的 dev mode。[--stop --format [auto|human|agent|json|quiet]]
  • hf spaces hardware — 列出 Spaces 可用的硬件选项。[--format [auto|human|agent|json|quiet]]
  • hf spaces hot-reload SPACE_ID — 无需完整重新构建 + 重启即可热重载某个 Space 的任意 Python 文件。[--local-file PATH --skip-checks --skip-summary --format [auto|human|agent|json|quiet]]
  • hf spaces info SPACE_ID — 获取 Hub 上某个 space 的信息。[--revision TEXT --expand TEXT --format [auto|human|agent|json|quiet]]
  • hf spaces list — 列出 Hub 上的 spaces,或某个 space repo 中的文件。[--search TEXT --author TEXT --filter TEXT --sort [created_at|last_modified|likes|trending_score] --limit INTEGER --expand TEXT --human-readable --tree --recursive --revision TEXT --format [auto|human|agent|json|quiet]]
  • hf spaces logs SPACE_ID — 获取某个 Space 的运行或构建日志。[--build --follow --tail INTEGER --format [auto|human|agent|json|quiet]]
  • hf spaces pause SPACE_ID — 暂停某个 Space。[--format [auto|human|agent|json|quiet]]
  • hf spaces restart SPACE_ID — 重启某个 Space。[--factory-reboot --format [auto|human|agent|json|quiet]]
  • hf spaces search QUERY — 使用语义搜索在 Hub 上搜索 spaces。[--filter TEXT --sdk TEXT --include-non-running --description --limit INTEGER --format [auto|human|agent|json|quiet]]
  • hf spaces secrets add SPACE_ID — 为某个 Space 添加或更新 secrets。[--secrets TEXT --secrets-file TEXT --format [auto|human|agent|json|quiet]]
  • hf spaces secrets delete SPACE_ID KEY — 从某个 Space 中移除一个 secret。[--yes --format [auto|human|agent|json|quiet]]
  • hf spaces secrets list SPACE_ID — 列出某个 Space 的 secrets。Secret 值只可写入,不会返回。[--format [auto|human|agent|json|quiet]]
  • hf spaces settings SPACE_ID — 更新某个 Space 的设置。[--sleep-time INTEGER --hardware [cpu-basic|cpu-upgrade|zero-a10g|t4-small|t4-medium|l4x1|l4x4|l40sx1|l40sx4|l40sx8|a10g-small|a10g-large|a10g-largex2|a10g-largex4|a100-large|a100x4|a100x8] --format [auto|human|agent|json|quiet]]
  • hf spaces ssh SPACE_ID — SSH 进入某个 Space 的 Dev Mode 容器。[--identity-file PATH --dry-run --auto --format [auto|human|agent|json|quiet]]
  • hf spaces variables add SPACE_ID — 为某个 Space 添加或更新环境变量。[--env TEXT --env-file TEXT --format [auto|human|agent|json|quiet]]
  • hf spaces variables delete SPACE_ID KEY — 从某个 Space 中移除一个环境变量。[--yes --format [auto|human|agent|json|quiet]]
  • hf spaces variables list SPACE_ID — 列出某个 Space 的环境变量。[--format [auto|human|agent|json|quiet]]
  • hf spaces volumes delete SPACE_ID — 移除某个 Space 的所有 volumes。[--yes --format [auto|human|agent|json|quiet]]
  • hf spaces volumes list SPACE_ID — 列出某个 Space 中挂载的 volumes。[--format [auto|human|agent|json|quiet]]
  • hf spaces volumes set SPACE_ID — 设置(替换)某个 Space 的 volumes。[--volume TEXT --format [auto|human|agent|json|quiet]]
  • hf spaces wait SPACE_ID — 等待某个 Space 完成构建/启动。[--timeout TEXT --format [auto|human|agent|json|quiet]]
hf webhooks — 管理 Hub 上的 Webhook。
  • hf webhooks create --watch TEXT — 创建新的 Webhook。[--url TEXT --job-id TEXT --domain [repo|discussions] --secret TEXT --format [auto|human|agent|json|quiet]]
  • hf webhooks delete WEBHOOK_ID — 永久删除 Webhook。[--yes --format [auto|human|agent|json|quiet]]
  • hf webhooks disable WEBHOOK_ID — 禁用已启用的 Webhook。[--format [auto|human|agent|json|quiet]]
  • hf webhooks enable WEBHOOK_ID — 启用已禁用的 Webhook。[--format [auto|human|agent|json|quiet]]
  • hf webhooks info WEBHOOK_ID — 显示单个 Webhook 的完整详情。[--format [auto|human|agent|json|quiet]]
  • hf webhooks list — 列出当前用户的所有 Webhook。[--format [auto|human|agent|json|quiet]]
  • hf webhooks update WEBHOOK_ID — 更新现有 Webhook。仅更改提供的选项。[--url TEXT --watch TEXT --domain [repo|discussions] --secret TEXT --format [auto|human|agent|json|quiet]]

通用选项

  • --format — 输出格式:--format json(或 --json)或 --format table(默认)。
  • -q / --quiet — 静默输出(每行一个 ID)。
  • --revision — Git 修订 ID,可以是分支名称、标签或提交哈希。
  • --token — 使用用户访问令牌。建议设置 HF_TOKEN 环境变量,而不是传入 --token。
  • --type — 仓库类型(model、dataset 或 space)。

将仓库挂载为本地文件系统

若要将 Hub 仓库或存储桶挂载为本地文件系统(无需下载、复制或等待),请使用 hf-mount。文件会按需获取。GitHub:https://github.com/huggingface/hf-mount

先下载安装脚本并进行审查,然后在本地运行: tmpdir="$(mktemp -d)" && curl -fsSL https://raw.githubusercontent.com/huggingface/hf-mount/main/install.sh -o "$tmpdir/hf-mount-install.sh" && less "$tmpdir/hf-mount-install.sh"

审查并批准下载的脚本后,再单独执行: sh "$tmpdir/hf-mount-install.sh"

一些命令示例:

  • hf-mount start repo openai-community/gpt2 /path/to/approved-empty-mountpoint — 挂载仓库(只读)
  • hf-mount start bucket myuser/my-bucket /path/to/approved-empty-mountpoint — 挂载存储桶(读写)
  • hf-mount status / hf-mount stop /tmp/data — 列出挂载项或卸载

提示

  • 使用 hf <command> --help 查看完整选项、说明、用法和实际示例
  • 使用 HF_TOKEN 环境变量(推荐)或 --token 进行身份验证
  • 使用 hf update 更新 CLI(会根据检测到的安装方式使用正确的命令)

示例

用户请求:

在此任务中使用 @hugging-face-cli:Hugging Face Hub CLI(hf),用于在 Hugging Face Hub 上下载、上传和管理模型、数据集、空间、存储桶、仓库、论文、作业等。

限制

  • 仅当任务明确符合其上游产品或 API 的适用范围时,才使用此技能。
  • 在进行更改前,请依据当前官方文档核实命令、API 行为、价格、配额、凭据和部署影响。
  • 不要将生成的示例视为环境特定测试、安全审查或破坏性操作及高成本操作所需用户批准的替代品。

评论

支持 Markdown