Prompts · Images et photos
Un script qui envoie ton workflow à ComfyUI
Claude écrit un petit script qui reprend ton workflow exporté, change la description et la graine, l'envoie à ComfyUI, attend l'image et l'enregistre. Puis, si tu veux, il en fait un skill /image.
Le prompt, en français
4 cases sont vides : elles partiront entre crochets, et Claude te posera la question.
Voir la version anglaise, celle qui est copiée
Write a script that drives ComfyUI from this folder, based on my workflow.
Workflow exported in API format: [Le fichier du workflow exporté au format API]
ComfyUI address: [L'adresse de ComfyUI sur ta machine]
Image folder: [Où enregistrer les images]
Language: [Le langage du script, ou « choisis pour moi »]
1. First of all
- Read ComfyUI's official documentation on the workflow API format (https://docs.comfy.org/development/api-development/workflow-api-format) and on the server routes (https://docs.comfy.org/development/comfyui-server/comms_routes), as well as the official example `script_examples/websockets_api_example.py` in the ComfyUI repository. Do not rely on your memory.
- Check that ComfyUI responds at the given address (`GET /system_stats`). If it doesn't, stop and tell me what to check.
- Open the workflow and list its nodes (number, `class_type`, `_meta.title`). If the file is not in API format, tell me to export it with "File → Export Workflow (API)".
2. Find nodes by their title
Do not rely on node numbers, which change from one workflow to another. Find the nodes to modify by their `_meta.title` (for example "PROMPT", "NEGATIF", "SEED", "TAILLE"). If they don't have a clear title yet, tell me which ones to rename in ComfyUI before exporting again. If a title is missing at run time, the script stops with a clear message.
3. The script
- It reads the workflow and replaces the description, the seed (random if I don't give one) and the size if I give one, without modifying the original file.
- It sends `{"prompt": <workflow>, "client_id": <identifier>}` as a POST to `/prompt` and reads the `prompt_id` from the response. If the response contains `error` or `node_errors`, it prints the error in a readable way and stops.
- It waits for completion by polling `/history/<prompt_id>` (once per second, with an adjustable maximum delay), or through the `/ws` WebSocket if that is simpler in this language.
- It downloads each image listed in `outputs` with `/view` (parameters `filename`, `subfolder`, `type`) and saves it in the image folder, with a name that contains the date and the seed.
- Next to each image, a small JSON file with the description, the seed, the size and the workflow name, so it can be regenerated.
- Command-line options: the description (required), the seed, the size, the number of images. Help (`--help`) and messages in French.
- No dependency if the standard library is enough; otherwise a single one, which you explain to me.
4. Try it
Run a real generation with a simple description, show me the path of the image and of its JSON file, then check that a wrong address or a missing node title gives a clear message.
5. Optional: a skill
Offer to turn it into an `/image` skill (`.claude/skills/image/SKILL.md`) that runs this script with the description I type (`$ARGUMENTS`), checking the skill format on https://code.claude.com/docs/en/skills. Only create it with my approval.
Talk to me in French.
Done when a real image has been generated and saved by the script, with its JSON file, and you have given me the command to generate another one.Comment t’en servir
Avant de coller ce prompt, fais marcher ton workflow à la main dans ComfyUI, puis exporte-le avec « File → Export Workflow (API) » et range le fichier dans ton projet. Renomme aussi les nœuds que le script doit changer (par exemple « PROMPT » pour le texte, « SEED » pour l'échantillonneur) : le script les retrouve par leur titre. ComfyUI doit être lancé pendant tout l'essai.
L'adresse de l'exemple, http://127.0.0.1:8188, est celle des exemples officiels de ComfyUI. Si ton installation en utilise une autre, mets la tienne : Claude vérifie d'abord que ComfyUI répond, et s'arrête si ce n'est pas le cas.
À la fin, tu as un script qui génère une image avec une simple commande, et un petit fichier à côté de chaque image pour pouvoir la refaire. La formation « Tes images et tes photos avec ComfyUI » a une leçon entière sur le pilotage depuis Claude Code.
Pour comprendre tout ce que fait ce prompt, et l’adapter : la formation Tes images et tes photos avec ComfyUI.