diffusers-workflow
CLAUDE.md19 starsChanged 3 days agoApache-2.0View on GitHub
diffusers-workflow is a declarative workflow engine for HuggingFace Diffusers. Users define AI image/video generation pipelines in JSON — variable substitution, multi-step composition, cross-step data flow, and utility tasks — without writing Python. Supports CUDA (NVIDIA), MPS (Apple Silicon), and CPU. docs/ARCHITECTURE.md is the map: concept, owning module, the rule that holds across the seam, and the test or check that enforces it. Open it before grepping - it names the module, and that module's docstring holds the detail. - dw.serve…
In this repository4 other files it gives its agents.
- dw_mcp/CLAUDE.mdCLAUDE.md
- ui/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- model-family-onboardingSkill
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 83
All entry points use dw/security.py's validators (paths, URLs, subprocess arguments) and the trust gate is dw/trust.py.
- Very specific: line 88
Never: use eval(), exec(), or shell=True
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
diffusers-workflow is a declarative workflow engine for HuggingFace Diffusers. Users define AI image/video generation pipelines in JSON — variable substitution, multi-step composition, cross-step data flow, and utility tasks — without writing Python. Supports CUDA (NVIDIA), MPS (Apple Silicon), and CPU.
Common Commands
# Install
bash ./install.sh && source ./activate
# HTTP server + web UI (http://127.0.0.1:8765, API docs at /docs)
python -m dw.serve
dw setup # service + Claude registrations (docs/INSTALL.md); checkout: venv/bin/dw setup --no-service --no-desktop
dw agent # Claude Code with the dw-notes channel
# Run a workflow - dw.run only queues it on a running dw.serve. This is the SD 1.5
# smoke test: small and ungated (no HF login); it proves the engine, not the picture
python -m dw.run workflows/templates/text-to-image.json
python -m dw.run workflows/templates/text-to-image.json prompt="a cat" num_images_per_prompt=4
# A picture on the model this server prefers (preference:text_to_image), by tier;
# a gated model (workflows/models/flux-dev.json) needs `hf auth login` first
python -m dw.run workflows/templates/preferred/text-to-image.json prompt="a cat" tier=best
# Validate a workflow against schema
python -m dw.validate workflows/models/z-image.json
# Unit tests - parallel on every core (`-n auto`); naming files runs one process
pytest tests/ -v
pytest tests/test_security.py -v
# System test (the smoke test) - downloads SD 1.5 (a few GB) and generates one image
python -m dw.testWhere things are
docs/ARCHITECTURE.md is the map: concept, owning module, the rule that holds across
the seam, and the test or check that enforces it. Open it before grepping - it names the
module, and that module's docstring holds the detail.
dw.serveruns every job in a persistent spawned worker (one per--devicescard) (dw/worker.py, managed bydw/worker_manager.py) that keeps models cached between runs, so a change to engine code needs a server restart before a job sees it.- The packaged
dw/workflows/is what abuiltin:step names (resolved indw/library.py); it is not the top-levelworkflows/folder of runnable examples. - The workflow schema is
dw/workflow_schema.json- read it for the full structure. - The HTTP server is
dw/server/(seedw/server/CLAUDE.md), the web UI isui/(seeui/CLAUDE.md), and the stdio MCP server isdw_mcp/(seedw_mcp/CLAUDE.md).
The guides in docs/, by topic:
WORKFLOW_GUIDE.md- writing workflow JSON. It owns the reference conventions (variable:,previous_result:,constant:,asset:,output:,prompt:,item:,gather:): its Authoring a workflow from an agent section, References first, and the Type System section.WORKSPACES.md- workspaces, the library search paths, run directories and manifests.SERVER.md- the HTTP API and web UI;REMOTE.md- using a server on another machine.MCP.md- the MCP tool surface;AGENT_LOOP.md- the automated implementer/tester loop.WORKER_GUIDE.md- the persistent worker and its queue protocol.TASKS.md- the utility task commands (dw/tasks/).ACCELERATION.md- caching, compile, attention backends, device settings, MPS;QUANTIZATION.md- per-component quantization backends;RECIPES_24GB.md- tested combinations of both per model family.LORAS.md,IP_ADAPTER.md,PROMPT_WEIGHTING.md- those features, one each.SECURITY.md- the validators and trust gate in depth;SECURITY_QUICKREF.md- the same at a glance.TESTING.md- the test suite;DEPENDENCIES.md- installation;RELEASING.md- releases.
Claude Code plugin
.claude-plugin/marketplace.json publishes the dw plugin in plugins/dw/ (it also starts the dw MCP server,
plugins/dw/.mcp.json): one composition skill per model family (minimax-h3, minimax-music3, ltx-2.5, kandinsky-6,
flux3-klein, minimax-h3-image) that chooses a template for a request's shape and states the family's hard rules, the
cross-cutting shapes above the families (script-to-video, series-episodes, cinematography, storyboard, long-form), and
choosing-a-model, which routes a request naming no family, workflow or model to the server's preference: ladder. Every skill
is named in plugins/dw/README.md (which says what each does and how it is pinned and versioned) and here, pinned by
tests/test_plugin_skills.py.
Security Rules
All entry points use dw/security.py's validators (paths, URLs, subprocess arguments) and the trust gate is dw/trust.py. When adding features:
- Validate paths with
validate_path()/validate_workflow_path()/validate_output_path() - Validate variable names with
validate_variable_name()(pattern:^[a-zA-Z_][a-zA-Z0-9_-]*$) - Validate URLs with
validate_url()(http/https only) - Sanitize subprocess args with
sanitize_command_args() - Never use
eval(),exec(), orshell=True - Path traversal (
../) is blocked
CodeQL models these validators as sanitizers (.github/codeql/dw-security/; the map's
CodeQL path-injection model row). That only holds while filesystem access goes through
one: reaching the disk some other way is a real alert, so treat one as a finding, not
noise. validate_path(path, base) is a barrier only when base is not None; with
None it is normalization only, and the path stays reportable.
Before you edit
- Model knowledge lives in
plugins/dw/and the catalog, never in engine code. A model's rule about a value is declared in the workflow (dw/variable_constraints.py), or read off the diffusers class that enforces it (dw/reference_limits.py,dw/pipeline_limits.py); the engine names the class, never the number. - Compare backends with
get_device_type(), not== "cuda"- a device likecuda:1fails the string compare (dw/__init__.py). {}keeps a value a string: under a*_type/*_dtype/dtypekey"{nf4}"stays"nf4"; unbraced it is loaded as a type, and fails at load time, after validation has passed (docs/WORKFLOW_GUIDE.mdTypes and escaping;dw/arguments.py).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

