Skip to content

Guide · Agent skill

How to use the Stable Diffusion Image Generation agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The stable-diffusion-image-generation skill is a set of instructions that teaches an AI agent how to write Python code using Hugging Face Diffusers to create images with Stable Diffusion models. It is for designers, hobbyists and developers who have a suitable GPU and Python setup and want the agent to help build image generation code. After reading this guide you will know how to install the skill, how to ask for what you need, and what hardware and software the generated code expects.

Stable Diffusion Image GenerationOrchestra-Research/AI-Research-SKILLs · MIT

Quick start

  1. 1Download and unzip the skill. Download the ZIP from this page and unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder, or upload it under Settings → Capabilities → Skills in the Claude apps.
  2. 2Install the Python libraries. Run pip install diffusers transformers accelerate torch in your Python environment, adding xformers if you want memory-efficient attention.
  3. 3Confirm your GPU. Check that you have a CUDA-capable GPU, since the code calls .to('cuda'). Without one, the examples will not run as written.
  4. 4Make a natural request. Describe the image or edit you want, such as text-to-image, image-to-image, inpainting or ControlNet, and name your input files.
  5. 5Review and run the generated script. Read the code the agent writes, then run it. Model weights download from Hugging Face on first use.
  6. 6Tune settings. Adjust num_inference_steps, guidance_scale, negative_prompt and seed to refine results.

What is an agent skill and what does this one do?

An agent skill is a folder of instructions and reference files that an AI agent loads when your request matches the skill's description. This skill is a guide the agent follows: it does not generate images by itself.

Once installed, the agent knows how to write code that turns text prompts into images, transforms existing pictures with text guidance, fills masked areas of a photo, and adds control such as edges or poses using ControlNet. It also explains settings like steps, guidance scale, seeds for reproducible results, and negative prompts. The actual image generation runs on your own machine or cloud GPU through the code the agent writes.

  • Text-to-image from natural language prompts
  • Image-to-image translation with a strength setting
  • Inpainting with a mask image (white marks the area to fill)
  • ControlNet conditioning for edges, poses, depth, normal maps, line segments and sketches
  • LoRA adapter loading for style adaptation
  • Custom pipelines built from separate components

Install the skill (ZIP download or Claude apps upload)

Download the skill ZIP from this page and unzip it. The folder contains SKILL.md plus two reference files, references/advanced-usage.md and references/troubleshooting.md.

For a personal install, unzip the folder into ~/.claude/skills/. To make it available only inside one project, unzip it into that project's .claude/skills/ folder.

If you use the Claude apps, you can instead upload the skill under Settings → Capabilities → Skills.

  • Personal: ~/.claude/skills/stable-diffusion-image-generation/
  • Project only: .claude/skills/stable-diffusion-image-generation/ inside your project
  • Claude apps: Settings → Capabilities → Skills

Install the Python libraries the code needs

The skill's examples depend on several Python packages. The skill's metadata lists diffusers at 0.30.0 or newer, transformers at 4.41.0 or newer, accelerate at 0.31.0 or newer, and torch at 2.0.0 or newer. xformers is optional and provides memory-efficient attention.

The source's quick-start install command is shown below. Run it in the Python environment you plan to use.

pip install diffusers transformers accelerate torch pip install xformers # Optional: memory-efficient attention

Trigger the skill with natural requests

You do not need to name the skill. The agent loads it when your request fits the description: generating images from text prompts, image-to-image translation, inpainting, or building custom diffusion pipelines. Describe the goal and the inputs you have.

Good requests name the task, the input image if any, and the output you want. Mention your GPU situation if it matters.

  • "Write a Python script that generates a 1024x1024 image of a futuristic city with Diffusers."
  • "Use Stable Diffusion image-to-image to turn my photo input.jpg into a watercolor painting."
  • "Write inpainting code that replaces the masked area of photo.jpg with a red car. The mask is mask.png, white for the region to fill."
  • "Add ControlNet canny conditioning so my house layout keeps its edges."
  • "Show me how to make results reproducible with a seed and use a negative prompt."

Example: a basic text-to-image script

This is the skill's basic text-to-image example. It loads a Stable Diffusion 1.5 model from Hugging Face, moves it to a CUDA GPU, and saves the result. The model weights are downloaded from Hugging Face the first time they are used.

from diffusers import DiffusionPipeline import torch pipe = DiffusionPipeline.from_pretrained( "stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16 ) pipe.to("cuda") image = pipe( "A serene mountain landscape at sunset, highly detailed", num_inference_steps=50, guidance_scale=7.5 ).images[0] image.save("output.png")

Key settings you can ask the agent to explain

The skill documents the main generation parameters. num_inference_steps sets the number of denoising steps, and more steps generally means better quality. guidance_scale controls how closely the image follows the prompt, with 7 to 12 described as typical. A generator seeded with a fixed number makes outputs reproducible. negative_prompt lists what to avoid, and strength in image-to-image sets how much the input image is changed (0 to 1).

  • num_inference_steps: default 50
  • guidance_scale: default 7.5, 7 to 12 typical
  • height and width: multiples of 8
  • generator: a seeded torch generator for reproducibility
  • num_images_per_prompt: batch size, default 1

Safety notes: scripts and network access

This skill runs scripts and uses the network. The code it writes downloads model weights from Hugging Face, and the skill's install commands use pip. Review generated code before running it, especially if it is going to run on a shared or cloud machine.

The code expects CUDA hardware. Calls such as .to("cuda") fail on a machine without a CUDA-capable GPU.

The skill does not address the licences of the model weights or the provenance of the training data. Check the licence of each model you download before using outputs commercially.

Tips for better results

Use float16 and CPU offload if memory is tight. The SDXL example in the skill calls pipe.enable_model_cpu_offload() and uses 1024x1024 output. Schedulers trade speed for quality: the skill lists DPMSolverMultistepScheduler at 15 to 25 steps as fast and high quality, and LCMScheduler at 4 to 8 steps as very fast. Keep a seed when you want to compare prompt changes fairly.

If installation or runtime errors appear, ask the agent to check the troubleshooting reference. The source includes fixes for package conflicts such as the cached_download import error, and for xFormers and Torch/CUDA mismatches.

  • Use a fixed seed to compare prompt edits fairly
  • Try DPMSolverMultistepScheduler for faster runs
  • Use enable_model_cpu_offload() for lower GPU memory use
  • Ask the agent to consult references/troubleshooting.md for errors

What people use it for

  • Generating concept images from text prompts with an open Stable Diffusion model
  • Restyling an existing photo into a painting style with image-to-image
  • Replacing an object in a photo by inpainting a masked region
  • Keeping the layout of a sketch or photo with ControlNet canny or scribble conditioning
  • Building a Python image generation feature for an app with a custom pipeline

Frequently asked questions

How do I install the stable-diffusion-image-generation skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or a project's .claude/skills/ folder for one project. In the Claude apps you can instead upload it under Settings → Capabilities → Skills.

What hardware do I need to run it?

The generated code expects a CUDA-capable GPU, because the examples call .to('cuda'). The skill recommends a GPU but does not give specific memory requirements, so check your model's needs before running it.

Is this skill free and what is its licence?

The skill is listed under the MIT licence. The licences of the Stable Diffusion model weights you download from Hugging Face are separate, and the skill does not address them.

Can the skill generate images without a GPU or Python?

Not as written. The skill focuses on local Diffusers code in Python, and the examples expect CUDA hardware and installed libraries. If you want a simple one-click tool, a web-based or API service is a better fit.

What are the alternatives to this skill?

The skill's own guide lists DALL-E 3 for API-based generation without a GPU, Midjourney for artistic outputs, Imagen for Google Cloud integration, and Leonardo.ai for web-based creative workflows.

Why does my code fail with a CUDA or cached_download error?

The troubleshooting reference covers these cases. For a cached_download ImportError, it suggests upgrading huggingface_hub and diffusers. For CUDA kernel or CUBLAS errors, it suggests checking your CUDA and Torch versions and reinstalling PyTorch with the matching CUDA build.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Choose this skill if you have a CUDA GPU and Python, and want an agent to write Diffusers code for generating, editing or controlling images with open Stable Diffusion models. Pick a hosted image service or a simple one-click app instead if you have no GPU, want no code, or need images with cleared commercial licensing.

Download the skill