ComfyUI Extension: Claude Code ComfyUI Nodes
ComfyUI nodes for integrating Claude Code SDK - enables AI-powered code generation, analysis, and assistance within ComfyUI workflows
Custom Nodes (0)
README
Claude Code ComfyUI Nodes
ComfyUI nodes for integrating Claude Code SDK - enables AI-powered code generation, analysis, and assistance within ComfyUI workflows.
Overview
This node pack provides a stateless, command-based interface to Claude Code within ComfyUI. Unlike traditional chat interfaces, these nodes operate as single-shot commands, making them perfect for automation workflows similar to n8n, Zapier, or Make.
Key Features
- Stateless Command Execution: Each node execution is independent, with explicit memory/context passing
- Folder-Based Output Management: All outputs are organized in timestamped folders
- Context Chaining: Convert previous outputs into memory for subsequent commands
- Argument Substitution: Use variables in commands and memory (e.g.,
${PROJECT_NAME}
) - Tool Control: Fine-grained control over which tools Claude can use
Nodes
1. Claude Code Command
The main execution node that runs Claude Code commands.
Inputs:
command
: The instruction/command for Claude to executemodel
: Choose between "sonnet" or "opus" modelsmax_turns
: Maximum iterations Claude can take (1-10)memory
: Optional context/memory (like CLAUDE.md content)arguments
: JSON object for variable substitutionprevious_output_folder
: Link to previous command's outputallowed_tools
: Comma-separated list of allowed tools
Outputs:
output_folder
: Name of the folder containing all generated filesclaude_response
: Claude's final response textsession_id
: Session ID for potential continuationsexecution_metadata
: JSON metadata about the execution
2. Claude Code Reader
Inspect and read files from Claude Code output folders.
Inputs:
output_folder
: Folder name from a ClaudeCodeCommandfile_pattern
: Glob pattern for files (e.g., "*.py")read_mode
: "list_files", "read_all", or "read_specific"specific_file
: File to read in "read_specific" modemax_files
: Maximum files to read
Outputs:
file_contents
: The actual file contentsfile_list
: JSON list of files with metadatametadata
: Execution metadata from the folder
3. Claude Code Context Builder
Convert output folders into memory/context for chaining commands.
Inputs:
output_folder
: Folder to build context fromcontext_mode
: How to build context ("full_content", "file_list", "summary", "custom")base_memory
: Existing memory to append tofile_filter
: File extensions to includecustom_template
: Custom context templatemax_file_size_kb
: Max file size to include
Outputs:
memory
: Formatted memory/context string
Installation
- Ensure you have ComfyUI installed
- Clone this repository into your
ComfyUI/custom_nodes
directory - Choose your setup:
Option A: Claude Code Max Plan (Recommended)
If you have a Claude Code Max Plan subscription:
- Install Claude Code from https://claude.ai/code
- The "Claude Code Command (Max Plan)" node will use your existing subscription
- No API key needed, no per-token costs
Option B: Developer API
If you want to use the Anthropic API directly:
- Install dependencies:
pip install claude-code-sdk aiofiles
- Set your
ANTHROPIC_API_KEY
environment variable - Use the "Claude Code Command (API)" node
- Pay per token based on API usage
- Restart ComfyUI
Usage Examples
Basic Command Execution
- Add a "Claude Code Command" node
- Enter your command, e.g.:
Create a Python script that generates fibonacci numbers. Include error handling and type hints.
- Set model to "sonnet" and max_turns to 3
- Execute the workflow
- Check the output folder for generated files
Chaining Commands
- First command generates code
- Connect output_folder to a "Claude Code Context Builder"
- Connect the memory output to a second "Claude Code Command"
- The second command can reference and build upon the first
Using Arguments
Set arguments as JSON:
{
"PROJECT_NAME": "MyAwesomeProject",
"LANGUAGE": "Python"
}
Then use in your command:
Create a ${LANGUAGE} project structure for ${PROJECT_NAME}.
Include README, tests, and proper package structure.
Output Organization
All outputs are stored in claude_code_outputs/
with the structure:
claude_code_outputs/
├── output_20240615_143022_a1b2c3d4/
│ ├── _claude_code_metadata.json
│ ├── generated_script.py
│ └── README.md
└── output_20240615_144512_e5f6g7h8/
├── _claude_code_metadata.json
└── refactored_code.py
Best Practices
- Be Specific: Clear, detailed commands produce better results
- Use Context: Chain commands together for complex workflows
- Manage Tools: Only enable tools that are needed for security
- Check Outputs: Use the Reader node to verify generated content
- Template Commands: Save frequently used commands as text files
License
GNU General Public License v3