AV ComfyUI Manual
12 / 64
Files
12
PART I · WORKFLOW ENGINEERING FOR COMFYUI

Modules & Input/Output Contracts — designing branches as replaceable building blocks

A professional workflow is easier to build and maintain when every major branch has one responsibility, explicit inputs, a predictable output and an independent checkpoint. The Master Workflow then becomes a system of modules rather than a monolith.

CONFIRMEDThe modular approach matches the documented Hansen structure: SDXL, masks, PEOPLE/PPL, main FLUX and output form separate functional branches with clear merge and return points.
01 · MODULE

A module is a complete responsibility, not just a colored frame

A group becomes an engineering module only when its purpose can be stated in one sentence, its required inputs can be listed, and one or more expected outputs can be named.

A good module can be temporarily separated from the Master Workflow, fed with test inputs, and evaluated independently.

02 · INPUT CONTRACT

The input contract defines what a module is allowed to expect

A branch should not rely on hidden assumptions. If a module requires an IMAGE at 1536 px, a MASK on the same canvas, a MODEL from a specific family and a FLOAT denoise value, that contract should be explicit before integration.

An input contract includes more than the socket type: dimensions, batch, coordinate space, polarity, model family, and whether the parameter is required or optional all matter.

Contract fieldExample
TypeIMAGE / MASK / LATENT / MODEL
Dimensions1536 × 1024
Batch1 image / N masks
Coordinate spaceSame as BASE IMAGE
Model familySDXL / FLUX-compatible
Required / optionalBASE IMAGE required; reference optional
03 · OUTPUT CONTRACT

The output contract defines what downstream can safely consume

An output should be usable by the next module without guesswork. If the PEOPLE branch returns a composited IMAGE on the same canvas, downstream FLUX can consume it as a predictable source. If the branch returns a crop at a different size, that is a different contract.

04 · RETURN CONTRACT

The return point is the branch’s official exit back into the Master Workflow

A complex branch should have one clearly readable return point. This is where the local task is complete and its result becomes part of the main data plane again.

Marking the return point explicitly makes standalone extraction, debugging and implementation replacement easier without forcing downstream reconstruction.

05 · RESPONSIBILITY

One module — one primary responsibility

ModuleResponsibility
CONTROLNETCreate / apply geometry guidance
SDXLProduce base generation / img2img result
MASKSDefine protected / editable regions
PPLCreate or replace people and return a composite
MAIN FLUXPerform controlled final refinement
UPSCALEIncrease output resolution while preserving consistency
OUTPUTSave / preview the delivery result
06 · HIDDEN DEPENDENCIES

A hidden dependency makes a “standalone” module misleading

If a branch looks isolated but relies on a seed, size, prompt fragment or model object from a distant part of the Master Workflow, it is not actually autonomous. Before extraction, identify every external link that crosses the intended module boundary.

A standalone JSON is independent only when every required external dependency has been replaced by a local input/control/loader or explicitly documented in the contract.

INFERRED

Extraction rule

Before exporting a branch, list every incoming link that crosses the selected group boundary. Each link must become either a local dependency or an explicit input.

07 · MODULE CHECKPOINT

Every module should expose its own provable result

If the only preview is at the very end of the Master Workflow, it is difficult to identify which module failed. A local module output should therefore have a Preview / MaskPreview / comparer or another diagnostic probe.

08 · MASTER BUILD

The Master Workflow should assemble like LEGO from known modules

09 · PRACTICE

Practice: write a contract for one familiar branch

  • Choose one branch from the current workflow.
  • State its responsibility in one line.
  • List every external incoming link.
  • For each input, record type, size/batch and required/optional status.
  • Name one official output / return point.
  • Add a checkpoint immediately before return.
  • Verify that upstream can be replaced with test inputs and the branch can run independently.