hf-mem – Agents & Automation skill for AI agents
Hugging Face CLI to estimate the required memory to load Safetensors or GGUF model weights for inference from the Hugging Face Hub
Install the hf-mem skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/hf-mem-c584f.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /hf-mem – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/hf-mem-c584f.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $hf-mem – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/hf-mem-c584f.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /hf-mem – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/hf-mem-c584f.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /hf-mem – then describe the task you want done.
SKILL.md content
hf_mem estimates the required memory for inference, including model weights and an optional KV cache, for Safetensors and GGUF for models on the Hugging Face Hub using HTTP Range requests i.e., without downloading or loading any weights locally.
When to use?
- User asks how much VRAM or memory a model needs to run
- User wants to know if a model fits on their GPU or a given instance
- User references a Hugging Face model ID or URL and asks about inference requirements
What are the requirements?
uvinstalled (foruvx)HF_TOKENfrom the host's private credential handling for gated/private repositories; avoid putting tokens in command arguments, logs or reports.- A reviewed pinned
hf-mempackage version and permission to access the requested model metadata. This skill does not bundle the executable.
How to run?
The angle-bracket and square-bracket forms below are usage notation, not shell commands to paste literally. Quote actual model IDs and file paths. Inspect the selected package's --help, choose a reviewed version (for example with uvx --from "hf-mem==REVIEWED_VERSION" hf-mem ...) and use a private cache where metadata is sensitive. Do not print credentials.
Run with --model-id pointing to the Hugging Face Hub repository which will check that it either contains Safetensors (via model.safetensors, model.safetensors.index.json if sharded, or model_index.json for Diffusers) or GGUF model weights within.
uvx hf-mem --model-id <model-id> --json-outputIf the repository contains GGUF model weights in multiple precisions / quantizations, the estimations will be on a per-file basis, whereas for inference you won't load all of those but rather only a single precision. This being said, for GGUF you might as well need to provide --gguf-file to target the specific file (or path if sharded) you want to run.
uvx hf-mem --model-id <model-id> --gguf-file <file-or-path> --json-outputAdditionally, hf-mem comes with an --experimental flag that will also calculate the KV cache memory requirements too, useful for large-language models, meaning it applies to LLMs (...ForCausalLM), VLMs (...ForConditionalGeneration), and GGUF models.
As per the context window, it will be read from the default or overridden with --max-model-len a la vLLM. And, same goes for the KV cache precision, which will default to the model precision unless manually set via --kv-cache-dtype a la vLLM too.
For Safetensors use as:
uvx hf-mem --model-id <model-id> --experimental [--max-model-len N] [--batch-size N] [--kv-cache-dtype auto|bfloat16|fp8|fp8_ds_mla|fp8_e4m3|fp8_e5m2|fp8_inc] --json-outputAnd, for GGUF use as:
uvx hf-mem --model-id <model-id> --gguf-file <file-or-path> --experimental [--max-model-len N] [--batch-size N] [--kv-cache-dtype auto|F32|F16|Q4_0|Q4_1|Q5_0|Q5_1|Q8_0|Q8_1|Q2_K|Q3_K|Q4_K|Q5_K|Q6_K|Q8_K|IQ2_XXS|IQ2_XS|IQ3_XXS|IQ1_S|IQ4_NL|IQ3_S|IQ2_S|IQ4_XS|I8|I16|I32|I64|F64|IQ1_M|BF16|TQ1_0|TQ2_0|MXFP4] --json-outputExamples
For Transformers with Safetensors weights:
uvx hf-mem --model-id MiniMaxAI/MiniMax-M2 --json-outputFor Diffusers with Safetensors weights:
uvx hf-mem --model-id Qwen/Qwen-Image --json-outputFor Sentence Transformers with Safetensors weights:
uvx hf-mem --model-id google/embeddinggemma-300m --json-outputWith --experimental to include the KV cache estimation for LLMs and VLMs:
uvx hf-mem --model-id mistralai/Mistral-7B-v0.1 --experimental --json-outputAnd, for LLMs or VLMs with GGUF weights:
uvx hf-mem --model-id unsloth/Qwen3.5-397B-A17B-GGUF --gguf-file Q4_K_M --experimental --json-outputLimitations
- Use this skill only when the task clearly matches its upstream product or API scope.
- Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
- Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
Interpretation and verification
Report the model revision, selected weight file or quantization, batch size, context length and KV-cache dtype alongside the estimate. Weight/header estimates are not a guarantee that a model fits: runtime workspaces, activations, allocator fragmentation, offloading and concurrent processes add memory. Confirm with the intended inference backend on target hardware before making a purchase or deployment decision. HTTP metadata access still contacts the Hub and can reveal private model identifiers; it does not run inference. Experimental KV estimates depend on supported architectures.
Related skills
- hierarchical-agent-memory – Scoped CLAUDE.md memory system that reduces context token spend. Creates directory-level…
- skillopt-sleep – Use when the user wants their Claude agent to self-improve from past usage, asks about a…
- hosted-agents – Build background agents in sandboxed environments. Use for hosted coding agents…
- hosted-agents-v2-py – Build hosted agents using Azure AI Projects SDK with HostedAgentDefinition. Use when…
- hubspot-automation – Automate HubSpot CRM operations (contacts, companies, deals, tickets, properties) via…
- huggingface-community-evals – Curated upstream guidance for Huggingface Community Evals; use when the workflow matches…
- hunt-dispatch – Skill-set loader for /hunt orchestrator.
- spec-driven-workflow – Use when the user asks to write specs before code, define acceptance criteria, plan…