custom-blocks

A packaging tool for turning a local modular pipeline block, a reusable piece of pipeline logic, into a directory that can be uploaded to the Hugging Face Hub.

In plain words
What is it for?
Publishing an already-written Python pipeline block or creating the on-disk structure for a modular pipeline repository.
Why use it?
It prepares the required files and layout so other users can load the block from the Hub.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/huggingface/diffusers/custom-blocks
Any agent
npx skills add huggingface/diffusers --skill custom-blocks
Clone the repo
git clone --depth 1 https://github.com/huggingface/diffusers

Made for: Claude Code, Codex.

Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,637 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00079 $0.01637
Opus 5 $0.00039 $0.00818
Sonnet 5 $0.00016 $0.00327
Haiku 4.5 $0.00008 $0.00164

Measured 2d ago against content hash becb119c4b27, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

custom-blocks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.ai/skills/custom-blocks/SKILL.md · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

What this skill is for

A ModularPipelineBlocks subclass is a unit of pipeline logic — input/output spec plus a __call__ — that slots into diffusers' modular pipeline composition. Once you have one defined locally, you almost always want to publish it as a small Hub repo so others can from_pretrained it. diffusers-cli custom_blocks automates the packaging step: it parses your Python file, instantiates the chosen block class, and writes a save_pretrained-style directory in your cwd that's ready to push to the Hub.

Use this skill when:

  • The user is writing a custom modular block and asks "how do I publish this?" or "package this for the Hub".
  • The user has a block.py (or similar) file with one or more ModularPipelineBlocks subclasses.
  • You're scaffolding a new modular pipeline repo and need the on-disk layout that ModularPipelineBlocks.from_pretrained expects.

Don't use this skill for: running an existing modular pipeline (diffusers-cli run), introspecting one (diffusers-cli schema), or writing the block class itself — this skill packages an already-written block.

The end-to-end workflow

[you: write block.py] → diffusers-cli custom_blocks → [packaged dir in cwd]
                                                            ↓
                                            hf upload <repo> .
                                                            ↓
                                consumers: ModularPipeline.from_pretrained(<repo>, trust_remote_code=True)
                                           diffusers-cli schema --model <repo> --trust-remote-code
                                           diffusers-cli run --model <repo> --trust-remote-code ...

The skill covers the middle box. The bookends (writing the block and uploading) are out of scope.

Command surface

diffusers-cli custom_blocks [--block_module_name <file.py>] [--block_class_name <ClassName>]

Flags

  • --block_module_name <file> — Python file containing the block class. Defaults to block.py in the cwd.
  • --block_class_name <name> — Which class in the file to package. Optional: if omitted, the CLI parses the file with ast, finds every class that inherits from ModularPipelineBlocks, and uses the first one (with an info log naming the others). Specify explicitly when the file defines more than one block and you want a specific one.

Read the full file on GitHub · 160 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 160 lines · 79 tokens per session scan A becb119c4b27

Subscribe to this mod's changes

custom-blocks is a skill published in the GitHub repository huggingface/diffusers (34,407 stars, last pushed 2d ago), licensed Apache-2.0. It adds 79 tokens to every session and 1,637 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.