Nodes/comfyui-grok-prompt-forge/Grok System Prompt Loader
ComfyUI Node

Grok System Prompt Loader

The little file that decides what your API node actually does

By Slartibart23·Created 2 months ago·Updated a day ago· 1
Grok System Prompt Loader
    • system_prompt
    ◄prompt_filem3l4nie_caption_refine.txt►

    What this node is for

    Here's the thing about this pack: Grok Text Refine and Grok Vision Caption don't have a fixed job. What they do is entirely defined by the system prompt you hand them - caption refiner, prompt generator, translator, whatever. The system prompt is the job description.

    So you're going to be writing and rewriting a few hundred words of instructions. The worst possible place to keep that text is a ComfyUI widget: it lives inside your workflow JSON, it's miserable to edit in a text box, and it gets baked into every exported workflow you share. This node reads it off disk instead.

    How it works

    One input, prompt_file. Give it a filename or a path and it resolves in this order: an absolute path first, then a bare filename is looked up in this pack's own system_prompts/ folder, then in your ComfyUI root (next to main.py).

    The output is a single system_prompt STRING. Wire it into the system_prompt input of Grok Text Refine or Grok Vision Caption and you're done.

    The part that earns its keep is the file watch. The node reports the file's modification time as its change signal, so editing and saving the file makes the next queue run pick up the new content. You do not restart ComfyUI, you do not touch the graph, you do not re-export anything. Tweak a line, hit queue, compare outputs. If you're iterating on a prompt - which is most of what you do with these nodes - that loop is the entire value.

    Because the prompt lives outside the workflow, it also becomes something you can version, diff, and keep a library of. Keep a handful of prompt files in system_prompts/ and switch jobs by editing one string.

    The pack ships two: m3l4nie_caption_refine.txt (the default) and m3l4nie_vision_caption.txt. Both are the author's own LoRA dataset-captioning prompts - long, specific rules about which traits to keep and which to drop for a training trigger token. Treat them as a worked example of how much structure a good system prompt carries, not as a general-purpose default. If you're not captioning a dataset, write your own.

    Install

    Search Grok Prompt Forge (xAI) in ComfyUI Manager, or clone it manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Slartibart23/comfyui-grok-prompt-forge
    

    Restart, and the nodes show up under Grok → Text. The README calls requests the single dependency; the actual requirements.txt also pins Pillow>=9.0 and numpy>=1.24, both of which already ship with ComfyUI, so a Manager install is painless.

    You'll need an xAI key from console.x.ai. Don't type it into the api_key widget on the API nodes - that ends up inside exported workflows. Do this instead: create grok_api_key.txt in your ComfyUI root containing nothing but the key, and leave the widget empty. (The API nodes also honour an XAI_API_KEY environment variable.) Watch out for Windows hiding file extensions and quietly naming it grok_api_key.txt.txt.

    Common issues

    "File not found" with a path list. The error prints every location it searched, so read it - usually you put the file somewhere sensible but not somewhere the node looks. A bare filename only checks system_prompts/ and the ComfyUI root. For anything else, pass an absolute path; forward slashes are fine on Windows.

    Encoding. This node opens UTF-8, full stop - unlike Grok Text File Loader, which tries utf-8-sig, utf-8, cp1252 and latin-1 in turn. Save your prompt files as UTF-8 or it'll throw a decode error.

    A prompt that looks like it did nothing. The file watch keys on modification time, so a save always registers. If the output didn't change, that's usually the API node downstream reusing a cached result - its seed is the cache-breaker, and on fixed it will happily return the old text for identical inputs.

    CategoryGrok/Text

    Inputs (1)

    NameTypeDefaultDescription
    prompt_fileSTRINGm3l4nie_caption_refine.txtName or path of a .txt file holding a system prompt. Bare filenames are looked up in this node pack's system_prompts/ folder, then in the ComfyUI root; absolute paths work too. The node watches the file - edit and save it, and the next run automatically uses the new content.

    Outputs (1)

    NameTypeDescription
    system_promptSTRING—