Nodes/ArtyClaw Comfy Nodes/Prompt Block Loader
ComfyUI Node

Prompt Block Loader

Edit Your Prompt Blocks in a Text File, Not Inside the Graph

By artyclaw·Created 5 months ago·Updated 5 months ago· 0
Prompt Block Loader
    • block1
    • block2
    config_pathprompt_blocks.txt
    blocknamemyblock
    force_reloadfalse

    There's a workflow itch that Prompt Block Loader scratches: you've got long, structured prompt chunks that you'd rather edit in a text editor than inside a ComfyUI node's cramped multiline box - and you want the graph to pick up the changes without touching the workflow. It reads a plain .txt config file, extracts two named "blocks," and outputs them as two strings. Edit the file, save, re-run, done. No graph editing.

    It's from artyclaw/artyclaw-comfy. Given how prompt engineering has shifted toward "structure your prompt in blocks" (the KB's own prompt-engineering doc calls block structure a genuinely new best practice for LLM-encoded models), this is the pack's most future-facing IO node.

    How it works

    The config file is a simple line format:

    # comments are ignored
    !myblock1
    a red car on a mountain road
    golden hour, low angle
    
    !myblock2
    shot on 35mm, shallow depth of field
    

    A header line !<name>1 or !<name>2 starts a block (the trailing digit is part of the header), content runs until the next ! header or the end of file, and # lines are skipped. The node builds keys from (blockname, "1") and (blockname, "2"), so with blockname = "myblock" it returns the content under !myblock1 and !myblock2.

    The nice touch is cache handling: the node's IS_CHANGED hook reports the config file's modification time, so ComfyUI automatically re-runs it when the file changes on disk. No manual "reload" ritual. The optional force_reload toggle exists for when you want to bypass that timestamp check anyway.

    Inputs and outputs

    • config_path - path to the config file, relative or absolute (default prompt_blocks.txt, relative to the ComfyUI working directory).
    • blockname - the base name whose 1 and 2 blocks you want (default myblock).
    • force_reload (optional) - bypass the file-timestamp cache.

    Outputs are block1 and block2 (both STRING). Missing blocks return empty strings rather than erroring.

    Install

    ComfyUI Manager → search ArtyClaw Comfy Nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/artyclaw/artyclaw-comfy
    

    Restart. Pure Python (os, re, time).

    Where people get burned

    Relative paths resolve against ComfyUI's working directory, not the node's folder - so prompt_blocks.txt ends up wherever you launched ComfyUI from, which surprises people the first time. Second, the block-name matching is exact and case-sensitive: !MyBlock1 won't match blockname = myblock. Third, the header regex only allows letters, digits, underscores, and hyphens in the name - a space in your block name silently never matches. And the two-block limit is hardcoded; if you have ten blocks, this node isn't the one - it's specifically for a pair you want to keep editing outside the graph. For that narrow, very real need, it's excellent.

    CategoryPrompting/IO

    Inputs (3)

    NameTypeDefaultDescription
    config_pathSTRINGprompt_blocks.txtPath to the config .txt file (relative or absolute).
    blocknameSTRINGmyblockBase block name to fetch: will output <blockname>1 and <blockname>2.
    force_reloadoptBOOLEANfalseForce reload even if file timestamp hasn't changed.

    Outputs (2)

    NameTypeDescription
    block1STRING
    block2STRING