Preface¶
Pulling models, pushing checkpoints, managing cache, or deploying Inference Endpoints on Hugging Face usually relies on hf (formerly huggingface-cli) or the Python huggingface_hub. When delegating these same tasks to a coding Agent, the common issue isn’t “not knowing how to write scripts,” but rather misremembering subcommands, parameters, and authentication paths—such as still using the deprecated huggingface-cli or treating whoami as a top-level command.
Below is an introduction to the hf-cli Skill from the official Hugging Face repository: it encodes Hub CLI usage into instructions that Agents can follow, covering downloading, uploading, caching, authentication, and extended capabilities like buckets, jobs, and endpoints, thereby reducing command hallucinations.
What is this¶
hf-cli is an Agent Skill in the Hugging Face skills repository, targeting the terminal tool hf (Hugging Face Hub CLI). The documentation specifies: hf is used to download, upload, and manage models, datasets, Spaces, buckets, repositories, papers, jobs, etc., on the Hub; and it replaces the deprecated huggingface-cli.
The Skill’s trigger scope is broad: it should be prioritized when users mention hf, huggingface, Hugging Face, huggingface-cli, or when performing Hub / ML ecosystem related operations (including training checkpoints, data pipelines, cloud storage sync); it is applicable even if the user doesn’t explicitly ask for “a CLI command.” The documentation content is generated from huggingface_hub v2.2.0 and can be regenerated using hf skills add --force.
Core Functions¶
The Skill embeds the hf command system rather than a standalone executable program. Verifiable capabilities based on the documentation include:
- Repositories & Files:
hf download,hf upload,hf cp; supports--type(model / dataset / space / kernel), revision, include / exclude, local directories, and cache directories. - Authentication: Unified under
hf auth, e.g.,hf auth login,hf auth whoami,hf auth list,hf auth switch,hf auth logout. - Local Cache:
hf cache list,hf cache prune,hf cache rm,hf cache verify. - Buckets & Sync:
hf bucketssubcommands (create, list, cp, sync, etc.) and top-levelhf sync(sync local directories with buckets). - Hub Resource Browsing & Management:
hf datasets,hf collections, etc. (The Skill documentation includes datasets card / info / leaderboard / list, etc.; the scraped data has truncation in the datasets section, other subcommands are subject to the Commands list in the Skill). - Environment & Maintenance:
hf env,hf version,hf update. - Output Formats: Most commands support
--format [auto|human|agent|json|quiet]to facilitate Agent result parsing.
The summary on officialskills.sh adds: hf covers part of the Hub lifecycle scenarios—downloading, uploading, caching, Inference Endpoints, jobs, webhooks, etc.—in a single binary, reducing the need to switch between web pages, Python, and multiple tools. Specific subcommands remain subject to the GitHub Skill documentation.
Installation and Activation¶
There are two levels: installing the hf CLI on the local machine, and installing the Skill in the Agent environment.
Install hf CLI¶
The official installation command:
curl -LsSf https://hf.co/cli/install.sh | bash -s
After installation, use hf --help to view subcommands; authentication-related commands are under hf auth.
Add hf-cli Skill to Agent¶
The method provided by officialskills.sh is:
npx skills add https://github.com/huggingface/skills --skill hf-cli
You can also provide the Skill directory link in the conversation and let the coding assistant install it according to project conventions:
https://github.com/huggingface/skills/tree/main/skills/hf-cli
If the documentation does not differentiate installation variations for Cursor, Codex CLI, or Claude Code, follow the above npx skills add and repository paths.
Typical Usage¶
The following examples are all derived from command definitions in the Skill documentation. Replace REPO_ID, paths, and tokens as needed.
Confirm environment and login identity
hf env
hf auth whoami
For the first time or when switching accounts, log in via browser or token (tokens can be created at huggingface.co/settings/tokens):
hf auth login
Download a specific model to a local directory
hf download REPO_ID --type model --local-dir ./my-model --revision main
To view the plan without actually downloading, use --dry-run mentioned in the documentation; for large repositories, you can use parameters like --max-workers (see hf download --help).
Upload a folder to Hub
hf upload REPO_ID ./output-folder --type model --commit-message "Add checkpoint"
For private repositories, add --private; if merging via PR is desired, the documentation provides --create-pr.
View and clean up cache
hf cache list --sort size:desc
hf cache prune --dry-run
Sync local training directory with bucket
hf buckets sync --dry-run
hf sync --dry-run
Before actual execution, it is recommended to use --dry-run to verify the files to be changed; hf sync and hf buckets sync both support include / exclude, delete, and other options in the documentation.
Update the CLI itself
hf update
Applicable Scenarios and Notes¶
Who it’s for
- ML engineers who frequently download fixed revisions, upload large weights or datasets on the Hub.
- Teams that want Agents to write commands and check parameters, requiring consistency with current
hfbehavior (including migration afterhuggingface-clideprecation). - Scenarios requiring handling Hub peripheral operations like buckets sync, cache verification, collections / datasets queries.
Notes
- The Skill description emphasizes: enable this Skill for any Hub ecosystem related tasks to prevent Agents from fabricating non-existent subcommands or old
huggingface-cliinterfaces. - Authentication and token management involve security:
hf auth tokenwill print the current token to stdout, requiring manual masking in shared logs or Agent transcripts. - The documentation is generated by the
huggingface_hubversion; after Hub adds new subcommands, runhf skills add --forceand localhf updateto keep the documentation and binary consistent. - The scraped data has truncation for the long command list after
hf datasets; for capabilities not listed in the text, refer tohf <subcommand> --helpand the complete Commands section in the official Skill directory.
Conclusion¶
The value of hf-cli lies in encoding the boundaries of the official Hugging Face Hub CLI (hf) into the Agent workflow—downloading, uploading, caching, authentication, and buckets operations are verifiable, and it explicitly replaces the deprecated huggingface-cli. After installing the CLI and Skill, let the Agent default to using this set of instructions when dealing with hf or Hugging Face Hub.
- Skill Directory: https://github.com/huggingface/skills/tree/main/skills/hf-cli
- CLI Installation: https://hf.co/cli/install.sh (Execute via
curlpipe, see command above)