Generated banner for Huggingface Tool Builder
Generated logo for Huggingface Tool Builder

Huggingface Tool Builder

Hugging FaceOfficialPublished by Hugging Face

  • Skill
  • Tool integration
  • Automation and integrations
  • Apache-2.0
  • Low risk
  • Has scripts

From the author

Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful when chaining or combining API calls or the task will be repeated/automated. This Skill creates a reusable script to fetch, enrich or process data.
— the description by Hugging Face

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill assists in creating custom command-line scripts and utilities for interacting with the Hugging Face ecosystem. It focuses on building composable tools that can fetch, process, and enrich data from the Hugging Face API or the Hub CLI. The skill emphasizes best practices such as secure authentication using environment variables, modular script design, and the use of piping and streaming for efficient data handling.

What it does

  • Generates reusable shell, Python, or TypeScript scripts for API interactions
  • Implements secure authentication patterns using environment variables
  • Creates composable utilities that support piping and streaming data
  • Provides guidance on querying API endpoints and extracting relevant metadata
  • Integrates with the Hub CLI for repository and infrastructure management
  • Ensures scripts include help documentation for inputs and outputs

When to use it

  • When you need to automate repetitive tasks involving Hugging Face data
  • When you want to chain multiple API calls to process model or dataset information
  • When you require a custom CLI tool to filter or enrich repository metadata
  • When you need to handle authenticated requests for gated or private content

Advantages

  • Promotes modularity through shell-friendly JSON output and piping
  • Ensures secure handling of credentials for authenticated access
  • Provides a consistent approach to building resilient and documented tools
  • Leverages existing CLI capabilities for streamlined repository interaction

Usage examples

“Create a script that fetches the top 10 most downloaded models and outputs their IDs.”
The agent generates a shell script that queries the API, processes the JSON response, and pipes the output to a filter to display the top 10 model IDs.
“Write a utility to extract license information from a list of model IDs provided via stdin.”
The agent provides a script that reads model IDs, fetches individual metadata, and outputs the license details in a structured format.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/huggingface/huggingface-tool-builder/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip huggingface-tool-builder.zip -d .agents/skills

Documentation by Hugging Face

Hugging Face API Tool Builder

Your purpose is now is to create reusable command line scripts and utilities for using the Hugging Face API, allowing chaining, piping and intermediate processing where helpful. You can access the API directly, as well as use the hf command line tool. Model and Dataset cards can be accessed from repositories directly.

Script Rules

Make sure to follow these rules:

  • Scripts must take a --help command line argument to describe their inputs and outputs

  • Non-destructive scripts should be tested before handing over to the User

  • Shell scripts are preferred, but use Python or TSX if complexity or user need requires it.

  • IMPORTANT: Use the HF_TOKEN environment variable as an Authorization header. For example: curl -H "Authorization: Bearer ${HF_TOKEN}" https://huggingface.co/api/. This provides higher rate limits and appropriate authorization for data access.

  • Investigate the shape of the API results before commiting to a final design; make use of piping and chaining where composability would be an advantage - prefer simple solutions where possible.

  • Share usage examples once complete.

Be sure to confirm User preferences where there are questions or clarifications needed.

Sample Scripts

Paths below are relative to this skill directory.

Reference examples:

  • references/hf_model_papers_auth.sh — uses HF_TOKEN automatically and chains trending → model metadata → model card parsing with fallbacks; it demonstrates multi-step API usage plus auth hygiene for gated/private content.

  • references/find_models_by_paper.sh — optional HF_TOKEN usage via --token, consistent authenticated search, and a retry path when arXiv-prefixed searches are too narrow; it shows resilient query strategy and clear user-facing help.

  • references/hf_model_card_frontmatter.sh — uses the hf CLI to download model cards, extracts YAML frontmatter, and emits NDJSON summaries (license, pipeline tag, tags, gated prompt flag) for easy filtering.

Baseline examples (ultra-simple, minimal logic, raw JSON output with HF_TOKEN header):

  • references/baseline_hf_api.sh — bash

  • references/baseline_hf_api.py — python

  • references/baseline_hf_api.tsx — typescript executable

Composable utility (stdin → NDJSON):

  • references/hf_enrich_models.sh — reads model IDs from stdin, fetches metadata per ID, emits one JSON object per line for streaming pipelines.

Composability through piping (shell-friendly JSON output):

  • references/baseline_hf_api.sh 25 | jq -r '.[].id' | references/hf_enrich_models.sh | jq -s 'sort_by(.downloads) | reverse | .[:10]'

  • references/baseline_hf_api.sh 50 | jq '[.[] | {id, downloads}] | sort_by(.downloads) | reverse | .[:10]'

  • printf '%s\n' openai/gpt-oss-120b meta-llama/Meta-Llama-3.1-8B | references/hf_model_card_frontmatter.sh | jq -s 'map({id, license, has_extra_gated_prompt})'

High Level Endpoints

The following are the main API endpoints available at https://huggingface.co

/api/datasets
/api/models
/api/spaces
/api/collections
/api/daily_papers
/api/notifications
/api/settings
/api/whoami-v2
/api/trending
/oauth/userinfo

Accessing the API

The API is documented with the OpenAPI standard at https://huggingface.co/.well-known/openapi.json.

IMPORTANT: DO NOT ATTEMPT to read https://huggingface.co/.well-known/openapi.json directly as it is too large to process.

IMPORTANT Use jq to query and extract relevant parts. For example,

Command to Get All 160 Endpoints

curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths | keys | sort'

Model Search Endpoint Details

curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths["/api/models"]'

You can also query endpoints to see the shape of the data. When doing so constrain results to low numbers to make them easy to process, yet representative.

Using the HF command line tool

The hf command line tool gives you further access to Hugging Face repository content and infrastructure.

❯ hf --help
Usage: hf [OPTIONS] COMMAND [ARGS]...

  Hugging Face Hub CLI

Options:
  --help                Show this message and exit.

Commands:
  auth                 Manage authentication (login, logout, etc.).
  buckets              Commands to interact with buckets.
  cache                Manage local cache directory.
  collections          Interact with collections on the Hub.
  datasets             Interact with datasets on the Hub.
  discussions          Manage discussions and pull requests on the Hub.
  download             Download files from the Hub.
  endpoints            Manage Hugging Face Inference Endpoints.
  env                  Print information about the environment.
  extensions           Manage hf CLI extensions.
  jobs                 Run and manage Jobs on the Hub.
  models               Interact with models on the Hub.
  papers               Interact with papers on the Hub.
  repos                Manage repos on the Hub.
  skills               Manage skills for AI assistants.
  spaces               Interact with spaces on the Hub.
  sync                 Sync files between local directory and a bucket.
  upload               Upload a file or a folder to the Hub.
  upload-large-folder  Upload a large folder to the Hub.
  version              Print information about the hf version.
  webhooks             Manage webhooks on the Hub.

The hf CLI command has replaced the now deprecated huggingface-cli command.

Files

references/find_models_by_paper.sh

#!/bin/bash

# Find models associated with papers on Hugging Face
# Usage: ./find_models_by_paper.sh [arXiv_id|search_term]
# Optional: Set HF_TOKEN environment variable for private/gated models

set -e

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Help function
show_help() {
    echo -e "${BLUE}Find models associated with papers on Hugging Face${NC}"
    echo ""
    echo -e "${YELLOW}Usage:${NC}"
    echo "  $0 [OPTIONS] [search_term|arXiv_id]"
    echo ""
    echo -e "${YELLOW}Options:${NC}"
    echo "  --help    Show this help message"
    echo "  --token   Use HF_TOKEN environment variable (if set)"
    echo ""
    echo -e "${YELLOW}Environment:${NC}"
    echo "  HF_TOKEN  Optional: Hugging Face token for private/gated models"
    echo ""
    echo -e "${YELLOW}Examples:${NC}"
    echo "  $0 1910.01108                    # Search by arXiv ID"
    echo "  $0 distilbert                     # Search by model name"
    echo "  $0 transformer                    # Search by keyword"
    echo "  HF_TOKEN=your_token $0 1910.01108  # Use authentication"
    echo ""
    echo -e "${YELLOW}Description:${NC}"
    echo "This script finds Hugging Face models that are associated with research papers."
    echo "It searches for models that have arXiv IDs in their tags or mentions papers in their metadata."
    echo ""
    echo -e "${YELLOW}Notes:${NC}"
    echo "• HF_TOKEN is optional for public models"
    echo "• Use HF_TOKEN for private repositories or gated models"
    echo "• HF_TOKEN enables higher rate limits for heavy usage"
}

# Parse arguments
USE_TOKEN=false
POSITIONAL_ARGS=()

while [[ $# -gt 0 ]]; do
    case $1 in
        --help)
            show_help
            exit 0
            ;;
        --token)
            USE_TOKEN=true
            shift
            ;;
        -*)
            echo -e "${RED}Unknown option: $1${NC}"
            show_help
            exit 1
            ;;
        *)
            POSITIONAL_ARGS+=("$1")
            shift
            ;;
    esac
done

set -- "${POSITIONAL_ARGS[@]}"

if [[ $# -eq 0 ]]; then
    echo -e "${RED}Error: Please provide a search term or arXiv ID${NC}"
    echo -e "Use ${YELLOW}$0 --help${NC} for usage information"
    exit 1
fi

SEARCH_TERM="$1"

# Set up authentication header if HF_TOKEN is available
if [[ -n "$HF_TOKEN" ]] && [[ "$USE_TOKEN" == true || -n "$HF_TOKEN" ]]; then
    AUTH_HEADER="-H \"Authorization: Bearer $HF_TOKEN\""
    echo -e "${BLUE}Using HF_TOKEN for authentication${NC}"
else
    AUTH_HEADER=""
    if [[ -n "$HF_TOKEN" ]]; then
        echo -e "${YELLOW}HF_TOKEN found but not using it (add --token flag to use)${NC}"
    fi
fi

# Check if the input looks like an arXiv ID (format: YYYY.NNNNN or YYYY.NNNNNNN)
if [[ "$SEARCH_TERM" =~ ^[0-9]{4}\.[0-9]{4,7}$ ]]; then
    echo -e "${BLUE}Searching for models associated with arXiv paper: $SEARCH_TERM${NC}"
    SEARCH_QUERY="arxiv%3A$SEARCH_TERM"
    IS_ARXIV_SEARCH=true
else
    echo -e "${BLUE}Searching for models related to: $SEARCH_TERM${NC}"
    SEARCH_QUERY="$SEARCH_TERM"
    IS_ARXIV_SEARCH=false
fi

# Function to extract arXiv IDs from tags
extract_arxiv_ids() {
    local tags="$1"
    echo "$tags" | jq -r '.[] | select(. | startswith("arxiv:")) | split(":")[1]' 2>/dev/null || true
}

# Function to get paper title from arXiv ID
get_paper_title() {
    local arxiv_id="$1"
    # Try to get paper title from Hugging Face tags if available
    # This is a simplified approach - in practice, you might want to call arXiv API
    echo "Paper Title (arXiv:$arxiv_id)"
}

# Search for models
API_URL="https://huggingface.co/api/models"
echo -e "${YELLOW}Searching Hugging Face API...${NC}"

# Build curl command with authentication if available
CURL_CMD="curl -s $AUTH_HEADER \"$API_URL?search=$SEARCH_QUERY&limit=50\""
echo -e "${BLUE}API Query: $API_URL?search=$SEARCH_QUERY&limit=50${NC}"

# Execute the API call
if [[ -n "$HF_TOKEN" ]]; then
    RESPONSE=$(curl -s -H "Authorization: Bearer $HF_TOKEN" "$API_URL?search=$SEARCH_QUERY&limit=50" || true)
else
    RESPONSE=$(curl -s "$API_URL?search=$SEARCH_QUERY&limit=50" || true)
fi

# Check if we got a valid response
if [[ -z "$RESPONSE" ]] || [[ "$RESPONSE" == "[]" ]]; then
    echo -e "${RED}No models found for search term: $SEARCH_TERM${NC}"
    
    # If arXiv search failed, try without arxiv: prefix
    if [[ "$IS_ARXIV_SEARCH" == true ]]; then
        echo -e "${YELLOW}Trying broader search without arxiv: prefix...${NC}"
        SEARCH_QUERY="$SEARCH_TERM"
        IS_ARXIV_SEARCH=false
        
        if [[ -n "$HF_TOKEN" ]]; then
            RESPONSE=$(curl -s -H "Authorization: Bearer $HF_TOKEN" "$API_URL?search=$SEARCH_QUERY&limit=50" || true)
        else
            RESPONSE=$(curl -s "$API_URL?search=$SEARCH_QUERY&limit=50" || true)
        fi
        
        if [[ -z "$RESPONSE" ]] || [[ "$RESPONSE" == "[]" ]]; then
            echo -e "${RED}Still no results found. Try a different search term.${NC}"
            exit 1
        fi
    else
        exit 1
    fi
fi

# Process the results
echo -e "${GREEN}Found models! Processing results...${NC}"

# Use jq to process the JSON response and find models with paper associations
MODELS_WITH_PAPERS=$(echo "$RESPONSE" | jq -r '
  .[] |
  select(.id != null) |
  {
    id: .id,
    arxiv_tags: [.tags[] | select(. | startswith("arxiv:"))] | join("; "),
    downloads: (.downloads // 0),
    likes: (.likes // 0),
    task: (.pipeline_tag // "unknown"),
    library: (.library_name // "unknown")
  }
  | @base64' 2>/dev/null || true)

# Count total results
TOTAL_MODELS=$(echo "$RESPONSE" | jq 'length' 2>/dev/null || echo "0")
MODELS_WITH_PAPERS_COUNT=$(echo "$MODELS_WITH_PAPERS" | wc -l)

echo -e "${BLUE}Results Summary:${NC}"
echo -e "  Total models found: $TOTAL_MODELS"
echo -e "  Models with paper associations: $MODELS_WITH_PAPERS_COUNT"
echo ""

if [[ -z "$MODELS_WITH_PAPERS" ]]; then
    # Show all models even if no paper associations found
    echo -e "${YELLOW}No explicit paper associations found. Showing all matching models:${NC}"
    echo "$RESPONSE" | jq -r '
      .[] |
      select(.id != null) |
      "📦 \(.id)
   Task: \(.pipeline_tag // "unknown")
   Downloads: \(.downloads // 0)
   Likes: \(.likes // 0)
   Library: \(.library_name // "unknown")
   ---"
    ' 2>/dev/null || echo "Failed to parse response"
else
    # Show models with paper associations
    echo -e "${GREEN}Models with paper associations:${NC}"
    echo "$MODELS_WITH_PAPERS" | while read -r model_data; do
        if [[ -n "$model_data" ]]; then
            # Decode base64 and show formatted
            echo "$model_data" | base64 -d | jq -r '
                "📄 \(.id)
   arXiv: \(.arxiv_tags)
   Task: \(.task)
   Downloads: \(.downloads)
   Likes: \(.likes)
   Library: \(.library)
   ---"
            ' 2>/dev/null || echo "Failed to parse model data"
        fi
    done
fi

# Additional search tips
echo ""
echo -e "${BLUE}Search Tips:${NC}"
echo "• Try searching with the full arXiv ID (e.g., 1910.01108)"
echo "• Try searching with the paper title keywords"
echo "• Try searching with the model name"
echo "• Use HF_TOKEN for private models or higher rate limits"
echo ""
echo -e "${BLUE}Examples to try:${NC}"
echo "  $0 1910.01108                    # DistilBERT paper"
echo "  $0 1810.04805                    # BERT paper" 
echo "  $0 1706.03762                    # Attention is All You Need paper"
echo "  $0 roberta                       # RoBERTa models"
echo "  $0 transformer                   # Transformer models"
echo "  HF_TOKEN=your_token $0 1910.01108  # Use authentication"

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs network access, Needs Python

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Hugging Face
Publisher
Hugging Face (Official)
Source
huggingface/skills · skills/huggingface-tool-builder · commit 25910b3
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Hugging Face.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download huggingface-tool-builder.zip