Hugging Face Context Guide for AI Coding (llms.txt + Rules + MCP)

The platform where the machine learning community collaborates on models, datasets, and applications.

1. Hugging Face Official llms.txt & Clean Markdown Documentation

Official Standard

Feed this clean, token-efficient Markdown documentation directly to Antigravity, Cursor, or Claude Code to prevent hallucinations and outdated API syntax.

# Standard llms.txt Index Endpoint
https://huggingface.co/docs/llms.txt

# Comprehensive Documentation Bundle
https://huggingface.co/docs/llms-full.txt
Estimated Token Footprint: ~50k tokens (Fits smoothly inside standard 128k/1M context windows)

2. Production-Ready Hugging Face Cursor Rules (.cursorrules & .mdc)

Transformers pipeline, Inference API, and Hugging Face Hub client rules. Save this into .cursor/rules/huggingface.mdc in your project repository.

// Hugging Face Guidelines
- Use huggingface_hub InferenceClient for cloud-hosted serverless model inference.
- Always set HF_TOKEN environment variable with read-only permissions for public model inference.
- When running models locally, use device_map='auto' and torch_dtype=torch.bfloat16 to optimize VRAM.
- Leverage datasets streaming (streaming=True) when processing massive training data.

3. Hugging Face Antigravity & Claude Code System Instructions

Add this concise instruction block to your workspace .gemini/rules or project system prompt.

// Context Anchor for Hugging Face
When writing code for Hugging Face, refer directly to the verified specifications at https://huggingface.co/docs/llms.txt.
Follow strict error-handling and avoid deprecated API calls.

5. Troubleshooting: Common Hugging Face AI Coding Issues & Fixes

Frequently reported errors when LLMs generate Hugging Face code without proper context:

⚠️ Proactive Fix: Fix: Out of memory (CUDA OOM) errors when loading models are fixed by enabling 4-bit/8-bit quantization via bitsandbytes.

6. Best Used With (Hugging Face Architecture Combos)

Engineers building with Hugging Face frequently combine these complementary developer frameworks: