huggingface_hub AGENTS.md

A development guide for huggingface_hub, a Python client library for storing and retrieving machine-learning files from the Hugging Face Hub.

In plain words
What is it for?
Use it when developing the client library, updating generated files, checking code quality, or running selected or complete test suites.
Why use it?
It explains setup, important source areas, and the commands for formatting, linting, type-checking, and running tests.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/huggingface/huggingface_hub/agents-md
Clone the repo
git clone --depth 1 https://github.com/huggingface/huggingface_hub

Made for: Codex, OpenCode.

Per session 2,565 This file is loaded in full into every session.
When invoked 2,565 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02565 $0.02565
Opus 5 $0.01282 $0.01282
Sonnet 5 $0.00513 $0.00513
Haiku 4.5 $0.00257 $0.00257

Measured yesterday against content hash 01f752a05361, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

huggingface_hub AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 144 lines

How it starts

The opening of the file, as written. The whole thing — 144 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Guide for huggingface_hub

Project overview

Python client library for the Hugging Face Hub. Source code is in src/huggingface_hub/, tests in tests/.

Setup

  • Virtualenv: .venv (everything pre-installed in editable mode with dev extras).
  • Activate: source .venv/bin/activate (or prefix commands with .venv/bin/python).

Key commands

Command What it does
make style Auto-format code (ruff format + fix), update generated files (static imports, __all__, async client, CLI reference)
make quality Check formatting, linting, generated files, and type-check (ty check src)
pytest tests/test_<module>.py Run a specific test file
pytest tests/test_<module>.py -k "test_name" Run a single test
pytest tests/ Run all tests (slow, many require network/auth)

Always run make style then make quality before committing.

Code structure

Core modules (src/huggingface_hub/)

  • __init__.py — Public API surface. Static imports are auto-generated by utils/check_static_imports.py; run make style to update.
  • hf_api.py — Main HfApi class (~11k lines). Repo CRUD, uploads, downloads, discussions, PRs, collections, and more. Most Hub operations live here.
  • file_download.pyhf_hub_download, caching logic, ETag/metadata resolution, xet download support.
  • _snapshot_download.pysnapshot_download (download an entire repo).
  • _commit_api.py — Low-level commit operations (CommitOperationAdd, CommitOperationDelete, CommitOperationCopy), LFS upload handling.
  • _commit_scheduler.py — Background scheduled commits.
  • _upload_large_folder.py — Chunked upload for very large folders (deprecated; upload_folder now handles large/resumable uploads).
  • hf_file_system.pyHfFileSystem (fsspec-based POSIX-like filesystem for Hub repos).
  • hub_mixin.pyModelHubMixin base class for ML framework integration (save/load to Hub).
  • repocard.py / repocard_data.pyRepoCard, ModelCard, DatasetCard and their metadata.
  • community.pyDiscussion, DiscussionComment and event deserialization.
  • lfs.py — Git LFS batch upload utilities.
  • _login.pylogin(), logout(), notebook_login(), token management.
  • _inference_endpoints.py — Inference endpoint CRUD and scaling.
  • _jobs_api.py — Training jobs API.
  • _space_api.py — Space runtime/hardware/storage types.
  • _webhooks_server.py / _webhooks_payload.py — Webhook server and payload definitions.
  • constants.py — All environment-variable-driven constants (timeouts, cache paths, endpoints).
  • errors.py — Custom exception hierarchy (HfHubHTTPError, RepositoryNotFoundError, etc.).

Read the full file on GitHub · 144 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 144 lines · 2,565 tokens per session scan A 01f752a05361

Subscribe to this mod's changes

huggingface_hub AGENTS.md is an instructions file published in the GitHub repository huggingface/huggingface_hub (3,857 stars, last pushed 3d ago), licensed Apache-2.0. It adds 2,565 tokens to every session, about $0.0128 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories

transformers copilot-instructions.md

Instructions for huggingface/transformers, covering copilot-instructions.md guide for hugging face transformers, core project structure, coding conventions for hugging face transformers, copying and inheritance and testing.

huggingface/transformers · 773 tokens

transformers AGENTS.md

Instructions for huggingface/transformers, a project described as: 🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

huggingface/transformers · 5 tokens

PINA AGENTS.md

Instructions for PINA-org/PINA, covering pina — physics-informed neural architectures, quick reference, workflow: problem → model → solver → trainer, problem types and condition types.

PINA-org/PINA · 829 tokens

presidio-research AGENTS.md

AGENTS.md instructions for data-privacy-stack/presidio-research, covering agents.md — codebase patterns, project setup, canonicalmapper, five issue types (issuetype enum) and resolution dataclass fields.

data-privacy-stack/presidio-research · 759 tokens

transformers CLAUDE.md

Instructions for huggingface/transformers, a project described as: 🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

huggingface/transformers · 5 tokens

Traintools AGENTS.md

AGENTS.md instructions for AparajeetS/Traintools, covering traintools agent guide, discovery, when to suggest traintools, routing and integration rules.

AparajeetS/Traintools · 698 tokens