Ai Agents 5 min read

How to Expose the Hugging Face Hub to Coding Agents via hf CLI

Learn how to use the newly redesigned hf CLI to provide coding agents like Claude Code and Cursor with direct access to Hugging Face models and datasets.

Hugging Face’s June 2026 update to the hf CLI redesigns the tool specifically as an executable interface for AI agents. Rather than requiring human developers to manually search for models, configure fine-tuning jobs, or deploy compute instances, the new CLI exposes the entire Hugging Face Hub directly to agentic workflows. By generating standardized tool definitions, it allows agents like Claude Code, Cursor, and OpenAI Codex to autonomously discover over two million models, manage storage buckets, and execute infrastructure commands.

This guide covers how to install the agent-optimized version of the CLI, generate skill definitions for your environments, and configure tracing to monitor agent activity.

Installation and Setup

While previous versions of the huggingface_hub package relied on Python’s pip, the agent-optimized CLI requires a standalone installer. This deployment method prevents Python PATH conflicts and ensures that the agent sub-processes always resolve to the correct binary.

Use the following command for macOS and Linux environments:

bash curl -LsSf https://hf.co/cli/install.sh | bash

For Windows users, use PowerShell:

powershell powershell -ExecutionPolicy ByPass -c “irm https://hf.co/cli/install.ps1 | iex”

Once installed, you must authenticate the CLI. If your agent runs in a headless environment, provide the token via environment variable (HF_TOKEN) rather than using the interactive hf login command.

The HF Skills System

The core of the redesign is the HF Skills System. Hugging Face now packages standardized task definitions using the SKILL.md format. These files provide the agent with necessary context, execution instructions, parameter constraints, and the exact command syntax needed to perform complex machine learning tasks.

Instead of writing custom system prompts to explain how Hugging Face works, you can generate a skill definition directly from your local installation. The command hf skills add reads the current system capabilities and outputs the definitions into your environment’s expected directory.

When working with agent skills, ensuring the agent understands the exact version and flag availability is critical. The local generation ensures parity between what the agent thinks it can do and what the system will actually execute.

Integrating with Coding Agents

The CLI handles integration differently depending on the coding agent you are targeting.

Claude Code Integration

Anthropic’s Claude Code supports a native plugin marketplace. You can register the Hugging Face CLI as a recognized tool using a specific flag.

bash hf skills add —claude

This command automatically updates Claude Code’s configuration, exposing the full suite of Hugging Face operations. If you are building automated Claude Code routines, the agent will now automatically suggest hf commands when asked to search for weights, sync datasets, or provision compute.

Cursor, Codex, and General Agents

For most other agent frameworks, the CLI relies on standard directory conventions. Frameworks typically look for tool configurations in hidden directories at the project root or the user’s home folder.

Running hf skills add without agent-specific flags will prompt the CLI to deposit the SKILL.md files in standard paths like .agents/skills or ~/.agents/skills. Once the files are populated, any agent configured to read from these directories will index the Hugging Face capabilities on its next run.

Core Agentic Capabilities

Once the skills are loaded, the agent can execute four primary categories of operations autonomously.

CapabilityCLI Command ExampleDescription
Search and Inspecthf search models "Qwen 3 quantizations"Queries the Hub for models or datasets and returns formatted metadata suitable for LLM parsing.
Storage Managementhf buckets sync ./data my-org/dataset-bucketInteracts with Storage Buckets, Hugging Face’s mutable, non-versioned object storage system. Agents can list (hf buckets list) and sync files.
Infrastructure Managementhf jobs submit --space my-spaceProvisions compute and schedules tasks via the hf jobs command, allowing agents to launch Hugging Face Spaces dynamically.

A primary limitation of this automation is rate limiting. When agents recursively search for models or attempt rapid bucket sync operations, they can hit Hugging Face API limits. Configure your agents to use exponential backoff when executing hf commands.

Agent Traces and Observability

Allowing agents to provision infrastructure and download model weights requires strict monitoring. To help developers monitor AI applications, Hugging Face added native support for Agent Traces.

The CLI can intercept session logs generated by local agents (typically stored as .jsonl files in directories like ~/.claude/projects) and upload them to the Hub. Once uploaded, Hugging Face provides a dedicated trace viewer to inspect the specific commands the agent executed, the parameters it chose, and the API responses it received.

To enable local trace syncing, configure the agent to write standardized logs, then use the CLI to push them to your organization’s designated trace repository.

Ensure that you review the permissions attached to the HF_TOKEN used by the agent. Limit the token’s scope to precisely the operations the agent requires, such as read-only access for search tasks or scoped write access for specific Storage Buckets, to prevent unintended infrastructure modifications.

Get Insanely Good at AI

Get Insanely Good at AI

The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.

Keep Reading