<instructions Image Gen Generates AI images via Gemini Imagen 4, OpenRouter (Gemini 2.5 Flash Image / GPT-5-image), Z.ai GLM-image, or OpenAI DALL-E 3. Applies anti-AI-slop prompt prefixes per style. Four modes: generate, edit, config, update. Arguments: Mode Routing | Mode | Flow | |------|------| | generate | Phase 0 - 1 - 2 - 3 - 4 | | edit | Phase 0 - 1 - 2E - 3 - 4 | | config | Phase 0 - C | | update | Phase 0 - U | CONTEXT-AWARE MODE DETECTION (CRITICAL): Mode is detected from BOTH explicit flags AND natural language context. Priority: 1. Explicit flags: , , - override everything 2. Con…

; then\n pass \"TC3 naming convention: $FNAME matches YYYYMMDD-HHMMSS_*_gemini_vN.png\"\nelse\n fail \"TC3 naming convention\" \"filename '$FNAME' does not match pattern\"\nfi\n\n# --- Test 4: Auto-versioning: run twice → v1 and v2 ---\n# GIVEN we call save-image.sh twice with identical arguments in the same second\n# WHEN we inspect the version suffix\n# THEN the first file is v1 and the second is v2\nOUT_DIR=\"$WORK_DIR/tc4\"\nmkdir -p \"$OUT_DIR\"\n\n# Force both into the same timestamp by pre-creating the v1 file\nTS=$(date +\"%Y%m%d-%H%M%S\")\nPREEXIST=\"${OUT_DIR}/${TS}_version-test_gemini_v1.png\"\ntouch \"$PREEXIST\"\n\nSAVED2=$(sh \"$SCRIPT\" \"$WORK_DIR/test-b64.txt\" \"$OUT_DIR\" \"version test\" \"gemini\" \"version test\" 2>/dev/null)\nFNAME2=$(basename \"$SAVED2\")\n\nif printf '%s\\n' \"$FNAME2\" | grep -qE '_v2\\.png

<instructions Image Gen Generates AI images via Gemini Imagen 4, OpenRouter (Gemini 2.5 Flash Image / GPT-5-image), Z.ai GLM-image, or OpenAI DALL-E 3. Applies anti-AI-slop prompt prefixes per style. Four modes: generate, edit, config, update. Arguments: Mode Routing | Mode | Flow | |------|------| | generate | Phase 0 - 1 - 2 - 3 - 4 | | edit | Phase 0 - 1 - 2E - 3 - 4 | | config | Phase 0 - C | | update | Phase 0 - U | CONTEXT-AWARE MODE DETECTION (CRITICAL): Mode is detected from BOTH explicit flags AND natural language context. Priority: 1. Explicit flags: , , - override everything 2. Con…

; then\n pass \"TC4 auto-versioning: second run produces v2\"\nelse\n fail \"TC4 auto-versioning\" \"expected v2 suffix, got: $FNAME2\"\nfi\n\n# --- Test 5: Sidecar JSON has all required fields ---\n# GIVEN save-image.sh ran successfully (reuse TC2 output)\n# WHEN we read the sidecar JSON\n# THEN it contains prompt, provider, model, timestamp, filename\nSIDECAR=\"${SAVED%.png}.json\"\nJSON=$(cat \"$SIDECAR\")\n\ncheck_json_field() {\n FIELD=\"$1\"\n if printf '%s\\n' \"$JSON\" | grep -q \"\\\"$FIELD\\\"\"; then\n pass \"TC5 sidecar field: $FIELD\"\n else\n fail \"TC5 sidecar field: $FIELD\" \"not found in $SIDECAR\"\n fi\n}\n\ncheck_json_field \"prompt\"\ncheck_json_field \"provider\"\ncheck_json_field \"model\"\ncheck_json_field \"timestamp\"\ncheck_json_field \"filename\"\n\n# --- Test 6: Output dir creation: non-existing dir gets created ---\n# GIVEN an output directory that does not exist\n# WHEN save-image.sh runs\n# THEN the directory is created and the file is saved\nNEW_DIR=\"$WORK_DIR/tc6/nested/new\"\nSAVED3=$(sh \"$SCRIPT\" \"$WORK_DIR/test-b64.txt\" \"$NEW_DIR\" \"newdir test\" \"gemini\" \"newdir prompt\" 2>/dev/null)\n\nif [ -d \"$NEW_DIR\" ]; then\n pass \"TC6 dir creation: output directory created\"\nelse\n fail \"TC6 dir creation: output directory created\" \"dir not found: $NEW_DIR\"\nfi\n\nif [ -f \"$SAVED3\" ]; then\n pass \"TC6 dir creation: file saved in new dir\"\nelse\n fail \"TC6 dir creation: file saved in new dir\" \"file not found: $SAVED3\"\nfi\n\n# --- Test 7: Title truncation — long title → max 30 chars in filename stem ---\n# GIVEN a very long title (>30 chars)\n# WHEN save-image.sh runs\n# THEN the title portion of the filename is truncated to 30 characters\nLONG_TITLE=\"this is an extremely long title that should definitely be truncated\"\nOUT_DIR=\"$WORK_DIR/tc7\"\nSAVED4=$(sh \"$SCRIPT\" \"$WORK_DIR/test-b64.txt\" \"$OUT_DIR\" \"$LONG_TITLE\" \"openai\" \"trunc test\" 2>/dev/null)\nFNAME4=$(basename \"$SAVED4\")\n\n# Remove timestamp prefix (YYYYMMDD-HHMMSS_) and suffix (_service_vN.png)\n# Remaining is the title portion\nTITLE_PART=$(printf '%s\\n' \"$FNAME4\" | sed 's/^[0-9]*-[0-9]*_//' | sed 's/_openai_v[0-9]*\\.png$//')\nTITLE_LEN=$(printf '%s' \"$TITLE_PART\" | wc -c | tr -d ' ')\n\nif [ \"$TITLE_LEN\" -le 30 ]; then\n pass \"TC7 title truncation: length=$TITLE_LEN (\u003c=30) in '$TITLE_PART'\"\nelse\n fail \"TC7 title truncation\" \"title part '$TITLE_PART' has $TITLE_LEN chars, expected \u003c=30\"\nfi\n\n# --- Cleanup ---\nrm -rf \"$WORK_DIR\"\n\n# --- Summary ---\nTOTAL=$((PASS + FAIL))\nprintf '\\n=== RESULTS: %d/%d passed ===\\n' \"$PASS\" \"$TOTAL\"\nif [ \"$FAIL\" -gt 0 ]; then\n printf 'FAILED: %d test(s) failed\\n' \"$FAIL\"\n exit 1\nfi\nexit 0\n","content_type":"application/x-sh; charset=utf-8","language":"bash","size":5365,"content_sha256":"0be1096857d9095a37897bbf7ecabdd4ef4d8af3b40363b9d4272ef62dddc26c"}],"content_json":{"type":"doc","content":[{"type":"paragraph","content":[{"text":"\u003cinstructions>","type":"text"}]},{"type":"heading","attrs":{"level":1},"content":[{"text":"Image Gen","type":"text"}]},{"type":"paragraph","content":[{"text":"Generates AI images via Gemini Imagen 4, OpenRouter (Gemini 2.5 Flash Image / GPT-5-image), Z.ai GLM-image, or OpenAI DALL-E 3. Applies anti-AI-slop prompt prefixes per style. Four modes: generate, edit, config, update.","type":"text"}]},{"type":"paragraph","content":[{"text":"Arguments:","type":"text","marks":[{"type":"strong"}]},{"text":" ","type":"text"},{"text":"$ARGUMENTS","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Mode Routing","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mode","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Flow","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"generate","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 0 -> 1 -> 2 -> 3 -> 4","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"edit","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 0 -> 1 -> 2E -> 3 -> 4","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"config","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 0 -> C","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"update","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 0 -> U","type":"text"}]}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"CONTEXT-AWARE MODE DETECTION (CRITICAL):","type":"text","marks":[{"type":"strong"}]},{"text":" Mode is detected from BOTH explicit flags AND natural language context. Priority:","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Explicit flags: ","type":"text"},{"text":"--edit","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"--config","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"--update","type":"text","marks":[{"type":"code_inline"}]},{"text":" -> override everything","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Context analysis of ","type":"text"},{"text":"$ARGUMENTS","type":"text","marks":[{"type":"code_inline"}]},{"text":" text:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Edit signals: \"edit this\", \"modify image\", \"change the\", \"add to image\" + image path present -> ","type":"text"},{"text":"edit","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Config signals: \"setup\", \"configure\", \"set key\", \"add token\" -> ","type":"text"},{"text":"config","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Update signals: \"check providers\", \"update models\", \"latest API\" -> ","type":"text"},{"text":"update","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Everything else -> ","type":"text"},{"text":"generate","type":"text","marks":[{"type":"strong"}]},{"text":" (this is 99% of cases)","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Default: ","type":"text"},{"text":"generate","type":"text","marks":[{"type":"strong"}]},{"text":" — just a prompt, generate the image","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"FAST PATH (99% case):","type":"text","marks":[{"type":"strong"}]},{"text":" When ","type":"text"},{"text":"$ARGUMENTS","type":"text","marks":[{"type":"code_inline"}]},{"text":" is just a prompt text (no flags, no mode signals):","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Skip Steps 3-6 in Phase 1 (count, service, style, output questions)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use defaults: count=1, service=gemini, style=photo, output=.claude/reports/images/","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Go straight to config table (Step 7) + confirmation (Step 8)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Only AskUserQuestion if API key is missing","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"AGENT INVOCATION:","type":"text","marks":[{"type":"strong"}]},{"text":" This skill can be called by agents (not just users). When called from an agent:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Treat all provided args as final — do NOT ask for confirmation of values already specified","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Only AskUserQuestion for truly missing required values (prompt, API key)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"The config table is still mandatory but confirmation step can be skipped if all params are explicit","type":"text"}]}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"API KEY PRIORITY","type":"text","marks":[{"type":"strong"}]},{"text":" (check in order, first found wins):","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Explicit key in ","type":"text"},{"text":"$ARGUMENTS","type":"text","marks":[{"type":"code_inline"}]},{"text":" text (user pasted inline)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":".env","type":"text","marks":[{"type":"code_inline"}]},{"text":" in project root (","type":"text"},{"text":"source .env 2>/dev/null","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Shell environment variable","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"AskUserQuestion (redirect to Phase C)","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"MANDATORY:","type":"text","marks":[{"type":"strong"}]},{"text":" Before ANY API call, display the full resolved configuration table. User must see exactly what will be sent.","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 0: Parse Arguments","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Parse Flags","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"bash \"${CLAUDE_SKILL_DIR}/scripts/parse-args.sh\" $ARGUMENTS && echo \"OK\" || echo \"FAILED\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Output: KEY=VALUE pairs. Store all values.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Also scan ","type":"text","marks":[{"type":"strong"}]},{"text":"$ARGUMENTS","type":"text","marks":[{"type":"code_inline"},{"type":"strong"}]},{"text":" raw text","type":"text","marks":[{"type":"strong"}]},{"text":" for inline values not captured by flags:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"API key pasted in prompt text -> extract and use (overrides ","type":"text"},{"text":".env","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Service/style mentioned in free text -> treat as flags","type":"text"}]}]}]}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Key","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Default","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Options","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"PROMPT","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"(empty)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Free-text image description","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"MODE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"generate","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"generate, edit, config, update","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SERVICE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"gemini","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"gemini, openrouter, openai","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"STYLE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"photo","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"photo, illustration, art","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"COUNT","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"1","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"1-10","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"OUTPUT","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":".claude/reports/images/","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Directory path","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"SIZE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"1024x1024","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"WxH format","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"EDIT_IMAGE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"(empty)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Path to image for edit mode","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"EDIT_INSTRUCTIONS","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"(empty)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Edit instructions text","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"PROMPT_MISSING","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"false","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"true if no prompt in generate mode","type":"text"}]}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"STOP if FAILED","type":"text","marks":[{"type":"strong"}]},{"text":" -- check parse-args.sh output for error details.","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Route to Mode","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Parsed MODE","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Go to","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"generate","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 1","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"edit","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase 1","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"config","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase C","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"update","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Phase U","type":"text"}]}]}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 1: Validate and Gather","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Load Environment and Check API Key","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"[ -f .env ] && set -a && . .env && set +a; bash \"${CLAUDE_SKILL_DIR}/scripts/validate-key.sh\" \"SERVICE_HERE\" && echo \"OK\" || echo \"FAILED\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Replace ","type":"text"},{"text":"SERVICE_HERE","type":"text","marks":[{"type":"code_inline"}]},{"text":" with the resolved SERVICE value.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"If FAILED (INVALID):","type":"text","marks":[{"type":"strong"}]},{"text":" Redirect to Phase C (config mode). Tell the user: \"No valid API key found for {SERVICE}. Let's configure it.\"","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Gather Missing Parameters","type":"text"}]},{"type":"paragraph","content":[{"text":"If MODE=generate and PROMPT_MISSING=true:","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"What image do you need? Describe the scene, subject, and mood.","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Describe your image (e.g., 'a cozy coffee shop at sunset with warm lighting')\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Cancel\"","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Store response as PROMPT.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"FAST PATH CHECK:","type":"text","marks":[{"type":"strong"}]},{"text":" If PROMPT is provided (not missing) AND no explicit --service/--style/--count/--output flags were given: → Skip Steps 3-6 entirely. Use defaults (count=1, service=gemini, style=photo, output=.claude/reports/images/). → Jump to Step 7 (config table). This is the 99% path — user just wants an image from their prompt.","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3: Confirm Image Count (skip on fast path)","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"How many images to generate?","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"1 (default, fastest)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"2-3 (compare variations)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"4+ (batch generation, up to 10)\"","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Update COUNT with the number. Default: 1.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"Provider limit:","type":"text","marks":[{"type":"strong"}]},{"text":" DALL-E 3 supports only 1 image per request. If SERVICE=openai and COUNT>1, generate COUNT sequential requests.","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4: Confirm Service (skip on fast path)","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Which image generation service?\n\n| Service | Model | Speed | Quality | Cost |\n|---------|-------|-------|---------|------|\n| openrouter | Gemini 2.5 Flash Image | Fast | High | ~$0.001/image |\n| zai | GLM-image | Fast | **Very High** | ~$0.015/image |\n| gemini | Imagen 4 | Fast | Very High | Paid plan required |\n| openrouter-gpt5 | GPT-5 Image | Medium | **Highest** | ~$0.01/image |\n| openai | DALL-E 3 | Medium | High | $0.04-0.12/image |","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"openrouter (Gemini 2.5 Flash -- cheapest, default)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"zai (GLM-image -- flagship Z.ai, high quality)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"gemini (Imagen 4 -- high quality, paid plan)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"openrouter-gpt5 (GPT-5 Image -- highest quality, ~$0.01/img)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"openai (DALL-E 3 -- reliable, most expensive)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Keep current: {SERVICE}\"","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Update SERVICE if changed. Re-validate key if service changed.","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 5: Confirm Style (skip on fast path)","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Image style? This controls anti-slop prompt engineering.\n\n- photo: Physically accurate photography -- real lighting, correct anatomy, natural materials\n- illustration: Professional illustration -- clean line work, proper color theory, organic imperfections\n- art: Consistent artistic medium -- unified brushwork, intentional composition, coherent color temperature","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"photo (realistic photography)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"illustration (clean vector/drawn style)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"art (painterly/artistic medium)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Keep current: {STYLE}\"","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 6: Confirm Output Directory (skip on fast path)","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Where to save generated images?","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\".claude/reports/images/ (default)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Current directory (.)\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Custom path (type your preferred directory)\"","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Update OUTPUT with chosen path.","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 7: Display Resolved Configuration (MANDATORY)","type":"text"}]},{"type":"paragraph","content":[{"text":"Output this table before proceeding. Do NOT skip this step.","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"=== Image Generation Config ===\n| Parameter | Value |\n|-----------|-------|\n| Prompt | {PROMPT (first 80 chars)}... |\n| Service | {SERVICE} ({model name}) |\n| Style | {STYLE} |\n| Count | {COUNT} |\n| Size | {SIZE} |\n| Output | {OUTPUT} |\n| API Key | {first 8 chars}...{last 4 chars} |\n| Est. Cost | {estimate based on service and count} |\n================================","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 8: Final Confirmation","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Proceed with generation?","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Yes, generate\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"No, change settings\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Cancel\"","type":"text"}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"If \"change settings\" -> go back to Step 4. If \"Cancel\" -> STOP with message \"Image generation cancelled.\"","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 2: Build Payload and Generate","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Load Anti-Slop Instructions","type":"text"}]},{"type":"paragraph","content":[{"text":"Read the anti-slop reference for the resolved STYLE: Read file: ","type":"text"},{"text":"${CLAUDE_SKILL_DIR}/references/anti-slop.md","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"paragraph","content":[{"text":"Extract the section matching STYLE (photo, illustration, or art). Store as ANTI_SLOP_PREFIX.","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Build Enhanced Prompt","type":"text"}]},{"type":"paragraph","content":[{"text":"Combine anti-slop prefix with user prompt:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"ENHANCED_PROMPT = ANTI_SLOP_PREFIX + \"\\n\\n\" + PROMPT","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3: Load Provider Specs","type":"text"}]},{"type":"paragraph","content":[{"text":"Read file: ","type":"text"},{"text":"${CLAUDE_SKILL_DIR}/references/providers.md","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"paragraph","content":[{"text":"Use the section for resolved SERVICE to build the correct JSON payload.","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4: Build and Write Payload","type":"text"}]},{"type":"paragraph","content":[{"text":"Construct JSON payload using the exact format from ","type":"text"},{"text":"references/providers.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for the resolved SERVICE. Insert ENHANCED_PROMPT, COUNT, SIZE (mapped to provider format).","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"cat > /tmp/image-gen-payload.json \u003c\u003c 'PAYLOAD_EOF'\n{JSON_PAYLOAD_HERE}\nPAYLOAD_EOF\njq empty /tmp/image-gen-payload.json && echo \"PAYLOAD_VALID\" || echo \"PAYLOAD_INVALID\"","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"STOP if PAYLOAD_INVALID","type":"text","marks":[{"type":"strong"}]},{"text":" -- fix JSON and retry.","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 5: Send API Request","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"[ -f .env ] && set -a && . .env && set +a; bash \"${CLAUDE_SKILL_DIR}/scripts/api-request.sh\" /tmp/image-gen-payload.json /tmp/image-gen-response.json \"SERVICE_HERE\" && echo \"API_OK\" || echo \"API_FAILED\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Replace ","type":"text"},{"text":"SERVICE_HERE","type":"text","marks":[{"type":"code_inline"}]},{"text":" with resolved SERVICE.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"If API_FAILED:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Check /tmp/image-gen-response.json for error details","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Rate limit (429) -> wait 30s, retry once","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Content policy violation -> inform user, suggest rephrasing prompt","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Auth error (401/403) -> redirect to Phase C","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Other errors -> show error, offer retry or cancel","type":"text"}]}]}]}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"For openai with COUNT>1:","type":"text","marks":[{"type":"strong"}]},{"text":" Loop COUNT times, incrementing version in output filename. Each request generates 1 image (DALL-E 3 limitation).","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 6: Parse Response","type":"text"}]},{"type":"paragraph","content":[{"text":"Parse /tmp/image-gen-response.json per provider format:","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Service","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Image location in response","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Format","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"gemini","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"predictions[].bytesBase64Encoded","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"base64 PNG","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openrouter","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"data[].url","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"URL to download","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openai","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"data[].url","type":"text","marks":[{"type":"code_inline"}]},{"text":" or ","type":"text"},{"text":"data[].b64_json","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"URL or base64","type":"text"}]}]}]}]},{"type":"paragraph","content":[{"text":"For base64 responses (gemini), extract each prediction and save to temp file:","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"jq -r '.predictions[INDEX].bytesBase64Encoded' /tmp/image-gen-response.json > /tmp/image-gen-b64-INDEX.txt","type":"text"}]},{"type":"paragraph","content":[{"text":"For URL responses (openrouter, openai), collect URLs for save-image.sh.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 2E: Build Edit Payload (edit mode only)","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Validate and Load","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"EDIT_IMG=\"EDIT_IMAGE_PATH_HERE\"\n[ -f \"$EDIT_IMG\" ] && file --mime-type \"$EDIT_IMG\" | grep -qE ': image/' && echo \"VALID_IMAGE\" || echo \"INVALID\"","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"If INVALID -> AskUserQuestion for correct path or cancel.","type":"text"}]}]},{"type":"paragraph","content":[{"text":"Read file: ","type":"text"},{"text":"${CLAUDE_SKILL_DIR}/references/mode-edit.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for provider-specific edit payloads and endpoints.","type":"text"}]},{"type":"paragraph","content":[{"text":"Edit support: gemini (Yes), openrouter (No -- redirect user), openai (Yes via dall-e-2).","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Build and Send","type":"text"}]},{"type":"paragraph","content":[{"text":"Construct edit payload per ","type":"text"},{"text":"references/mode-edit.md","type":"text","marks":[{"type":"code_inline"}]},{"text":". Same API call pattern as Phase 2 Step 5.","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 3: Save Images","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Generate Title","type":"text"}]},{"type":"paragraph","content":[{"text":"Create kebab-case title from PROMPT (max 30 chars). Example: \"a cozy coffee shop at sunset\" -> \"cozy-coffee-shop-sunset\"","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Save Each Image","type":"text"}]},{"type":"paragraph","content":[{"text":"For each image in the response:","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"bash \"${CLAUDE_SKILL_DIR}/scripts/save-image.sh\" \"SOURCE_HERE\" \"OUTPUT_DIR\" \"TITLE\" \"SERVICE\" \"PROMPT\" \"STYLE\" \"SIZE\" && echo \"SAVE_OK\" || echo \"SAVE_FAILED\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Replace placeholders:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"SOURCE_HERE","type":"text","marks":[{"type":"code_inline"}]},{"text":": URL or temp file path from Phase 2 Step 6","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"OUTPUT_DIR","type":"text","marks":[{"type":"code_inline"}]},{"text":": resolved OUTPUT","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"TITLE","type":"text","marks":[{"type":"code_inline"}]},{"text":": generated title","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"SERVICE","type":"text","marks":[{"type":"code_inline"}]},{"text":": resolved SERVICE","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"PROMPT","type":"text","marks":[{"type":"code_inline"}]},{"text":": original user PROMPT (not enhanced)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"STYLE","type":"text","marks":[{"type":"code_inline"}]},{"text":": resolved STYLE","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"SIZE","type":"text","marks":[{"type":"code_inline"}]},{"text":": resolved SIZE","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Collect all saved file paths from stdout.","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"STOP if SAVE_FAILED","type":"text","marks":[{"type":"strong"}]},{"text":" -- check stderr for details, offer retry.","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase 4: Report","type":"text"}]},{"type":"paragraph","content":[{"text":"Display table: file paths, sidecar JSON paths, provider, style, size, prompt (truncated), estimated cost.","type":"text"}]},{"type":"paragraph","content":[{"text":"Cost per image: gemini ~$0.02 (free tier), openrouter ~$0.04, openai $0.04-0.12 (size/quality dependent).","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion: \"What next?\" Options: \"Generate more (same settings)\", \"Different prompt\", \"Edit one of these images\", \"Done\"","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"\"Generate more\" -> Phase 2. \"Different prompt\" -> Phase 1 Step 2. \"Edit\" -> edit mode. \"Done\" -> STOP.","type":"text"}]}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase C: Config Mode","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Select Service","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion: \"Which service to configure?\" Options: \"openrouter (Gemini 2.5 Flash)\", \"zai (GLM-image)\", \"gemini (Imagen 4)\", \"openrouter-gpt5 (GPT-5 Image)\", \"openai (DALL-E 3)\", \"All services\"","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Get API Key","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion: \"Enter your API key for {service}:\" Show key URLs: Gemini ","type":"text"},{"text":"https://aistudio.google.com/apikey","type":"text","marks":[{"type":"code_inline"}]},{"text":", OpenRouter ","type":"text"},{"text":"https://openrouter.ai/keys","type":"text","marks":[{"type":"code_inline"}]},{"text":", OpenAI ","type":"text"},{"text":"https://platform.openai.com/api-keys","type":"text","marks":[{"type":"code_inline"}]},{"text":" Options: \"Paste your API key\", \"Skip this service\"","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3: Validate Key","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"export SERVICE_KEY_HERE=\"USER_KEY_HERE\"; bash \"${CLAUDE_SKILL_DIR}/scripts/validate-key.sh\" \"SERVICE_HERE\" && echo \"KEY_VALID\" || echo \"KEY_INVALID\"","type":"text"}]},{"type":"blockquote","content":[{"type":"paragraph","content":[{"text":"If KEY_INVALID -> show error, offer re-enter or skip.","type":"text"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4: Choose Storage and Save","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion: \"Where to save?\" Options: \".env in project root (default)\", \"~/.zshrc (system-wide)\", \".claude.local.md (project-level)\"","type":"text"}]},{"type":"paragraph","content":[{"text":"Save key to chosen location. For ","type":"text"},{"text":".env","type":"text","marks":[{"type":"code_inline"}]},{"text":": also ensure ","type":"text"},{"text":".env","type":"text","marks":[{"type":"code_inline"}]},{"text":" is in ","type":"text"},{"text":".gitignore","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 5: Verify","type":"text"}]},{"type":"paragraph","content":[{"text":"EXECUTE","type":"text","marks":[{"type":"strong"}]},{"text":" using Bash tool:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"[ -f .env ] && set -a && . .env && set +a; bash \"${CLAUDE_SKILL_DIR}/scripts/validate-key.sh\" \"SERVICE_HERE\" && echo \"CONFIG_OK\" || echo \"CONFIG_FAILED\"","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Phase U: Update Mode","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 1: Research Latest API Changes","type":"text"}]},{"type":"paragraph","content":[{"text":"Use WebSearch to check each provider's current API documentation:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Gemini Imagen: search \"Google Gemini Imagen API latest models 2026\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"OpenRouter image generation: search \"OpenRouter image generation API models 2026\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"OpenAI DALL-E: search \"OpenAI DALL-E API latest models pricing 2026\"","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 2: Load Current Reference","type":"text"}]},{"type":"paragraph","content":[{"text":"Read file: ","type":"text"},{"text":"${CLAUDE_SKILL_DIR}/references/providers.md","type":"text","marks":[{"type":"code_inline"}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 3: Compare and Report","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Provider","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Current Model","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Latest Model","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Pricing Change","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Breaking Changes","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"gemini","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{current}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{latest}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{yes/no}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{details}","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openrouter","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{current}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{latest}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{yes/no}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{details}","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openai","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{current}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{latest}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{yes/no}","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"{details}","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Step 4: Offer Update","type":"text"}]},{"type":"paragraph","content":[{"text":"If changes found:","type":"text"}]},{"type":"paragraph","content":[{"text":"ASK","type":"text","marks":[{"type":"strong"}]},{"text":" using AskUserQuestion:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Changes detected in provider APIs. Update references/providers.md?","type":"text"}]},{"type":"paragraph","content":[{"text":"Options:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Yes, update providers.md\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Show details first\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"No, keep current\"","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"If \"Yes\" -> update ","type":"text"},{"text":"${CLAUDE_SKILL_DIR}/references/providers.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" with new information.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"\u003c/instructions>","type":"text"}]}]},"metadata":{"date":"2026-06-05","name":"brewui:image-gen","model":"haiku","author":"@skillopedia","source":{"stars":27,"repo_name":"claude-brewcode","origin_url":"https://github.com/kochetkov-ma/claude-brewcode/blob/HEAD/brewui/skills/image-gen/SKILL.md","repo_owner":"kochetkov-ma","body_sha256":"8b2b4e2f402a7ecf17f9c86334478c4d861b3ef82ca8c3d18032755b1966e8d2","cluster_key":"fa8a844ccccf03245fc8205b237781f33560b9da0a7860156798a4461339164f","clean_bundle":{"format":"clean-skill-bundle-v1","source":"kochetkov-ma/claude-brewcode/brewui/skills/image-gen/SKILL.md","attachments":[{"id":"8079513a-2240-5ec2-9c45-65c1ad511e78","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/8079513a-2240-5ec2-9c45-65c1ad511e78/attachment.md","path":"references/anti-slop.md","size":4252,"sha256":"a8cda8b5006b4daf20754137cb48bebd9e4cf4ae0e92fff95e866a44443900b8","contentType":"text/markdown; charset=utf-8"},{"id":"9490bc7b-2a2d-5b05-bbad-67cca73ba9a5","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/9490bc7b-2a2d-5b05-bbad-67cca73ba9a5/attachment.md","path":"references/mode-edit.md","size":2936,"sha256":"cf1b017d797547c38a73c58d63d1c67236b74b9dc4569ed84983aed8cebc015d","contentType":"text/markdown; charset=utf-8"},{"id":"1beddcf6-5951-5b0c-897a-2b8c6573ad39","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/1beddcf6-5951-5b0c-897a-2b8c6573ad39/attachment.md","path":"references/mode-generate.md","size":2855,"sha256":"7ab4bca82c01f0e715cd0fd8c12e2253fb9b471f9adc06935b97b6a3320d0bc5","contentType":"text/markdown; charset=utf-8"},{"id":"0d091bcb-f863-55ac-8fdc-a5c1884f7727","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/0d091bcb-f863-55ac-8fdc-a5c1884f7727/attachment.md","path":"references/mode-update.md","size":12007,"sha256":"d681479d74bb4d5b02660d95431e5cee6df691284cd414f609efb156cbcc1e76","contentType":"text/markdown; charset=utf-8"},{"id":"df66eb00-d571-5402-8489-04e785f0133b","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/df66eb00-d571-5402-8489-04e785f0133b/attachment.md","path":"references/prompt-guide.md","size":3899,"sha256":"7e93450029a6cf1cec2c78a7f7fa53a4f1201e87f2c33a7256e0cbebdc47c456","contentType":"text/markdown; charset=utf-8"},{"id":"dbdf56fd-9e7d-5542-bb7c-de61821ad9ee","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/dbdf56fd-9e7d-5542-bb7c-de61821ad9ee/attachment.md","path":"references/providers.md","size":5598,"sha256":"2d82c26495a5094e7976ef04ba40ae5bf69053e763acc99b58ddecdab62e22f4","contentType":"text/markdown; charset=utf-8"},{"id":"e0097c34-2761-5481-9971-af7af238251a","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/e0097c34-2761-5481-9971-af7af238251a/attachment.sh","path":"scripts/api-request.sh","size":3819,"sha256":"e880969c2242d3f9fc794efe01ffd726ae671634bb13bbf2af01d6ce3cc4de27","contentType":"application/x-sh; charset=utf-8"},{"id":"b21a59ce-30e9-5360-ac81-4189bb4ea33c","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/b21a59ce-30e9-5360-ac81-4189bb4ea33c/attachment.sh","path":"scripts/parse-args.sh","size":2882,"sha256":"8283bb8b74be19db610152a0f3d416621335b9507d4c983c124df90e6caeb701","contentType":"application/x-sh; charset=utf-8"},{"id":"2441cb00-bb78-569d-8ba8-4a8fbd4fb619","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/2441cb00-bb78-569d-8ba8-4a8fbd4fb619/attachment.sh","path":"scripts/save-image.sh","size":3594,"sha256":"41713f24827c9f26ff54c17cf9c4e5199c910920fee92d76e12cb000e7c4b6c9","contentType":"application/x-sh; charset=utf-8"},{"id":"3bc064a6-e89c-5642-b068-e39e28b364ea","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/3bc064a6-e89c-5642-b068-e39e28b364ea/attachment.sh","path":"scripts/validate-key.sh","size":2771,"sha256":"af3079fcb5a4c8f83127945026307a774a53cefa88d82765ac4c5062939ebc9f","contentType":"application/x-sh; charset=utf-8"},{"id":"adbfe46f-647a-5d41-b0f0-7832564ab82f","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/adbfe46f-647a-5d41-b0f0-7832564ab82f/attachment.md","path":"tests/test-generate-flow.md","size":4168,"sha256":"32b32dfc8bf92ff44006cc714a7c773142981033469f21c0fde3a1b88a31dfb0","contentType":"text/markdown; charset=utf-8"},{"id":"8b027c5a-13e0-5ef5-82a9-f67bd9a42ba1","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/8b027c5a-13e0-5ef5-82a9-f67bd9a42ba1/attachment.sh","path":"tests/test-parse-args.sh","size":4124,"sha256":"11ce4b8a94c72d9e5bc3f518d06c03e0d179e0846a5e7bbe0b4b047d1ca275e4","contentType":"application/x-sh; charset=utf-8"},{"id":"793e79f6-f5f5-543f-ad35-99b8db2c6a0f","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/793e79f6-f5f5-543f-ad35-99b8db2c6a0f/attachment.sh","path":"tests/test-save-image.sh","size":5365,"sha256":"0be1096857d9095a37897bbf7ecabdd4ef4d8af3b40363b9d4272ef62dddc26c","contentType":"application/x-sh; charset=utf-8"}],"bundle_sha256":"663e4aeffd3676e993a88594d21394616ebee10b14f2d8c5f57da3e261a2ff5c","attachment_count":13,"text_attachments":13,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":1,"skill_md_path":"brewui/skills/image-gen/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"web-development","category_label":"Web"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"web-development","import_tag":"clean-skills-v1","description":"Generates AI images via OpenRouter (Gemini/GPT-5), Z.ai GLM-image, Google Imagen 4, or OpenAI DALL-E 3 with anti-AI-slop controls. Modes: generate, edit, config, update. Triggers: generate image, create image, AI image, og image, blog image, illustration.","allowed-tools":["Read","Write","Edit","Bash","Glob","Grep","AskUserQuestion","WebSearch"],"argument-hint":"[prompt] [--edit image.png 'instructions'] [--config] [--update] [--service gemini|openrouter|openai] [--style photo|illustration|art] [--count N] [--output dir] [--size WxH]","user-invocable":true}},"renderedAt":1782980622175}

<instructions Image Gen Generates AI images via Gemini Imagen 4, OpenRouter (Gemini 2.5 Flash Image / GPT-5-image), Z.ai GLM-image, or OpenAI DALL-E 3. Applies anti-AI-slop prompt prefixes per style. Four modes: generate, edit, config, update. Arguments: Mode Routing | Mode | Flow | |------|------| | generate | Phase 0 - 1 - 2 - 3 - 4 | | edit | Phase 0 - 1 - 2E - 3 - 4 | | config | Phase 0 - C | | update | Phase 0 - U | CONTEXT-AWARE MODE DETECTION (CRITICAL): Mode is detected from BOTH explicit flags AND natural language context. Priority: 1. Explicit flags: , , - override everything 2. Con…