File contents HuggingFace CLI
Execute Hugging Face Hub operations using the hf CLI for downloading models/datasets, uploading files, managing repositories, cache, and cloud compute.
Prerequisites
HuggingFace CLI installed: pip install huggingface_hub
HF account and token for authenticated operations
hf auth login completed
Instructions
Authentication
hf auth login # Interactive login
hf auth login --token $HF_TOKEN # Non-interactive
hf auth whoami # Check current user
Download models and datasets
hf download <repo_id> # Full repo to cache
hf download <repo_id> --local-dir ./models # To local directory
hf download <repo_id> --include "*.safetensors" # Filter by pattern
hf download <repo_id> --repo-type dataset # Dataset
Upload files
hf upload <repo_id> . . # Current dir to root
hf upload <repo_id> ./models /weights # Folder to path
hf upload <repo_id> . . --repo-type dataset # Dataset
hf upload <repo_id> . . --create-pr # Create PR
Repository management
hf repo create <name> # Create model repo
hf repo create <name> --repo-type dataset # Create dataset
hf repo create <name> --private # Private repo
hf repo delete <repo_id> # Delete repo
hf repo tag create <repo_id> v1.0 # Create tag
Cache management
hf cache ls # List cached repos
hf cache rm model/gpt2 # Remove cached repo
hf cache prune # Remove detached revisions
Browse Hub
hf models ls # List trending models
hf models ls --search "llama" --limit 20 # Search models
hf datasets ls # List datasets
hf spaces ls # List spaces
Cloud compute (Jobs)
hf jobs run python:3.12 python script.py # Run on CPU
hf jobs run --flavor a10g-small <image> <cmd> # Run on GPU
hf jobs ps # List jobs
hf jobs logs <job_id> # View logs
Error Handling
If authentication fails, run hf auth login again
For permission errors, check token scope
For large uploads, use hf upload-large-folder
Notes
Key options: --repo-type (model/dataset/space), --revision, --quiet
GPU flavors: cpu-basic, t4-small, a10g-small, a100-large, h100
Use --quiet for scripts to get only paths/URLs
Source: huggingface/skills
1 --- 2 name: huggingface-cli 3 description: HuggingFace CLI 4 --- 5 # HuggingFace CLI 6 7 Execute Hugging Face Hub operations using the `hf` CLI for downloading models/datasets, uploading files, managing repositories, cache, and cloud compute. 8 9 ## Prerequisites 10 11 - HuggingFace CLI installed: `pip install huggingface_hub` 12 - HF account and token for authenticated operations 13 - `hf auth login` completed 14 15 ## Instructions 16 17 1. **Authentication** 18 ```bash 19 hf auth login # Interactive login 20 hf auth login --token $HF_TOKEN # Non-interactive 21 hf auth whoami # Check current user 22 ``` 23 24 2. **Download models and datasets** 25 ```bash 26 hf download <repo_id> # Full repo to cache 27 hf download <repo_id> --local-dir ./models # To local directory 28 hf download <repo_id> --include "*.safetensors" # Filter by pattern 29 hf download <repo_id> --repo-type dataset # Dataset 30 ``` 31 32 3. **Upload files** 33 ```bash 34 hf upload <repo_id> . . # Current dir to root 35 hf upload <repo_id> ./models /weights # Folder to path 36 hf upload <repo_id> . . --repo-type dataset # Dataset 37 hf upload <repo_id> . . --create-pr # Create PR 38 ``` 39 40 4. **Repository management** 41 ```bash 42 hf repo create <name> # Create model repo 43 hf repo create <name> --repo-type dataset # Create dataset 44 hf repo create <name> --private # Private repo 45 hf repo delete <repo_id> # Delete repo 46 hf repo tag create <repo_id> v1.0 # Create tag 47 ``` 48 49 5. **Cache management** 50 ```bash 51 hf cache ls # List cached repos 52 hf cache rm model/gpt2 # Remove cached repo 53 hf cache prune # Remove detached revisions 54 ``` 55 56 6. **Browse Hub** 57 ```bash 58 hf models ls # List trending models 59 hf models ls --search "llama" --limit 20 # Search models 60 hf datasets ls # List datasets 61 hf spaces ls # List spaces 62 ``` 63 64 7. **Cloud compute (Jobs)** 65 ```bash 66 hf jobs run python:3.12 python script.py # Run on CPU 67 hf jobs run --flavor a10g-small <image> <cmd> # Run on GPU 68 hf jobs ps # List jobs 69 hf jobs logs <job_id> # View logs 70 ``` 71 72 ## Error Handling 73 74 - If authentication fails, run `hf auth login` again 75 - For permission errors, check token scope 76 - For large uploads, use `hf upload-large-folder` 77 78 ## Notes 79 80 - Key options: `--repo-type` (model/dataset/space), `--revision`, `--quiet` 81 - GPU flavors: cpu-basic, t4-small, a10g-small, a100-large, h100 82 - Use `--quiet` for scripts to get only paths/URLs 83 84 Source: huggingface/skills
mediar-ai/skillhubz/tree/main/packages/skills/skills/huggingface-cli commit 9bd2e93f3a
Frequently asked questions How do I install the Huggingface CLI skill? Run npx skillmds@latest add mediar-ai/huggingface-cli in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Huggingface CLI skill do? HuggingFace CLI It is listed under AI & ML on SkillMD.
Is Huggingface CLI safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Huggingface CLI? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Huggingface CLI free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Huggingface CLI? mediar-ai (@mediar-ai) published this skill. Their other Agent Skills are listed on their SkillMD profile.