metadata
name: hf-cli
description: >-
Hugging Face Hub CLI (`hf`). Use it to search, download and upload models,
datasets and Spaces; manage repos, buckets (S3-like storage), the local cache,
discussions and pull requests, collections and webhooks; run Jobs and
sandboxes on Hugging Face infrastructure; create and configure Spaces; deploy
Inference Endpoints; read papers; query datasets with SQL; and share agent
session traces. Use this skill whenever a task involves the Hugging Face Hub
or the user mentions 'hf', 'huggingface', 'Hugging Face' or 'huggingface-cli'
(deprecated, replaced by `hf`), and for cloud compute or storage needs like
training runs, batch jobs, checkpoints or datasets, even if the user doesn't
explicitly ask for a CLI command. Requires a terminal.
hf is the command line interface of the Hugging Face Hub. It replaces the deprecated huggingface-cli.
Not installed? Run curl -LsSf https://hf.co/cli/install.sh | bash -s (alternatives: pip install -U huggingface_hub, brew install hf, or uvx hf ... without installing).
Generated with huggingface_hub v2.6.0.dev0. Run hf skills update hf-cli -g to regenerate.
Commands
Only command names are listed here. Run hf <command> --help before using a command for the first time: it prints its arguments, flags and examples. Do not guess flags.
hf auth— Manage authentication (login, logout, etc.):list (ls),login,logout,revoke,switch,token,whoamihf buckets— Commands to interact with buckets:cp,create,delete,info,list (ls),move,remove (rm),settings,synchf cache— Manage local cache directory:list (ls),prune,rm,verifyhf collections— Interact with collections on the Hub:add-item,create,delete,delete-item,info,list (ls),update,update-itemhf cp SRC [DST]— Copy files between local paths, repositories, and buckets.hf datasets— Interact with datasets on the Hub:card,info,leaderboard,list (ls),parquet,sqlhf discussions— Manage discussions and pull requests on the Hub:close,comment,create,diff,edit,info,list (ls),merge,rename,reopenhf download REPO_ID [FILENAMES]...— Download files from the Hub.hf endpoints— Manage Hugging Face Inference Endpoints:catalog {deploy, list (ls)},delete,deploy,describe,hardware,list (ls),pause,resume,scale-to-zero,updatehf env— Print information about the environment.hf extensions (ext)— Manage hf CLI extensions:exec,install,list (ls),remove (rm),search,updatehf jobs— Run and manage Jobs on the Hub:cancel,expose,hardware,inspect,labels,list (ls, ps),logs,rerun,run,scheduled {delete, inspect, labels, list (ls, ps), reschedule, resume, run, suspend, trigger, uv run},ssh,stats,uv run,waithf models— Interact with models on the Hub:card,info,list (ls)hf papers— Interact with papers on the Hub:info,list (ls),read,searchhf repos— Manage repos on the Hub:branch {create, delete},cp,create,delete,delete-files,duplicate,list (ls),move,settings,tag {create, delete, list (ls)}hf resource-groups— Manage resource groups of an organization on the Hub:assign,unassignhf sandbox— Run and manage experimental sandboxes on Hugging Face Jobs:cp,create,exec,kill,pool {create, delete (rm), ls (list)},process {kill, ls (list)},spawnhf skills— Manage skills for AI assistants:add,list (ls),preview,updatehf spaces— Interact with spaces on the Hub:card,dev-mode,hardware,hot-reload,info,list (ls),logs,pause,restart,search,secrets {add, delete, list (ls)},settings,ssh,templates,variables {add, delete, list (ls)},volumes {delete, list (ls), set},wait,zero-gpu quotahf sync [SOURCE] [DEST]— Sync files between local directory and a bucket.hf update— Update thehfCLI to the latest version.hf upload REPO_ID [LOCAL_PATH] [PATH_IN_REPO]— Upload a file or a folder to the Hub.hf version— Print information about the hf version.hf webhooks— Manage webhooks on the Hub:create,delete,disable,enable,info,list (ls),update
Output and scripting
- Output is compact when an AI agent is detected and human-friendly otherwise; force a format with
--format [agent|auto|human|json|quiet]. - Use
--jsonto parse results (e.g. withjq) and-q/--quietto print one ID per line (e.g.hf jobs ls -q | xargs hf jobs wait). - These flags work on every command except
hf extensions exec,hf sandbox execandhf sandbox spawn; most commands also accept--no-truncatefor full values in human tables. - Lines starting with
Hint:go to stderr, so stdout stays parseable; read them, they often give the next command to run.
Authentication
- Check the current login with
hf auth whoami; if logged out, ask the user to runhf auth loginor to set theHF_TOKENenvironment variable. - Prefer
HF_TOKENorhf auth loginover--token: the flag ends up in the shell history and not every command accepts it (e.g.hf auth whoami). - Never print a token; forward it to a Job, a sandbox or a Space with
--secrets HF_TOKEN, which reads the value from the local environment.
Repos, files and paths
- Repo IDs are
namespace/nameand are models by default: prefix them (datasets/namespace/name,spaces/namespace/name) or pass--typefor other repo types. - Remote files are addressed as
hf://[datasets/|spaces/|buckets/]namespace/name[@revision]/path(no prefix means a model repo; buckets have no revision). hf models ls REPO_ID,hf datasets ls REPO_ID,hf spaces ls REPO_IDandhf buckets ls BUCKET_IDlist remote files, andhf models card REPO_ID(same for datasets and Spaces) prints the README, without downloading anything.hf downloadstores files in the local cache and prints their path: pass filenames or--include/--excludeglobs to fetch only what is needed,--dry-runto check sizes first, and--local-dirto get plain files in a folder.hf upload REPO_ID [LOCAL_PATH] [PATH_IN_REPO]creates the repo if needed and handles large folders: they are split into several commits and re-running the same command resumes an interrupted upload.hf cpcopies single files between local paths, repos and buckets, with-for stdin/stdout (e.g.hf cp hf://datasets/namespace/name/README.md -); for local folders usehf upload/hf download(repos) orhf sync(buckets).- To read a repo or bucket as a local folder without downloading it, mount it with
hf-mount(https://github.com/huggingface/hf-mount).
Choosing the right resource
- Dataset repo vs bucket: use a dataset (or model) repo for data to publish, share or version, as repos are git-based and keep history; use a bucket (
hf buckets,hf sync) for mutable S3-like storage without history, e.g. checkpoints, logs and intermediate artifacts. - Job vs sandbox: use
hf jobsto run one command to completion (training, batch inference, evals, scheduled tasks); usehf sandbox(experimental) for a machine to iterate on with repeatedexecandcpcalls, andhf sandbox killit when done. - Space SDK: use
--sdk staticfor a website made of plain HTML/CSS/JS files,--sdk gradiofor a Python demo, and--sdk dockeronly when the app needs its own server or system dependencies. - Create a Space explicitly with
hf repos create NAME --type space --sdk ...before uploading to it:hf uploadon a missing Space creates a Gradio one. - After pushing to a Space, run
hf spaces wait SPACE_ID(non-zero exit code if the Space is not running) and readhf spaces logs SPACE_ID(--buildfor build logs) if it failed.
Jobs
hf jobs uv run script.pyruns a Python script and installs its dependencies (inline script metadata or--with) without building an image;hf jobs run IMAGE COMMAND...runs any Docker image.- Hardware defaults to
cpu-basic: list flavors and prices withhf jobs hardwareand pick one with--flavor. - Jobs stop after 30 minutes by default: set
--timeout(e.g.--timeout 2h) for longer runs. - A Job streams its logs until it ends; pass
-d/--detachto get the Job ID right away, then usehf jobs logs -f JOB_ID,hf jobs inspect JOB_IDorhf jobs wait JOB_ID(non-zero exit code if the Job failed). - When launching related Jobs, give each one a descriptive
--nameand a shared--label(e.g.--label project=my-experiment), and reuse that label in later calls so they can be found withhf jobs ls -a --label project=my-experiment. hf jobs lsonly shows running Jobs; add-ato include finished and failed ones.- Mount inputs and outputs with
-v: repos are read-only (-v hf://datasets/namespace/name:/data) and buckets are read-write (-v hf://buckets/namespace/name:/output), which makes buckets the place to persist results.
Sharing agent traces
- The Hub renders raw JSONL session traces in a trace viewer, no conversion needed: Claude Code stores them in
~/.claude/projects/<project>/<session-id>.jsonl, Codex in~/.codex/sessions/YYYY/MM/DD/*.jsonl, Pi in~/.pi/agent/sessionsand Factory Droid in~/.factory/sessions. - To share the current session, pick the most recently modified
.jsonlof your harness and upload that single file:hf upload namespace/name path/to/session.jsonl --type dataset --private(orhf cpit into a bucket). - Traces contain prompts, command output, local paths and possibly secrets: keep the dataset or bucket private unless the user explicitly asks to publish it, and offer to review or redact it first.
- To keep sharing new sessions, sync the whole folder to a bucket, e.g.
hf sync ~/.codex/sessions hf://buckets/namespace/name/codex. - Other harnesses can write the Session Traces Format to render in the same viewer: https://huggingface.co/docs/hub/session-traces-format.
Search
- Search with
hf models lsandhf datasets ls(--search,--filter,--author,--sort,--limit),hf spaces search QUERY(semantic search) andhf papers search QUERY. hf datasets sql "SELECT ..."queries the parquet files of a dataset with DuckDB, without downloading it.
Staying up to date
hf updateupdates the CLI andhf skills update hf-cli -gregenerates this skill for the installed version (drop-gfor a project-level install);hf --skillsprints it.- If Hugging Face MCP tools are also available in the session, they can be used as well.
Xet Storage Details
- Size:
- 10.7 kB
- Xet hash:
- 6cc2d938089066352dd3e8039532a01dad08fbfd3639d8d6a52fc063a8a4768a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.