Generate or edit images when this task has no native tool for the requested operation, or the user explicitly chooses this plugin or a configured provider.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Image Generation?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/wecode-ai-image-generation)
---
name: image-generation
description: Generate or edit images when this task has no native tool for the requested operation, or the user explicitly chooses this plugin or a configured provider.
---
# Image generation and editing
Choose the route before checking plugin configuration or submitting an image request:
1. If the user explicitly selects this plugin or one of its configured provider profiles, use this plugin. Being installed or enabled, or having this Skill automatically activated, is not an explicit selection.
2. Otherwise, prefer the runtime's native image tool when it is available in the current task for the requested generation or edit. Follow that tool's instructions and stop this plugin workflow; native generation does not require this plugin's configuration.
3. If no native tool is available for the requested operation, use this plugin's task CLI below. If the plugin is disabled, unavailable or unconfigured, explain what is needed; do not automatically install, enable or configure it.
Use actual tool availability and its supported operations, not a model name, image-input support, a configuration flag or the presence of a Skill file, to select the route. Do not submit an image request just to probe support. These instructions guide the agent's tool selection; they do not enforce routing inside the host.
Choose one route per request. Errors, quota exhaustion, timeouts, cancellation, partial results and unknown outcomes after a call do not make the native tool absent. Do not automatically switch between native generation, this CLI, MCP or providers to resend it. A separate user request can authorize another generation.
When the plugin route is selected, run `node scripts/image-generation.mjs` from this plugin's installed directory, or use the script's absolute path, in the active task shell. Use the configured default provider unless the user explicitly selects another configured profile. The text/chat model does not need to match the image provider.
1. Run `node scripts/image-generation.mjs config` and find the selected profile in its `providers` list. Use the user's explicitly selected provider ID, or `default_provider` when none was selected; require that profile's `configured` value to be true. An unconfigured default or another profile must not block a different configured selection. If the selected profile is missing or unconfigured, direct the user to this plugin's **插件配置 → 默认配置 / Plugin configuration → Default configuration** button. They can also run `node scripts/settings.mjs start` from this plugin's installed directory. If task identity is required but unavailable, explain that the service must be called from a task with an injected Wework identity. Do not request API keys or usernames in chat, read credential files, inspect environment values, or configure credentials through shell tool arguments.
2. Translate the user's request into both a clear image prompt and explicit provider parameters in `options`. Each supplied option overrides the same configured default; unspecified options keep their defaults. For one requested image set `options.n` to `1`; translate a requested size, quality or format into the corresponding supported option. Never keep a conflicting default just because it is configured, or change persistent settings to satisfy one request. Invoke `node scripts/image-generation.mjs generate` with one JSON object on standard input: `{"prompt":"...","options":{"n":1}}`. The only request fields are `prompt`, optional `provider`, `output_directory` and `options`, plus `images` and optional `mask` for edits. Never pass identity, usernames, model, URL, headers or credentials as request parameters. Keep the JSON separate from executable shell syntax; do not create temporary request files.
3. When revising an image, invoke `node scripts/image-generation.mjs edit` with the same JSON shape and `images` containing the actual absolute source image paths. Use a previously saved result or the user's attachments. Preserve reference order. Pass a mask only for a provider/model that supports it. Do not substitute a new text-only generation for an edit.
4. If the active task workspace path is known, set `output_directory` to its `generated-images` subdirectory. Otherwise omit it: the plugin uses its configured output directory or `~/Pictures/WeWork`. Never save outputs inside the installed plugin directory. Source files are preserved.
5. Keep the shell tool's result object and wait for the existing process to finish. A `session_id` without an `exit_code` means it is still running, even when `output` is empty. Continue that same session with `write_stdin` and empty `chars`, accumulating its output chunks until a final exit code arrives. If an outer tool wrapper yields a job or cell ID, resume it through that wrapper's wait tool first. A long requested yield time does not prove completion. Do not start another CLI call or use a directory listing as a substitute for the final result. Parse the completed CLI's JSON even when its exit code is nonzero.
6. Display every returned saved image **once** by copying its `markdown` field verbatim into the final response, outside a code block. It is a standard Markdown image with an absolute local `file:` URI and the image's `prompt` in its quoted title. Keep its URI encoding and HTML entities intact so paths, quotes, backslashes and multiline prompts remain correct. `prompt_source: "provider_revised"` means the provider reported a revised prompt; `"request"` means the prompt sent in this call. Do not claim a request prompt was revised. When an image includes `transparency`, report its actual status as described below. The tool returns text metadata only and does not display an image itself. Do not also embed data URLs or emit a second copy as an attachment. Show only files actually returned as saved, including saved images in a partial result.
7. For `partial`, show the saved images and explain the reported processing failure or unmet transparency requirement; it does not necessarily mean a file could not be saved. `error.code: "transparency_not_confirmed"` with `generation_state: "completed"` means the output was preserved but transparency was not confirmed. Do not delete it or resubmit. For failed, timed-out or cancelled calls, report the result without claiming an image was generated. If the completed process returns no valid JSON, report that the result could not be confirmed. Never automatically retry a generation: `generation_state: unknown` means the provider may already have accepted or charged for it. Do not switch to MCP, another provider or another command to resend a failed or uncertain operation. A separate user request can authorize another generation.
## Transparent backgrounds
For background removal, use `edit` with the original image; creating a new transparent image still uses `generate`. When removing a background without a requested replacement, or when the user explicitly requests transparency, include the corresponding option rather than only prompt text. With a provider/model supporting OpenAI-compatible transparent output, set `options.background` to `"transparent"` and `options.output_format` to `"png"`, or `"webp"` if the user requested it. These values override conflicting defaults such as `"opaque"` or `"jpeg"` for this call only. Preserve unrelated defaults. For example:
```json
{
"prompt": "Remove the background and preserve the foreground subjects with clean edges.",
"images": ["/absolute/source.png"],
"options": { "n": 1, "background": "transparent", "output_format": "png" }
}
```
A request for both JPEG and transparency is incompatible; clarify the required format before submitting. Other providers may require different parameters or lack transparent output. A JSON gateway must map the corresponding options into its request body. Do not infer support from its model name or silently replace the user's requirement with a default. Report an unsupported operation or parameter without switching providers or resubmitting.
Only when the effective `background` is `"transparent"`, the plugin reports `images[].transparency` after inspecting saved pixels. `status: "present"` confirms actual pixels with alpha below 255; `"absent"` confirms no transparent pixels; `"unverified"` means a reliable check is unavailable. Optional dimensions and `transparent_pixels` / `pixel_count` describe the inspected image; `reason` may explain a limitation. The bounded check supports common non-interlaced 8-bit PNGs. Unsupported bit depths, interlacing, animation, WebP/GIF or malformed data yield `unverified`; JPEG and confirmed opaque RGB images yield `absent`. Without other download or save errors, non-`present` results report `partial`, completed generation, and `transparency_not_confirmed`; mixed failures retain the original error code. Preserve the saved files and inspect each image's metadata in either case. Calls not requesting transparency are unaffected.
`present` confirms only that some transparent pixels exist, not that the background was fully removed or the foreground preserved. Inspect the actual image before making those claims. A PNG extension, RGBA channels or a checkerboard preview are not evidence of success. State any unverified limitation, and do not claim private-gateway support was tested. Do not invent success or perform unrequested Python, color-key or pixel-threshold processing to conceal an opaque result; that can remove foreground details. Preserve the returned image and report the unmet requirement without automatic resubmission.
Task identity is supplied by Wework to the active task shell. A private provider can bind an HTTP header to `WEGENT_SKILL_USER_NAME` through `header_env`; the CLI reads that binding internally. Never copy a username into the request, invent one, use the OS `USER`/`USERNAME`, or set a global environment variable as a substitute. Restricted tasks may deliberately have no identity; preserve that boundary. Do not print the identity or any credential.
Provider capability differences are deliberate: OpenAI edits accept multiple files and optional masks; Seedream uses its image-generation endpoint with image references and has no mask field in this adapter. Seedream `n > 1` requests a group with an upper bound, not an exact count. Streaming is not implemented. Parameters unsupported by the selected model can be rejected by its API; do not silently change providers to conceal errors.
Configuration is plugin-owned. Standard MCP tools remain available for external MCP clients, but this Skill consistently uses the task CLI so it can use the task shell's existing context. A standalone MCP client does not automatically receive Wework task identity. Public providers need no employee identity; private gateways can require a configured task identity binding. No Wework backend, Team or host image-provider extension is required. For configuration and custom gateway mapping, see [the plugin README](../../README.md).