Hey everyone β I just had one of those "oh wow this actually matters" moments reading through a really solid deep dive on HuggingFace, and they've completely rethought their CLI for AI agents! Published back on June 4th in my hometown by CΓ©lina Hanouti and Lucain Pouget Wauplin (two HF engineers who clearly care about the craft), this post is full of practical gems. I was particularly drawn into it because we keep hearing so much talk about coding agents taking over, but rarely do developers see actual hard evidence for why optimizing your tooling matters β not just "it's good to have them" vibes.
What got my attention first: they started tracking agent traffic on the Hub in April 2026 and found that Claude Code alone is already at around **40k distinct users** with nearly **49 million requests**, while Codex follows close behind, dwarfing every other coding assistant β Cursor, Gemini CLI, Pi Agent (that little AIAGENT variable), even Hugging Chat itself. Here's the clever part: *hf-cli* auto-detects whether a coding agent is driving it by reading environment variables at runtimeβCLAUDECODE/CLAUDE_CODE for Claude Code, CODEX_SANDBOX/CODEX_SANBOX for Codex (_CURSOR and _GEMINI_ too), plus the universal AI_AGENT variableβand that single signal triggers two behaviors simultaneously: different output formatting AND a tagged user-agent string so they can attribute every request back to who drove it. And now I'm seeing why this matters in practiceβhumans expect rich terminal tables with ANSI colors, green checkmarks (β/β), progress bars and prose hints about what to do next; coding agents want the *opposite*: no truncation at all, full ISO timestamps on every record, absolutely nothing lost because an agent handles dense data beautifully.
The benchmark numbers blew me away: when a coding hand-rolls through curl calls or uses the Python SDK directly for complex multi-step tasksβlike listing models and then running inference endpointsβit consumes up to **six times as many tokens** compared against using the optimized CLI! That's genuinely remarkable because token budgets matter *a lot* in real-world agent workflows where you're paying per call. They introduced this "agent mode" starting with hf-cli v1.9.0 (still rolling out across releases now) and built in features like next-command hints showing exactly what to run afterβ`Use \`hf jobs logs 6f3a1c2e9b\`` for exampleβthe agent can chain operations without guessing IDs, plus non-blocking behavior where everything's safe-to-retry so agents don't choke on timeouts or lost context (`--exist-ok` is literally documented as "no-op if already exists"). Everything that guides (hints, warnings, errors) goes to stderr while structured data stays in stdout β no pollution. My takeaway? If you're building agent workflows around the HuggingFace Hub and still hand-rolling requests through basic SDK calls or curl commands, ditching vanilla for this optimized version is a must-have optimization worth your time.
Source: https://huggingface.co/blog/hf-cli-for-agents
What got my attention first: they started tracking agent traffic on the Hub in April 2026 and found that Claude Code alone is already at around **40k distinct users** with nearly **49 million requests**, while Codex follows close behind, dwarfing every other coding assistant β Cursor, Gemini CLI, Pi Agent (that little AIAGENT variable), even Hugging Chat itself. Here's the clever part: *hf-cli* auto-detects whether a coding agent is driving it by reading environment variables at runtimeβCLAUDECODE/CLAUDE_CODE for Claude Code, CODEX_SANDBOX/CODEX_SANBOX for Codex (_CURSOR and _GEMINI_ too), plus the universal AI_AGENT variableβand that single signal triggers two behaviors simultaneously: different output formatting AND a tagged user-agent string so they can attribute every request back to who drove it. And now I'm seeing why this matters in practiceβhumans expect rich terminal tables with ANSI colors, green checkmarks (β/β), progress bars and prose hints about what to do next; coding agents want the *opposite*: no truncation at all, full ISO timestamps on every record, absolutely nothing lost because an agent handles dense data beautifully.
The benchmark numbers blew me away: when a coding hand-rolls through curl calls or uses the Python SDK directly for complex multi-step tasksβlike listing models and then running inference endpointsβit consumes up to **six times as many tokens** compared against using the optimized CLI! That's genuinely remarkable because token budgets matter *a lot* in real-world agent workflows where you're paying per call. They introduced this "agent mode" starting with hf-cli v1.9.0 (still rolling out across releases now) and built in features like next-command hints showing exactly what to run afterβ`Use \`hf jobs logs 6f3a1c2e9b\`` for exampleβthe agent can chain operations without guessing IDs, plus non-blocking behavior where everything's safe-to-retry so agents don't choke on timeouts or lost context (`--exist-ok` is literally documented as "no-op if already exists"). Everything that guides (hints, warnings, errors) goes to stderr while structured data stays in stdout β no pollution. My takeaway? If you're building agent workflows around the HuggingFace Hub and still hand-rolling requests through basic SDK calls or curl commands, ditching vanilla for this optimized version is a must-have optimization worth your time.
Source: https://huggingface.co/blog/hf-cli-for-agents