自动化与脚本
需要管理 Hugging Face Hub 资源时,用…
适用场景:在 Hugging Face 生态中管理模型、数据集、Spaces、Jobs、Endpoints、Buckets、论文与 Webhooks,或需要云存储训练检查点/数据管道/agent traces 时,使用 hf CLI。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
需要管理 Hugging Face Hu特定
解决思路
- 安装 hf:运行 `curl -LsSf https://hf.co/cli/install.sh | bash -s`。
- 重要:`hf` 命令已替代废弃的 `huggingface-cli`。
- 运行 `hf --help` 查看可用功能;认证命令统一在 `hf auth` 下,例如 `hf auth whoami`。
- 由 `huggingface_hub v1.32.0` 生成;运行 `hf skills add --force` 可重新生成技能。
- `hf cp SRC`:在本地路径、仓库和 buckets 之间复制文件;支持 `--format [auto|human|agent|json|quiet]`。
- `hf download REPO_ID`:从 Hub 下载文件;支持 `--type [model|dataset|space|kernel] --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`:在本地目录和 bucket 之间同步文件;支持 `--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|kernel] --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;改用 `hf upload`;支持 `--type [model|dataset|space|kernel] --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 list`:列出所有已存访问令牌;支持 `--format [auto|human|agent|json|quiet]`。
- `hf auth login`:通过浏览器登录,或使用 huggingface.co/settings/tokens 的 token;支持 `--add-to-git-credential --force --format [auto|human|agent|json|quiet]`。
- `hf auth logout`:登出指定 token;支持 `--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 cp SRC`:在本地路径、仓库和 buckets 之间复制文件;支持 `--format [auto|human|agent|json|quiet]`。
- `hf buckets create BUCKET_ID`:创建新 bucket;支持 `--private --region [us|eu] --exist-ok --format [auto|human|agent|json|quiet]`。
- `hf buckets delete BUCKET_ID`:删除 bucket;支持 `--yes --missing-ok --format [auto|human|agent|json|quiet]`。
- `hf buckets info BUCKET_ID`:获取 bucket 信息;支持 `--format [auto|human|agent|json|quiet]`。
- `hf buckets list`:列出 buckets 或 bucket 内文件;支持 `--human-readable --tree --recursive --search TEXT --format [auto|human|agent|json|quiet]`。
- `hf buckets move FROM_ID TO_ID`:移动/重命名 bucket 到新名称或命名空间;支持 `--format [auto|human|agent|json|quiet]`。
- `hf buckets remove ARGUMENT`:从 bucket 移除文件;支持 `--recursive --yes --dry-run --include TEXT --exclude TEXT --format [auto|human|agent|json|quiet]`。
- `hf buckets settings BUCKET_ID`:更新 bucket 设置(可见性);支持 `--private --public --format [auto|human|agent|json|quiet]`。
- `hf buckets sync`:在本地目录和 bucket 之间同步文件;支持 `--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 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 --show-warnings --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|kernel] --revision TEXT --cache-dir TEXT --local-dir TEXT --fail-on-missing-files --fail-on-extra-files --format [auto|human|agent|json|quiet]`。
- `hf collections add-item COLLECTION_SLUG ITEM_ID ITEM_TYPE`:向 collection 添加条目;支持 `--note TEXT --exists-ok --format [auto|human|agent|json|quiet]`。
- `hf collections create TITLE`:在 Hub 创建新 collection;支持 `--namespace TEXT --description TEXT --private --exists-ok --format [auto|human|agent|json|quiet]`。
- `hf collections delete COLLECTION_SLUG`:从 Hub 删除 collection;支持 `--missing-ok --format [auto|human|agent|json|quiet]`。
- `hf collections delete-item COLLECTION_SLUG ITEM_OBJECT_ID`:从 collection 删除条目;支持 `--missing-ok --format [auto|human|agent|json|quiet]`。
- `hf collections info COLLECTION_SLUG`:获取 Hub 上 collection 信息;支持 `--format [auto|human|agent|json|quiet]`。
- `hf collections list`:列出 Hub 上 collections;支持 `--owner TEXT --item TEXT --sort [lastModified|trending|upvotes] --limit INTEGER --format [auto|human|agent|json|quiet]`。
- `hf collections update COLLECTION_SLUG`:更新 collection 元数据;支持 `--title TEXT --description TEXT --position INTEGER --private --theme TEXT --format [auto|human|agent|json|quiet]`。
- `hf collections update-item COLLECTION_SLUG ITEM_OBJECT_ID`:更新 collection 中条目;支持 `--note TEXT --position INTEGER --format [auto|human|agent|json|quiet]`。
- `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 close REPO_ID NUM`:关闭 discussion 或 pull request;支持 `--comment TEXT --yes --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions comment REPO_ID NUM`:评论 discussion 或 pull request;支持 `--body TEXT --body-file PATH --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions create REPO_ID --title TEXT`:在仓库创建新 discussion 或 pull request;支持 `--body TEXT --body-file PATH --pull-request --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions diff REPO_ID NUM`:显示 pull request 的 diff;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions edit REPO_ID NUM COMMENT_ID`:编辑 discussion 或 pull request 上已有评论;支持 `--body TEXT --body-file PATH --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions info REPO_ID NUM`:获取 discussion 或 pull request 信息;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions list REPO_ID`:列出仓库上的 discussions 和 pull requests;支持 `--status [open|closed|merged|draft|all] --kind [all|discussion|pull_request] --author TEXT --limit INTEGER --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions merge REPO_ID NUM`:合并 pull request;支持 `--comment TEXT --yes --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions rename REPO_ID NUM NEW_TITLE`:重命名 discussion 或 pull request;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf discussions reopen REPO_ID NUM`:重新打开已关闭的 discussion 或 pull request;支持 `--comment TEXT --yes --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `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 --engine [custom|hf-serve|llamacpp|sglang|tei|tgi|tgi-neuron|vllm|vllm-neuron] --health-route TEXT --port INTEGER --container-registry-username TEXT --container-registry-password TEXT --tensor-parallel-size INTEGER --data-parallel-size 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`:获取已有 endpoint 信息;支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf endpoints hardware`:列出可用于部署 Inference Endpoint 的硬件;支持 `--namespace TEXT --vendor TEXT --region TEXT --accelerator TEXT --instance-type TEXT --all --format [auto|human|agent|json|quiet]`。
- `hf endpoints list`:列出给定 namespace 的所有 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`:更新已有 endpoint;支持 `--namespace TEXT --repo TEXT --accelerator TEXT --instance-size TEXT --instance-type TEXT --framework TEXT --revision TEXT --task TEXT --custom-image TEXT --engine [custom|hf-serve|llamacpp|sglang|tei|tgi|tgi-neuron|vllm|vllm-neuron] --health-route TEXT --port INTEGER --tensor-parallel-size INTEGER --data-parallel-size INTEGER --container-command TEXT --container-args 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 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 extensions update`:将已安装扩展更新到最新版本;支持 `--format [auto|human|agent|json|quiet]`。
- `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` 会替换所有现有标签,只传 `--name` 会保留标签;支持 `--name TEXT --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 --name 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 --name 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 --dry-run --expose INTEGER --ssh --network-group TEXT --network-alias TEXT --resource-group-id TEXT --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` 会替换所有现有标签,只传 `--name` 会保留标签;支持 `--name TEXT --label TEXT --clear --namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf jobs scheduled list`:列出定时 Jobs;支持 `--all --status [active|suspended] --label TEXT --name TEXT --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 --name 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 --dry-run --expose INTEGER --resource-group-id TEXT --namespace TEXT`。
- `hf jobs scheduled suspend SCHEDULED_JOB_ID`:暂停定时 Job;支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf jobs scheduled trigger 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 --name TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --timeout TEXT --dry-run --expose INTEGER --resource-group-id TEXT --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 --name TEXT --label TEXT --volume TEXT --env-file TEXT --secrets-file TEXT --timeout TEXT --detach --dry-run --expose INTEGER --ssh --network-group TEXT --network-alias TEXT --resource-group-id TEXT --namespace TEXT --with TEXT --python TEXT`。
- `hf jobs wait JOB_IDS`:等待一个或多个 Job 达到终态;支持 `--timeout TEXT --namespace TEXT --format [auto|human|agent|json|quiet]`。
- `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 --pipeline-tag TEXT --gated --apps TEXT --num-parameters TEXT --inference-provider [baseten|cerebras|cohere|deepinfra|fal-ai|featherless-ai|fireworks-ai|groq|hf-inference|novita|nscale|openai|ovhcloud|publicai|replicate|scaleway|together|wavespeed|zai-org] --warm --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 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 branch create REPO_ID BRANCH`:为 Hub 仓库创建新分支;支持 `--revision TEXT --type [model|dataset|space|kernel] --exist-ok --format [auto|human|agent|json|quiet]`。
- `hf repos branch delete REPO_ID BRANCH`:从 Hub 仓库删除分支;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf repos cp SRC`:在本地路径、仓库和 buckets 之间复制文件;支持 `--format [auto|human|agent|json|quiet]`。
- `hf repos create REPO_ID`:在 Hub 创建新仓库;支持 `--type [model|dataset|space|kernel] --sdk TEXT --template 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|kernel] --missing-ok --yes --format [auto|human|agent|json|quiet]`。
- `hf repos delete-files REPO_ID PATTERNS`:从 Hub 仓库删除文件;支持 `--type [model|dataset|space|kernel] --revision TEXT --commit-message TEXT --commit-description TEXT --create-pr --format [auto|human|agent|json|quiet]`。
- `hf repos duplicate FROM_ID`:在 Hub 复制仓库(model、dataset 或 Space);支持 `--type [model|dataset|space|kernel] --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`:列出所有仓库(models、datasets、spaces、buckets)及存储信息;支持 `--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`:把仓库从一个 namespace 移动到另一个 namespace;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf repos settings REPO_ID`:更新仓库设置;支持 `--gated [auto|manual|false] --private --public --protected --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf repos tag create REPO_ID TAG`:为仓库创建 tag;支持 `--message TEXT --revision TEXT --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf repos tag delete REPO_ID TAG`:删除仓库 tag;支持 `--yes --type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf repos tag list REPO_ID`:列出仓库 tags;支持 `--type [model|dataset|space|kernel] --format [auto|human|agent|json|quiet]`。
- `hf sandbox cp SRC DST`:在本地机器和 sandbox 之间复制文件(docker 风格);支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox create`:创建 sandbox,默认是专用 VM,使用 `--pool` 可创建便宜共享 sandbox;支持 `--pool 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] --idle-timeout TEXT --env TEXT --secrets TEXT --label TEXT --env-file TEXT --secrets-file TEXT --volume TEXT --namespace TEXT --forward-hf-token --format [auto|human|agent|json|quiet]`。
- `hf sandbox exec SANDBOX_ID COMMAND`:在 sandbox 中运行命令并流式输出;以命令退出码退出;支持 `--workdir TEXT --env TEXT --env-file TEXT --timeout FLOAT --namespace TEXT`。
- `hf sandbox kill`:终止 sandbox、整个共享主机或全部(`--all`);支持 `--all --yes --namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox pool create`:预热池:立即启动一个主机 VM,并打标签以便之后按 pool id 找到;支持 `--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] --per-host INTEGER RANGE --max-hosts INTEGER RANGE --idle-timeout TEXT --namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox pool delete POOL_ID`:终止池中每个主机 VM(因此也终止其所有 sandboxes);支持 `--yes --namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox pool ls`:列出正在运行的 sandbox 池(按主机 VM 分组);支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox process kill SANDBOX_ID PID`:停止 sandbox 中运行的后台进程;支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox process ls SANDBOX_ID`:列出 sandbox 中运行的后台进程(由 `hf sandbox spawn` 启动);支持 `--namespace TEXT --format [auto|human|agent|json|quiet]`。
- `hf sandbox spawn SANDBOX_ID COMMAND`:在后台启动长运行命令并返回 pid,不等待;支持 `--workdir TEXT --env TEXT --env-file TEXT --namespace TEXT`。
- `hf skills add`:为 AI 助手安装 Hugging Face 技能;支持 `--claude --global --dest PATH --force --format [auto|human|agent|json|quiet]`。
- `hf skills list`:列出 Hugging Face marketplace 中可用技能;支持 `--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 marketplace 技能;支持 `--claude --global --dest PATH --format [auto|human|agent|json|quiet]`。
- `hf spaces card SPACE_ID`:获取 Hub 上 Space 卡片(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 仓库内文件;支持 `--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 templates`:列出可用 Space 模板;支持 `--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 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`:列出当前用户所有 webhooks;支持 `--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 revision id,可以是分支名、tag 或 commit hash。
- 通用选项:`--token` 使用 User Access Token;优先设置 `HF_TOKEN` 环境变量而不是传 `--token`。
- 通用选项:`--type` 指定仓库类型(model、dataset、space 或 kernel)。
- 如需把 Hub 仓库或 buckets 挂载为本地文件系统,无需下载、复制或等待,使用 `hf-mount`;文件按需拉取;GitHub:https://github.com/huggingface/hf-mount。
- 安装 `hf-mount`:运行 `brew install hf-mount`,或从 https://github.com/huggingface/hf-mount/releases 下载二进制。
- 使用 `hf-mount start repo openai-community/gpt2 /tmp/gpt2` 挂载仓库(只读)。
- 使用 `hf-mount start --hf-token $HF_TOKEN bucket myuser/my-bucket /tmp/data` 挂载 bucket(读写)。
- 使用 `hf-mount status` 列出挂载,或 `hf-mount stop /tmp/data` 卸载。
- 使用 `hf <command> --help` 查看完整选项、描述、用法和真实示例。
- 认证优先用 `HF_TOKEN` 环境变量(推荐),或用 `--token`。
- 用 `hf update` 更新 CLI,它会按检测到的安装方式使用正确命令。
适用边界 · 注意事项
- 没有 Hugging Face 账号、网络访问,或不允许访问 Hugging Face Hub 时,不应使用。
- 完全不需要 Hugging Face 生态、只想在本地管理模型/数据集/文件时,不应使用。
- 不要继续使用已弃用的 `huggingface-cli`;旧流程中的 `hf upload-large-folder` 也应优先改用 `hf upload`。