Nodes/Claude Code ComfyUI Nodes/Claude Code Execute
ComfyUI Node

Claude Code Execute

Run a real Claude Code agent from inside a ComfyUI graph

By christian-byrne·Created about a year ago·Updated about a year ago· 34
Claude Code Execute
  • memory
  • arguments
  • tools
  • previous_output
  • mcp_config
  • output
  • response
  • metadata
command_sourcefile
command_file[Custom Command]
command# Claude Code Command Your command instructions here...
modeldefault
max_turns8

Claude Code Execute is the engine room of the Claude Code ComfyUI Nodes pack. Where the other nodes in the pack build inputs and read outputs, this one actually runs the agent: it hands a command to the real Claude Code CLI, lets it think and write files, and hands you back what it made. If you've ever wanted to tell ComfyUI "write me a Python script" and have the result sitting in a folder when the queue finishes, this is the node.

The name is a slight lie, in the good way: it doesn't call any API and needs no key of its own. The node shells out to the claude command-line tool via subprocess, piping your prompt into claude -p --max-turns N. Whatever auth your CLI already has - a Claude Max subscription or an ANTHROPIC_API_KEY in your environment - is what gets used. The README talks about separate "Max Plan" and "API" nodes, but the shipped code has one Execute node either way; that split only exists in how you've logged your CLI in.

How it works

Mechanically it's a one-shot (stateless) run, not a chat. Each execution makes a fresh timestamped folder inside claude_code_outputs/ (relative to wherever you launched ComfyUI), builds a prompt from your command plus any memory, arguments, or previous-output context, and tells Claude to write all its files into that folder and nowhere else. That folder is the entire sandbox. When the run finishes you get three things: the folder name as the output (CLAUDE_OUTPUT type), the agent's final response text, and a metadata JSON with execution time, model, turn count, exit code, and what was written. Progress messages stream to the UI as it runs.

The inputs that matter

  • command_source - file pulls from the dropdown, text lets you type straight into the node. New command files go in the pack's commands/ folder.
  • command / command_file - your actual instructions. This is where the prompt quality lives; a vague command gets a vague result.
  • model - default, sonnet, or opus. Sonnet is the sensible workhorse; opus for genuinely hard reasoning tasks.
  • max_turns - how many agentic steps Claude may take, 1–512, default 8. Big tasks eat turns fast.

The optional inputs are the interesting part, because they wire in the rest of the pack: memory (from Claude Memory Builder), arguments (from Claude Arguments Builder, for ${VAR} substitution), tools (from Claude Tools Config, which becomes --allowedTools flags), previous_output (a prior run's folder, read as context), and mcp_config (from Claude MCP Manager).

Installing

Install: ComfyUI Manager (search "Claude Code ComfyUI Nodes"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/christian-byrne/claude-code-comfyui-nodes

then restart. The requirements.txt lists claude-code-sdk and aiofiles, but the code actually just calls the CLI - so the dependency that actually matters is the claude binary itself on your PATH, signed in. Run claude in a terminal once to confirm.

Common issues

Where people get burned: the CLI not being on ComfyUI's PATH (launch ComfyUI from a shell where which claude works); Claude leaving the sandbox folder if your command never tells it where to write (keep the "create all output files in: [folder]" instruction intact); and max_turns being too low for multi-file tasks, which ends in a half-finished folder and a nonzero exit code in the metadata. Someone on r/comfyui described trying this pack for agentic workflows and it "worked pretty well" - the honest caveat is that a full agent run costs real tokens or Max-plan usage, so it's not a node you click idly. Use it deliberately, and let the Reader node show you what actually got made.

Categoryclaude_code

Inputs (10)

NameTypeDefaultDescription
command_sourceCOMBOfileUse command from file or custom text
command_fileCOMBO[Custom Command]Select a command file from the commands folder
commandSTRING# Claude Code Command Your command instructions here...Custom command (used when command_source is 'text' or file is '[Custom Command]')
modelCOMBOdefaultClaude model to use
max_turnsINT81–512Maximum number of turns Claude can take to complete the task
memoryoptCLAUDE_MEMORYMemory/context from Claude Memory Builder
argumentsoptCLAUDE_ARGUMENTSArguments from Claude Arguments Builder
toolsoptCLAUDE_TOOLSTool configuration from Claude Tools Config
previous_outputoptCLAUDE_OUTPUTOutput from previous Claude Code execution
mcp_configoptMCP_CONFIGMCP configuration from Claude MCP Manager

Outputs (3)

NameTypeDescription
outputCLAUDE_OUTPUT
responseSTRING
metadataJSON