Hugging Face CLI をエージェント最適化された Hub 操作手段として設計する
Hugging Face は、コーディングエージェント(Claude Code, Cursor など)による利用増加に対応するため、CLI ツール「hf」を再設計し、複雑なマルチステップタスクにおけるトークン使用量を最大 6 倍削減する成果を達成した。
キーポイント
エージェント最適化への転換
従来の人間向け CLI から、Claude Code や Cursor などの AI コーディングエージェントが効率的に利用できるように再設計された。
トークン効率の劇的向上
ベンチマークにより、複雑なマルチステップタスクにおいて、従来の手動スクリプトや SDK 直接使用と比較して最大 6 倍のトークン削減を実現したことが確認された。
機能の包括的維持
モデル・データのアップロード/ダウンロード、リポジトリ管理、Jobs の実行、Inference Endpoints の設定など、Python SDK で可能な全機能を CLI から利用可能にしている。
人間とエージェントの出力要件の違い
人間には色付きや改行された見やすい形式を、エージェントにはトークン数を節約するための構造化され完全な非装飾データを提供する。
自動検出による最適化
環境変数を通じてエージェント利用を検知し、フラグ指定なしで同じコマンドを人間用またはエージェント用に自動的に出力形式を切り替える。
Agent 最適化された TSV 出力形式
人間向けに色付きのテーブルを生成する一方、エージェントには完全な ID、ISO タイムスタンプ、すべてのタグを含む、解析しやすい TSV 形式で情報を提供し、トリミングや ANSI コードを排除します。
次のコマンドへの自動ヒント機能
コマンド実行後に直ちに実行可能な次のステップ(例:ジョブ ID を指定したログ取得)を提示する「Hint」機能を追加し、人間とエージェントの両方が手動でコマンドを組み立てる手間を省きます。
重要な引用
The hf CLI has been primarily built for our users over the years. But it's now increasingly used by coding agents: Claude Code, Codex, Cursor and more.
We found that on complex, multi-step tasks the no-CLI baseline (an agent hand-rolling curl or the Python SDK) uses up to 6× as many tokens as the hf CLI.
An agent wants the inverse: no ANSI, nothing truncated, every value in full since an agent can handle far denser output than a human, kept compact and structured to stay light on tokens.
When `hf` auto-detects agent use (via the environment variables mentioned above), it renders the **same command** differently.
An agent gets the complete record as TSV: full repo ids, full ISO timestamps, every tag, no ANSI codes, nothing truncated, clean to parse and light on tokens.
For an agent it's a rail: the next action is named, parameterized with the right ids, and ready to run, so it takes fewer steps working out what to do.
影響分析・編集コメントを表示
影響分析
このイニシアチブは、AI エージェントが自律的にリソース管理やモデル運用を行う際のボトルネックであるトークンコストと複雑さを解決し、エージェントによる開発ワークフローの普及を加速させる。特に、大規模なマルチステップタスクを実行する際のコスト効率性が向上することで、企業レベルでの自動化導入障壁が下がる可能性がある。
編集コメント
AI エージェントが単なるコード生成だけでなく、インフラやリソース管理まで自律的に行う時代において、ツール側の最適化(トークン効率化)は極めて重要な戦略です。
hf は、Hugging Face Hub への公式コマンドラインエントリーポイントです。Python SDK を介して Hub でできることは何でも、ターミナルから実行できます:モデル、データセット、Spaces のダウンロードとアップロード;リポジトリ、ブランチ、タグ、プルリクエストの作成と管理;HF インフラ上での Jobs の実行;Buckets、Collections、Webhooks、Inference Endpoints の管理。
この hf CLI は長年にわたり主にユーザー向けに構築されてきました。しかし現在では、コーディングエージェント(Claude Code、Codex、Cursor など)によっても頻繁に利用されるようになっています。そこで私たちは、両方のユーザー層に対応できるよう CLI を再構築しました。本ブログ記事では、その取り組みとベンチマークの結果についてまとめます。複雑で多段階のタスクにおいて、CLI なしベースライン(エージェントが手動で curl や Python SDK を組み立てる場合)は、hf CLI と比較して最大6 倍ものトークン数を消費することが判明しました。
Hub における AI エージェントのトラフィック
私たちは2026年4月から、ハブにおけるエージェントの利用状況を追跡し始めています。hf CLI(およびその基盤となる huggingface_hub Python SDK)は、CLAUDECODE/CLAUDE_CODE(Claude Code用)、CODEX_SANDBOX(Codex用)、さらに Cursor、Gemini、Pi、そして汎用的な AI_AGENT といった環境変数を参照することで、コーディングエージェントが操作していることを検出します。この単一のシグナルには2つの役割があります:1つは CLI の出力を形成すること(詳細は後述)で、もう1つは各ハブリクエストに agent/<name> というユーザーエージェントタグを付与し、どのエージェントがトラフィックを駆動しているかを特定できるようにすることです。別々のユーザー数で最も多いのはClaude Code と Codexであり、他を大きく引き離しています。これら2つのエージェントこそが、本記事の後半でベンチマークする対象となります。

image
棒グラフは各エージェントあたりの別々のユーザー数を示しており、リクエスト数はその下のサブラベルで表されています。Claude Code 単独でも約4万人のユーザーとほぼ4900万件のリクエストを記録しており、Codex もこれに続いています。これらの数字はまだ初期段階のもので(エージェントトラフィックの特定は2026年4月から開始したため)、規模としてはすでに注目すべきものですが、コーディングエージェントがハブを利用する標準的な方法として定着するにつれて、さらに成長していくと予想しています。
人間とエージェントのために設計された
人間とコーディングエージェントは、同じ hf コマンドに対して異なる出力を期待します。人間はリッチなターミナル出力を望みます:ANSI カラー、画面に収まるようにトリミングされたパッド付きテーブル、成功時の緑色の✅、ブール値の✔、プログレスバー、文章によるヒントです。一方、エージェントはその逆を求めます:ANSI なし、一切のトリミングなし、すべての値を完全に表示(エージェントは人間よりもはるかに密度の高い出力を処理できるため)、トークン数を抑えるためにコンパクトかつ構造化された形式で保持します。また、エージェントは CLI プロンプトに応答できず、タイムアウト後にコマンドを喜んで再実行します。このセクションの残りは、hf がそれぞれの側に必要なものをどのように提供するかを説明するものです。agent-mode 出力は hf v1.9.0 で導入され、以降のリリースで残りの CLI を徐々に移行しています。
1 つのコマンド、複数のレンダリング
hf は上記の環境変数を通じてエージェントの使用を自動検出すると、同じコマンドを異なる形式でレンダリングします。フラグを指定せずに、人間またはエージェント向けに出力フォーマットを最適化します:
human (ターミナルでのデフォルト): 表示範囲に合わせて切り詰められたアライメント済みテーブル、ヒント付き
hf models ls --author Qwen --sort downloads --limit 3
ID CREATED_AT DOWNLOADS LIBRARY_NAME LIKES PIPELINE_TAG PRIVATE TAGS
------------------------ ---------- --------- ------------ ----- --------------- ------- -------------------------
Qwen/Qwen3-0.6B 2025-04-27 21156913 transformers 1285 text-generation transformers, safetens...
Qwen/Qwen2.5-1.5B-Ins... 2024-09-17 15143953 transformers 725 text-generation transformers, safetens...
Qwen/Qwen3-4B 2025-04-27 14808352 transformers 625 text-generation transformers, safetens...
ヒント: --no-truncate または --format json を使用して、完全な値を表示してください。
エージェント(自動検出):TSV、完全な ID と ISO タイムスタンプ、すべてのタグを出力。切り捨てなし
$ hf models ls --author Qwen --sort downloads --limit 3
id created_at downloads library_name likes pipeline_tag private tags
Qwen/Qwen3-0.6B 2025-04-27T03:40:08+00:00 21156913 transformers 1285 text-generation False ['transformers', 'safetensors', 'qwen3', 'text-generation', 'conversational', 'arxiv:2505.09388', 'base_model:Qwen/Qwen3-0.6B-Base', 'base_model:finetune:Qwen/Qwen3-0.6B-Base', 'license:apache-2.0', 'text-generation-inference', 'endpoints_compatible', 'deploy:azure', 'region:us']
Qwen/Qwen2.5-1.5B-Instruct 2024-09-17T14:10:29+00:00 15143953 transformers 725 text-generation False['transformers', 'safetensors', 'qwen2', 'text-generation', 'chat', 'conversational', 'en', 'arxiv:2407.10671', 'base_model:Qwen/Qwen2.5-1.5B', 'base_model:finetune:Qwen/Qwen2.5-1.5B', 'license:apache-2.0', 'text-generation-inference', 'endpoints_compatible', 'deploy:azure', 'region:us']
Qwen/Qwen3-4B 2025-04-27T03:41:29+00:00 14808352 transformers 625 text-generation False ['transformers', 'safetensors', 'text-generation', 'arxiv:2309.00071', 'arxiv:2505.09388', 'base_model:Qwen/Qwen3-4B-Base', 'base_model:finetune:Qwen/Qwen3-4B-Base', 'license:apache-2.0', 'endpoints_compatible', 'deploy:azure', 'region:us']
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "翻訳全文"}
人間向けには、ターミナルに収まるように切り詰められた整列されたテーブルと、さらに詳細を見るためのヒントが表示され、ステータスに応じた色付け(成功時は緑の✓、エラー時は赤)が行われます。エージェント向けには、完全なレコードが TSV 形式で提供されます:フルリポジトリ ID、完全な ISO タイムスタンプ、すべてのタグ、ANSI コードなし、切り詰めなし、解析しやすくトークン消費も少ない形式です。
実際の実装では、生データを引数として受け取り書式処理を行う .table(...)、.result(...)、.json() などのロギングメソッドを実装しています。人間モードとエージェントモードに加え、コマンドをパイプ接続しやすくするための --json および --quiet オプションも導入しました。デフォルトモードは文脈に基づいて自動的に選択されますが、ユーザーは --format human | agent | json | quiet を使用していつでも好みの書式を強制指定できます。
次のコマンドのヒント
CLI コマンドは単独で実行されることは稀です:あるステップは通常次のステップを意味します(git add の後、git commit など)。多くの hf コマンドにはヒントが付加されており、直近で使用した ID が事前に入力された状態で、ユーザーやエージェントが最初から考え直すことなく次のステップへ直接チェーンできます。バックグラウンドでジョブを開始すればログへの案内が表示され、Space を作成すれば起動ステータスへの案内が表示されます:
$ hf jobs run --detach python:3.12 python train.py
✓ Job started
id: 6f3a1c2e9b
url: https://huggingface.co/jobs/celinah/6f3a1c2e9b
Hint: Use hf jobs logs 6f3a1c2e9b to fetch the logs.
人間にとっては利便性ですが、エージェントにとってはレールです。次のアクションは名前が付けられ、適切な ID でパラメータ化され、実行の準備ができているため、何をすべきかを考えるステップ数が少なくて済みます。エラーも同様に振る舞い、単に失敗するのではなく修正方法を命名します:
Error: Not logged in. Run hf auth login first.
ヒント、警告、エラーはすべて stderr に出力され、データは stdout に流れるため、エージェントが解析する出力をこれらのガイダンスが汚染することはありません。
ブロッキングせず、再試行も安全
hf はインタラクティブなプロンプトでキー入力を待って止まることはありません。破壊的なコマンドでも人間には確認を求めますが、エージェントモードではメッセージに修正方法を含めて *速やかに失敗* します(確認をスキップするには --yes を使用)。また -y/--yes オプションで確認をスキップできます。さらに、エージェントはタイムアウトやコンテキストの喪失時に再試行を行うため、操作は繰り返し実行しても安全になるように設計されています:hf repos create --exist-ok はリポジトリが既に存在する場合は何もしない(no-op)コマンドであり、アップロードを再実行してもきれいに再コミットされます。別に、実際のデータを移動させるコマンドには --dry-run オプションがあり、実行前に転送される内容を正確に示します。これは人間にもエージェントにも便利で、どちらも長いダウンロードや盲信の同期にコミットする必要がありません:
エージェントモード: --yes がない破壊的コマンドは拒否し、メッセージ内に修正方法を記載する
$ hf repos delete my-org/old-model
Error: You are about to permanently delete model 'my-org/old-model'. Proceed? Use --yes to skip confirmation.
データを移動するコマンドは、転送を事前にプレビューするために --dry-run を使用します
$ hf download deepseek-ai/DeepSeek-V4-Pro config.json --dry-run
[dry-run] 1 ファイル(計 1 件中)を合計 1.8K でダウンロードします。
file size
config.json 1.8K
発見可能で予測可能なコマンド
hf はプローブ(探索・確認)できるように設計されています:hf を実行してリソースグループを確認し、必要なものに対して --help を実行してください。すべての --help の末尾には、実際のコピー&ペースト可能な例が記載されています(エージェントは説明を解析するよりも、これらの例に一致させる方がはるかに高速です):
$ hf models ls --help
...
Examples
$ hf models ls --sort downloads --limit 10
$ hf models ls --search "qwen" --author Qwen
$ hf models ls Qwen/Qwen3-4B --tree
コマンドツリーは整合性があり、リソース + 動詞という形式で、明白なエイリアス(hf models ls, hf repos create, hf jobs ps, hf collections delete; list/ls, remove/rm)が用意されています。そのため、エージェントが一度でも一つのコマンドを学習すれば、残りのコマンドも推測できます。また、出力は組み合わせ可能です:-q オプションを使用すると 1 行に 1 つの ID が印刷され、次のコマンドのパイプラインに渡すことができます。--json オプションを使用すると、jq に渡せる形式が得られます。
$ hf models ls --author Qwen -q | head -3
Qwen/Qwen3-0.6B
Qwen/Qwen2.5-1.5B-Instruct
Qwen/Qwen3-4B
コーディングエージェント向けの hf CLI のベンチマーク
hf CLI がエージェントにとって本当に効率的かどうかを確認するため、私たちは測定を行いました。小さな評価ハネスを構築し、Hub を駆動する各方法を通じて同じセットの Hub タスクを何度も実行し、ライブな Hub に対して各ランを採点しました。手法の詳細に入る前の結論は以下の通りです:両方のエージェントにおいて hf CLI が優位に立ち、特に複雑で多段階のタスクでははるかに少ないトークン数で使用することで明確な差を見せました。
agent tool success score token usage self-report error
Claude Code (Sonnet 4.6)
hf CLI
0.94
baseline
2 / 163
curl / Python SDK
0.84
1.3-1.6× tokens
11 / 163
Codex (GPT-5.5)
hf CLI
0.93
baseline
3 / 163
curl / Python SDK
0.92
1.6-1.8× tokens
10 / 163
*(self-report error = エージェントが 17 の解決可能なタスクで成功を報告したが、Hub はそれと異なる結果を示した。hf CLI の行はスキルがインストールされた CLI を指します。このスキルが裸の CLI に追加するもの(主にツール呼び出しの削減)の詳細は、以下の スキルセクション で解説されています。代表的なトランスクリプトは こちらのバケット で公開されています。)*
設定
私たちは、18 の非自明な Hub タスクを定義しました。「ファイルをダウンロードする」のような単純なものではなく、実際に要求するようなタスクです。例えば、トレンドのある組織のモデルを集約する、リポジトリ内のファイルとそのサイズを検査する、含める/除外するルール付きでフォルダをアップロードする、ファイルを削除する、リポジトリ間でファイルをコピーする、ライセンスを追加する PR を開く、ブランチとタグを持つリポジトリを作成する、バケットを同期して不要なものを整理する、コレクションを構築するなどです。各タスクは、Hub と対話する方法が1 つだけに限定された新しいコーディングエージェントに割り当てられます。
- hf CLI を使用する、または
curl または Python SDK を使用する(hf CLI は一切使用せず、エージェントは REST API に対して curl を実行するか、huggingface_hub という Python ライブラリを使用します)。
私たちは、スキル(後ほど 独自のセクション で詳述する生成されたコマンド参照)ありとなしの 2 つの設定で hf CLI を実行しました。しかし、以下の主要な比較は単にhf CLI vs curl / SDKです。スキルの増加分の影響は小さ enough なので、メインの結果を混雑させないために別セクションとして扱います。
設定は意図的にクリーンに保たれています:実行ごとに新しいインスタンスを使用し、カスタム MCP サーバーも CLAUDE.md や AGENTS.md も存在せず、行動を誘導するコンテキスト内の要素は何もありません。タスクとツールは単一のプロンプトに組み込まれ、エージェントは TASK_COMPLETE または TASK_FAILED マーカーで完了しますが、このマーカーを信頼してはいけません(エージェントは実際には完了していない作業に対して成功を報告する可能性があるため)、各実行は独立してライブの Hub への再クエリによって評価されます:ブランチが本当に作成されたか、ファイルが実際に削除されたか、バケットが存在するかを確認します。各タスク/ツールの組み合わせは、コーディングエージェントが非決定論的であるため10 回実行され、エージェントあたり約520 回(18 タスク × 3 ツール × 10 反復、ただし請求対象の Jobs タスクには上限があるため減算)と、合計で約 1,000 回の評価済み実行が行われます。この一連の実験は、最も人気のある 2 つのコーディングエージェント(Claude Code with Sonnet 4.6 および OpenAI Codex with GPT-5.5)に対して 2 回実施されました。
結果
以下の 2 つのチャートは上記の表を詳細に解説しています。まず、Sonnet エージェントにおけるタスク成功率です。これは curl と SDK が最も苦戦するエージェントです:

image
CLI を使用しない場合、Sonnet 環境では curl と SDK は 10 ポイントほど遅れをとります。これは、Sonnet ではこれらのツールがジョブの一部(主に書き込み処理)を完了できないためであり、hf CLI はそれをクリアしています。
2 つ目の画像は、タスクごとに分解した GPT-5.5 におけるトークンの影響度を示しています。各棒グラフは、同じタスクにおける curl/SDK のトークン数を CLI のトークン数で割った比率を表しており、例えば 2.4×とは、非 hf バージョンが同じ作業を行うために CLI の 2.4 倍のトークンを消費したことを意味します:

image
1 回の読み取り(データセットの行数カウント、メタデータのバッチ処理)においては、curl と SDK は問題なく、場合によってはより軽量です。しかし、タスクが複雑化し複数の依存ステップを伴うようになると、エージェントは REST コールチェーンを手動で構築するか、SDK を丹念に検索する必要が生じ、コストが急増します:リポジトリの作成(ブランチとタグを含む)、ファイル削除、リポジトリ間でのコピー、バケットの同期などにおいて、CLI の 2.4 倍から 6 倍ものトークン数を要します。hf CLI を用いれば、エージェントは複雑なワークフローを構築するのではなく、タスクを少数の高レベルコマンドとして表現できます。
主な知見
- hf CLI は curl や SDK に比べてはるかに軽量です。同じタスクで同等以上の成功率を達成する場合でも、curl と SDK は約 1.3 倍から 1.8 倍のトークンを消費します。簡単な読み取り処理では問題ありませんが、実際の多ステップ作業においては 2 倍から 6 倍のコストがかかります:CLI は REST コールチェーンを組み合わせて少数の高レベルコマンドに変換する一方、curl や SDK では毎回手動でチェーンを再構築する必要があります。
- より強力なモデル上では、curl や SDK は機能しますが、依然として非効率です。Sonnet 上ではジョブの一部(主に書き込み処理)を完了できません。GPT-5.5 上では、REST コールを手動で実装(または SDK を正しく使用)することで概ね成功しますが、それでも CLI のトークン利用料に比べて遥かに高額なコストを支払うことになります。
The hf-cli skill
hf はスキルを提供しています。これはエージェントがコンテキストとして読み込む、全コマンド表面のコンパクトな参照資料です。自動生成されており、生きている hf コマンドツリーから作成されます。各コマンドは 1 行で表現され(シグネチャ、1 行の説明、重要なフラグ)、リソースごとにグループ化され、一般的なオプションに関する簡易用語集も含まれています。自己説明的なフラグは意図的に省略されており、これにより内容が簡潔に保たれ、コンテキストの負荷を軽減しています。また、これは毎回のリリースで再生成されます。hf skills preview を実行して表示するか、以下のコマンドでインストールしてください。
Codex, Cursor, OpenCode, Pi および .agents/skills からスキルを読み込む他のエージェント向け
hf skills add
上記に加え Claude Code も含む
hf skills add --claude
これにより何を得られるでしょうか?主に、エージェントが推測するのをやめさせることです。最も明確な単一の視点は、各実行で必要なコマンド数です。スキルありとなしを比較すると以下のようになります。

image
両方のエージェントにおいて、タスクあたりのコマンド数は約 10 から約 7 に減少し、ツール呼び出しがおよそ 30% 削減されました。これは、エージェントが適切なコマンドと引数を見つけるために --help をプローブしないためです。スキルはトークン請求額を削減するわけではありません。なぜなら、コンテキストに固定された情報スライスを先頭に付加するため、同じタスクにおけるトークン数は概ね変わらず、わずかに増加する可能性があるからです。また、このスキルが CLI の信頼性を高めるわけでもありませんが、エージェントがツールの仕組みを探る時間を費やすのではなく、あなたのタスクを実行することに時間を割けるようになります。これは、ローカルモデルを hf と併用する場合に特に役立つ可能性があります。
各タスクは新しいセッションで実行されたため、スキルはすべてのタスクでコンテキストコストを支払います。実際のマルチタスクセッションでは、このコストは均等配分されます(エージェントはコマンドの表面を一度学習するだけで済むため)、その場合のトークン状況はおそらく改善されるでしょうが、私たちはそのケースについては測定していません。
実際に試してみましょう
私たちはこれが重要だと考えているため、これらすべてのベンチマークを行いました。エージェントは Hugging Face Hub の実用的なユーザーになりつつあります:モデルのトレーニング、データセットの構築とクリーニング、Spaces としてのデプロイなどを行い、ほとんどが誰かのために実行しています。エージェントにとってよく機能する Hub は、それを利用する人にとってもより良く機能する Hub です。エージェントのツールがどれだけ優れているかは、それがあなたのために行えることの多さに直結します。
もしあなたのエージェントが Hugging Face Hub と対話するのであれば、hf CLI を使用することを推奨します:
macOS / Linux
curl -LsSf https://hf.co/cli/install.sh | bash
Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
そして、そのスキルを渡して、最初のターンからコマンドの全表面を理解させます:
hf skills add # Codex, Cursor, OpenCode, Pi および .agents/skills からスキルを読み込む他のエージェント向け
hf skills add --claude # 上記 + Claude Code
次に、エージェントを Hub に指し示して作業させます。ログイン済みであることを確認(hf auth login)した後、以下のようなプロンプトを渡します:
hf を使用して、私の Hugging Face Hub のモデル、データセット、および Spaces を一覧表示してください。
現在どのように Hub を利用しているかを確認し、私が役立つと感じるいくつかの方法を提案してください。
エージェントは自身でコマンドを計算し、有用な結果を返します。
完全なコマンドリファレンスは hf CLI ガイド に掲載されています。
エージェントハネスの登録
エージェントハネスを構築していますか?登録してください! これにより、hf がそれを検知できるようになり、Hub 側でトラフィックがあなたのハネスに帰属されます。agent-harnesses.ts にエントリを追加する小さな PR を開くだけで済みます。詳細は エージェントハネスの登録 ガイドをご覧ください。
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "翻訳全文"}
原文を表示
hf is the official command-line entrypoint to the Hugging Face Hub. Anything you can do on the Hub from the Python SDK, you can do from your terminal: download and upload models, datasets and Spaces; create and manage repos, branches, tags and pull requests; run Jobs on HF infrastructure; manage Buckets, Collections, webhooks and Inference Endpoints.
The hf CLI has been primarily built for our users over the years. But it's now increasingly used by coding agents: Claude Code, Codex, Cursor and more. So we rebuilt it to make it work for both audiences at once. This blog post summarizes what we did, and how we benchmarked it. We found that on complex, multi-step tasks the no-CLI baseline (an agent hand-rolling curl or the Python SDK) uses up to 6× as many tokens as the hf CLI.
AI agent traffic on the Hub
We started tracking agent usage of the Hub in April 2026. The hf CLI (and the huggingface_hub Python SDK it's built on) detects when a coding agent is driving it by reading the environment variables agents set: CLAUDECODE/CLAUDE_CODE for Claude Code, CODEX_SANDBOX for Codex, plus Cursor, Gemini, Pi, and the universal AI_AGENT. That single signal does two jobs: it shapes the CLI's output (more on that below) and it tags each Hub request with an agent/<name> user-agent, so we can attribute traffic to the agent driving it. The two largest by distinct users are Claude Code and Codex, well ahead of everything else, and they're the two agents we benchmark later in this article.


The bars count distinct users per agent; request volume is the sub-label. Claude Code alone is ~40k users and nearly 49M requests, with Codex close behind. These are early numbers (we only began attributing agent traffic in April 2026), but the scale is already significant, and we expect it to keep growing as coding agents become a standard way to work with the Hub.
Built for humans and agents
Humans and coding agents expect different outputs for the same hf commands. A human wants rich terminal output: ANSI color, padded tables truncated to fit the screen, a green ✅ on success, ✔ for booleans, progress bars, prose hints. An agent wants
the inverse: no ANSI, nothing truncated, every value in full since an agent can handle far denser output than a human, kept compact and structured to stay light on tokens. It also can't answer a CLI prompt and will happily re-run a command after a timeout. The rest of this section is how hf gives each side what it needs. We introduced agent-mode output in hf v1.9.0 and have been migrating the rest of the CLI to it gradually in the following releases.
One command, multiple renderings
When hf auto-detects agent use (via the environment variables mentioned above), it renders the same command differently. It optimizes output format for humans or agents without passing a flag:
# human (default in a terminal): aligned table, truncated to fit, with a hint
> hf models ls --author Qwen --sort downloads --limit 3
ID CREATED_AT DOWNLOADS LIBRARY_NAME LIKES PIPELINE_TAG PRIVATE TAGS
------------------------ ---------- --------- ------------ ----- --------------- ------- -------------------------
Qwen/Qwen3-0.6B 2025-04-27 21156913 transformers 1285 text-generation transformers, safetens...
Qwen/Qwen2.5-1.5B-Ins... 2024-09-17 15143953 transformers 725 text-generation transformers, safetens...
Qwen/Qwen3-4B 2025-04-27 14808352 transformers 625 text-generation transformers, safetens...
Hint: Use `--no-truncate` or `--format json` to display full values.
# agent (auto-detected): TSV, full ids + ISO timestamps + every tag, nothing truncated
$ hf models ls --author Qwen --sort downloads --limit 3
id created_at downloads library_name likes pipeline_tag private tags
Qwen/Qwen3-0.6B 2025-04-27T03:40:08+00:00 21156913 transformers 1285 text-generation False ['transformers', 'safetensors', 'qwen3', 'text-generation', 'conversational', 'arxiv:2505.09388', 'base_model:Qwen/Qwen3-0.6B-Base', 'base_model:finetune:Qwen/Qwen3-0.6B-Base', 'license:apache-2.0', 'text-generation-inference', 'endpoints_compatible', 'deploy:azure', 'region:us']
Qwen/Qwen2.5-1.5B-Instruct 2024-09-17T14:10:29+00:00 15143953 transformers 725 text-generation False['transformers', 'safetensors', 'qwen2', 'text-generation', 'chat', 'conversational', 'en', 'arxiv:2407.10671', 'base_model:Qwen/Qwen2.5-1.5B', 'base_model:finetune:Qwen/Qwen2.5-1.5B', 'license:apache-2.0', 'text-generation-inference', 'endpoints_compatible', 'deploy:azure', 'region:us']
Qwen/Qwen3-4B 2025-04-27T03:41:29+00:00 14808352 transformers 625 text-generation False ['transformers', 'safetensors', 'text-generation', 'arxiv:2309.00071', 'arxiv:2505.09388', 'base_model:Qwen/Qwen3-4B-Base', 'base_model:finetune:Qwen/Qwen3-4B-Base', 'license:apache-2.0', 'endpoints_compatible', 'deploy:azure', 'region:us']
A human gets an aligned table, truncated to fit the terminal, plus a hint on how to see more, with color cues for status (a green ✓ on success, red on error). An agent gets the complete record as TSV: full repo ids, full ISO timestamps, every tag, no ANSI codes, nothing truncated, clean to parse and light on tokens.
In practice, we've implemented logging methods like .table(...), .result(...), .json(), etc., which take raw data as input and handle the formatting. In addition to human and agent modes, we've introduced --json and --quiet options to make it easier to pipe commands together. The default mode is automatically chosen based on context, but users can always force the format of their choice with --format human | agent | json | quiet.
Next-command hints
CLI commands rarely run in isolation: one step usually implies the next (git add, then git commit). Many hf commands now end with a hint: the exact next command to run, pre-filled with the IDs you just used, so a user or agent can chain straight to the next step instead of working it out from scratch. Start a Job in the background and it points you to its logs; create a Space and it points you to its boot status:
$ hf jobs run --detach python:3.12 python train.py
✓ Job started
id: 6f3a1c2e9b
url: https://huggingface.co/jobs/celinah/6f3a1c2e9b
Hint: Use `hf jobs logs 6f3a1c2e9b` to fetch the logs.
For a human that's a convenience. For an agent it's a rail: the next action is named, parameterized with the right ids, and ready to run, so it takes fewer steps working out what to do. Errors behave the same way, naming the fix instead of just failing:
Error: Not logged in. Run `hf auth login` first.
Hints, warnings and errors all go to stderr while data goes to stdout, so none of this guidance pollutes the output the agent is parsing.
Non-blocking and safe to retry
hf never sits on an interactive prompt waiting for a key an agent can't press. A destructive command still asks a human to confirm, but in agent mode it *fails fast* with the fix in the message (Use --yes to skip confirmation.), and -y/--yes skips it. And because agents retry on timeouts and lost context, operations are built to be safe to repeat: hf repos create --exist-ok is a no-op if the repo already exists, and re-running an upload re-commits cleanly. Separately, the commands that move real data take a --dry-run that shows exactly what they'll transfer before they run, which proves handy for humans and agents alike, since neither has to commit to a long download or blind sync:
# agent mode: a destructive command without --yes refuses, with the fix in the message
$ hf repos delete my-org/old-model
Error: You are about to permanently delete model 'my-org/old-model'. Proceed? Use --yes to skip confirmation.
# commands that move data take --dry-run to preview the transfer first
$ hf download deepseek-ai/DeepSeek-V4-Pro config.json --dry-run
[dry-run] Will download 1 files (out of 1) totalling 1.8K.
file size
config.json 1.8K
Discoverable, predictable commands
hf is built to be probed: run hf to see the resource groups, run --help on the one you need, and every --help ends with real, copy-pasteable examples (which an agent matches against far faster than it parses a description):
$ hf models ls --help
...
Examples
$ hf models ls --sort downloads --limit 10
$ hf models ls --search "qwen" --author Qwen
$ hf models ls Qwen/Qwen3-4B --tree
The command tree is consistent, resource + verb with the obvious aliases (hf models ls, hf repos create, hf jobs ps, hf collections delete; list/ls, remove/rm), so once an agent learns one command it can guess the rest. And the output composes: -q prints one id per line to pipe into the next command, --json gives you something to hand to jq.
$ hf models ls --author Qwen -q | head -3
Qwen/Qwen3-0.6B
Qwen/Qwen2.5-1.5B-Instruct
Qwen/Qwen3-4B
Benchmarking the hf CLI for Coding Agents
To find out whether the hf CLI is really more efficient for agents, we measured it. We built a small evaluation harness and ran the same set of Hub tasks through each way of driving the Hub, many times over, grading every run against the live Hub. Here's the headline before the methodology: across both agents the hf CLI comes out ahead, most clearly on complex, multi-step tasks where it uses far fewer tokens.
agent
tool
success score
token usage
self-report error
Claude Code (Sonnet 4.6)
hf CLI
0.94
baseline
2 / 163
curl / Python SDK
0.84
1.3-1.6× tokens
11 / 163
Codex (GPT-5.5)
hf CLI
0.93
baseline
3 / 163
curl / Python SDK
0.92
1.6-1.8× tokens
10 / 163
*(self-report error = the agent reported success on the 17 solvable tasks but the Hub said otherwise. The hf CLI rows are the CLI with its skill installed; what the skill adds on top of the bare CLI (chiefly fewer tool calls) is broken out in the skill section below. Representative transcripts are published in this bucket.)*
The setup
We defined 18 non-trivial Hub tasks. Not "download a file", but the kind of thing you'd actually ask for: aggregate a trending org's models, inspect a repo's files and their sizes, upload a folder with include/exclude rules, delete files, copy files across repos, open a PR that adds a license, create a repo with a branch and a tag, sync and prune a bucket, build a collection. Each task goes to a fresh coding agent with exactly one way to talk to the Hub:
- the hf CLI, or
- curl / the Python SDK: no hf CLI at all, so the agent falls back to curl against the REST API or the huggingface_hub Python library.
We run the hf CLI in two configurations, with and without its skill (a generated command reference we come back to in its own section). But the headline comparison below is simply hf CLI vs curl / the SDK; the skill's incremental effect is small enough that we break it out on its own rather than crowd it into the main results.
The config is deliberately clean: a fresh instance per run, no custom MCP servers, no CLAUDE.md or AGENTS.md, nothing in context to nudge behavior. The task and the tool go into a single prompt, and the agent finishes with a TASK_COMPLETE or TASK_FAILED marker, but we don't trust that marker (an agent will report success on work that never landed), so we grade every run independently by re-querying the live Hub: did the branch really get created, is the file actually gone, does the bucket exist? Each task/tool combination is run 10 times, since coding agents are non-deterministic, about 520 runs per agent (18 tasks × 3 tools × 10 reps, minus a cap on one billable Jobs task) and ~1,000 graded runs in total. We ran the whole thing twice, on the two most popular coding agents (Claude Code with Sonnet 4.6 and OpenAI Codex with GPT-5.5).
The results
The two charts below unpack the table above. First, task success on Sonnet, the agent where curl and the SDK struggle most:


Without the CLI, curl and the SDK trail by ten points, because on Sonnet they simply can't finish parts of the job (the writes, mostly), while the hf CLI clears them.
The second image shows token impact on GPT-5.5, broken down per task. Each bar is the curl/SDK tokens divided by the CLI's on the same task, so 2.4× means the non-hf version burned 2.4 times as many tokens to do the same thing:


On a one-shot read (count dataset rows, batch metadata) curl and the SDK are fine, and sometimes lighter. But as tasks get more complex and involve several dependent steps, the agent has to hand-roll the entire chain of REST calls (or dig through the SDK) and the cost blows up: 2.4× to 6× the CLI's on creating a repo with a branch and tag, deleting files, copying across repos, or syncing a bucket. The hf CLI lets the agent express the task as a few higher-level commands, rather than crafting a complex workflow.
Key findings
- The hf CLI is far leaner than curl or the SDK. For the same task, at equal-or-better success, curl and the SDK burn roughly 1.3× to 1.8× the tokens. On easy reads they're fine, but on real multi-step work they pay 2× to 6×: the CLI composes a chain of REST calls into a few high-level commands, while curl or the SDK re-derives the chain by hand every run.
- On a stronger model, curl and the SDK work but stay wasteful. On Sonnet they can't finish parts of the job (the writes, mostly); on GPT-5.5 they mostly succeed, hand-rolling the REST calls (or using the SDK) correctly, but still pay well over the CLI's token bill.
The hf-cli skill
hf ships a skill: a compact reference of the whole command surface that an agent loads as context. It's auto-generated from the live hf command tree, one line per command (its signature, a one-line description, and the flags that matter), grouped by resource, with a short glossary of common options. It deliberately skips the self-explanatory flags so it stays terse and light on context, and it's regenerated every release. Run hf skills preview to print it, or install it with:
# for Codex, Cursor, OpenCode, Pi and other agents that load skills from `.agents/skills`
hf skills add
# includes the above + Claude Code
hf skills add --claude
What does it buy you? Mostly, the agent stops guessing. The clearest single view is how many commands each run takes, with the skill and without:


On both agents that's about ten commands per task down to about seven, roughly 30% fewer tool calls. That's because the agent isn't probing --help to find the right command and argument. The skill won't cut your token bill, because it prepends a fixed slice of info to the context, so tokens remain about the same or slightly tick up for the same task. The Skill won't make the CLI more reliable either, but it will help the agent spend time running your task rather than finding out how the tool works. This could be particularly helpful when using hf with local models.
We ran each task in a fresh session, so the skill pays its context cost on every task. In a real multi-task session that cost amortizes (the agent learns the command surface once), so the token picture likely improves there; we didn't measure that case.
Try it yourself
We benchmarked all this because we think it matters. Agents are becoming real users of the Hub: they train models, build and clean datasets, and ship demos as Spaces, almost always on behalf of a person. A Hub that works well for agents is also a Hub that works better for the people using them. The better an agent's tools are, the more it can do for you.
If your agent interacts with the Hugging Face Hub, we recommend giving it the hf CLI:
# macOS / Linux
curl -LsSf https://hf.co/cli/install.sh | bash
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
Then hand it the skill, so it knows the whole command surface from the first turn:
hf skills add # Codex, Cursor, OpenCode, Pi and other agents that load skills from .agents/skills
hf skills add --claude # the above + Claude Code
Then point your agent at the Hub and let it work. Make sure you're logged in (hf auth login), then hand it a prompt like:
Use `hf` to list my Hugging Face Hub models, datasets, and Spaces.
Take a look at how I am currently using the Hub and suggest a few ways you could help me.
It'll work out the commands on its own and come back with something useful.
The full command reference lives in the hf CLI guide.
Register an agent harness
Building an agent harness? Get it registered! That's how hf learns to detect it, and how the Hub attributes its traffic to your harness. You simply need to open a small PR adding an entry to agent-harnesses.ts. Read the Register your agent harness guide for more details.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み