# banana-claws

Adopt this skill: https://proskills.md/skills/other/ironystock-banana-claws-skill

Page: https://proskills.md/skills/other/ironystock-banana-claws-skill
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skill/SKILL.md
size: 7025
upstream: https://github.com/ironystock/banana-claws/blob/main/skill/SKILL.md

````text
---
name: banana-claws
description: Generate images via OpenRouter API (text-to-image) with automation-ready local scripts and a queue-first workflow. Use for single images or batched variants (posters, thumbnails, illustrations, concept art), especially when agents must acknowledge quickly, process asynchronously, and return consolidated file attachments with structured success/failure records.
homepage: https://github.com/ironystock/banana-claws
user-invocable: true
metadata: {"openclaw":{"emoji":"🍌","primaryEnv":"OPENROUTER_API_KEY","requires":{"bins":["python3"],"env":["OPENROUTER_API_KEY"]}}}
---

# OpenRouter Image Generation

Generate images from prompts using OpenRouter's image generation endpoint.

## Requirements

- `OPENROUTER_API_KEY` in environment
- `python3`
- Python package: `requests`

Install dependency:

```bash
python3 -m pip install requests
```

## FTUX preflight (run first)

```bash
python3 {baseDir}/scripts/preflight_check.py
python3 {baseDir}/scripts/preflight_check.py --json
```

If checks fail, tell the user exactly what is missing and provide copy/paste fix steps from the `Fixups` output.

## Default model

- `google/gemini-3.1-flash-image-preview`
- Optional alternatives (if enabled on your account): `openai/gpt-5-image`, `openai/gpt-5-image-mini`

## Usage

```bash
python3 {baseDir}/scripts/generate_image.py \
  --prompt "A cinematic portrait of a cyberpunk crab" \
  --model google/gemini-3.1-flash-image-preview \
  --image-size low \
  --out ./generated/cyber-crab.png
```

Optional args:

```bash
--model openai/gpt-5-image
--model openai/gpt-5-image-mini
--image-size low|medium|high
--clarify-hints      # print prompt-quality hints to stderr
--strict-clarify     # fail fast when prompt appears underspecified
--baseline-image ./path/to/reference.png
--baseline-source-kind current_attachment|reply_attachment|explicit_path_or_url
--confirm-external-upload # required for local baseline file upload
--variation-strength low|medium|high
--must-keep "title placement"
--must-keep "logo mark"
--lock-palette
--lock-composition
--allow-no-baseline-on-edit-intent
```

## Queue -> response pattern (avoid traffic jams)

When a user asks for multiple images/iterations, do **not** hold one long-running turn per image.
Do not block waiting for a "single message with all files" if the adapter does not support it.

**Hard contract for queue mode:**
- NEVER run `run_image_queue.py` in the same foreground turn as enqueue for multi-image requests.
- ALWAYS enqueue + immediate queued ack first, then background handoff.

Use a queue + batched response flow:

1. Enqueue each requested image quickly.
2. **Immediately return** with a short "queued" acknowledgement (do not wait for generation in the same turn).
3. Drain queue in background (preferred: sub-agent/session worker).
4. Send one consolidated completion status response when done.
5. **Always attach generated image files** (never send only paths).
6. If the messaging adapter allows only one media per send, post attachments as reply-chain messages under the consolidated completion status message (one file per message).

Enqueue command:

```bash
python3 {baseDir}/scripts/enqueue_image_job.py \
  --prompt "A retro 80s crab poster" \
  --model google/gemini-3.1-flash-image-preview \
  --image-size low \
  --clarify-hints \
  --out ./generated/crab-01.png \
  --request-id "discord-<message-id>"
```

Background queue handoff (recommended):

```bash
python3 {baseDir}/scripts/queue_and_return.py \
  --prompt "A minimalist snow crab logo" \
  --count 4 \
  --request-id "discord-<message-id>" \
  --out-dir ./generated \
  --prefix crab-logo \
  --queue-dir ./generated/imagegen-queue
```

Manual drain command (worker context only; not same foreground turn):

```bash
python3 {baseDir}/scripts/run_image_queue.py \
  --queue-dir ./generated/imagegen-queue

# queue_and_return guardrails (optional tuning)
python3 {baseDir}/scripts/queue_and_return.py \
  --max-background-workers 2 \
  --orphan-timeout-sec 1800 \
  ...
```

Batch-enqueue N variants with consistent file names:

```bash
python3 {baseDir}/scripts/enqueue_variants.py \
  --prompt "A minimalist snow crab logo" \
  --count 4 \
  --baseline-image ./generated/base-logo.png \
  --variation-strength low \
  --lock-palette \
  --lock-composition \
  --must-keep "wordmark placement" \
  --must-keep "icon silhouette" \
  --out-dir ./generated \
  --prefix crab-logo \
  --request-id "discord-<message-id>"
```

Useful options:

```bash
--max-jobs 3   # process only a subset for controlled batches
--start-index 5  # continue naming from prior batches
```

## Data transmission notice (external provider)

- This skill sends prompts and generated/edit inputs to OpenRouter (`openrouter.ai`).
- If you pass `--baseline-image`, that image content is transmitted to the provider as part of the request.
- Do not submit sensitive/private images unless the user explicitly approves external transmission.

## Notes

- If generation fails due to model/provider mismatch, retry with `--model openai/gpt-5-image-mini`.
- Local baseline uploads are deny-by-default; pass `--confirm-external-upload` only when user explicitly approves sending that local file to provider.
- Local baseline files are restricted to png/jpg/jpeg/webp, non-symlink regular files, workspace-local paths, and max size threshold.
- For iterative work, prefer `--image-size low`; switch to `medium` or `high` for final renders.
- Use `--clarify-hints` to surface prompt-quality gaps early; use `--strict-clarify` for workflows that must fail on ambiguity.
- Keep prompts explicit for text rendering tasks.
- Save outputs into workspace paths, not `/tmp`, for durability.
- When user asks for generated images in chat, attach the generated file in the response (do not only send a path).
- For queue mode, read results from:
  - `.../imagegen-queue/results/*.json` (success)
  - `.../imagegen-queue/failed/*.json` (failure details)
- Edit/variant intent prompts fail fast if no baseline is supplied (`--baseline-image`) unless explicitly overridden.
- Resolve baseline deterministically in caller: current-message attachment > replied-message attachment > clarification request.
- Pass `--baseline-source-kind current_attachment|reply_attachment|explicit_path_or_url` for auditable provenance.
- When baseline is supplied, rails default to low-variation + locked palette/composition unless explicitly changed.
- Queue results persist provider metadata (generation id + provider response payload/path) and drift diagnostics (`edit_intent_detected`, `baseline_applied`, `baseline_source`, `baseline_source_kind`, `baseline_resolution_policy`, `rails_applied`) to help edits/debugging and smarter agent continuation.
- Queue worker writes `handoff_mode` + `same_turn_drain_detected` so you can enforce true async behavior in tests/ops.
- `enqueue_variants.py` writes `<prefix>-manifest.json` with baseline, constraints, variant deltas, and output targets for reproducible reruns.
````

## File: README.md
upstream: https://github.com/ironystock/banana-claws/blob/main/README.md

````text
# banana-claws

[![CI](https://github.com/ironystock/banana-claws/actions/workflows/ci.yml/badge.svg)](https://github.com/ironystock/banana-claws/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/ironystock/banana-claws?sort=semver)](https://github.com/ironystock/banana-claws/releases)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](./LICENSE)
[![Issues](https://img.shields.io/github/issues/ironystock/banana-claws)](https://github.com/ironystock/banana-claws/issues)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)

`banana-claws` is a public OpenClaw skill and script toolkit for OpenRouter image generation, designed for both autonomous agents and human builders. It supports fast single-image generation, queue-first batch workflows, and machine-readable result artifacts so orchestration systems can acknowledge quickly, process in background, and return consolidated attached outputs.

## Fast install (copy/paste for agents)

If you are instructing another OpenClaw agent, use this instruction block verbatim:

```text
Install the OpenClaw skill `banana-claws` from:
https://github.com/ironystock/banana-claws

Steps:
1) Clone repo
2) Copy `skill/` contents into ~/.openclaw/workspace/skills/banana-claws/
3) Ensure OPENROUTER_API_KEY is set in runtime env
4) Restart/reload agent runtime so skills are re-indexed
5) Verify skill discovery, then run a queue-mode smoke test with attached outputs
```

Recommended smoke-test prompt for the agent:

```text
Use banana-claws to generate 2 variants of "neon cyberpunk crab logo" in queue mode.
Acknowledge queued immediately, then return a consolidated completion status and attach outputs.
```

## Best install path for external agents

- **Preferred:** install from GitHub repo source (`skill/` directory), not from release zip.
- **Why:** agents reliably understand repo URL + folder copy instructions; zip handling varies across runtimes/tools.
- **If using release zip anyway:** extract it first, then manually copy `skill/` into the OpenClaw skills directory.

## What this includes

- `skill/SKILL.md` — skill instructions + queue/response pattern
- `skill/scripts/generate_image.py` — single image generation
- `skill/scripts/enqueue_image_job.py` — enqueue one job
- `skill/scripts/enqueue_variants.py` — enqueue N variants with consistent naming
- `skill/scripts/run_image_queue.py` — drain queue and write success/failure job records
- `skill/scripts/queue_and_return.py` — enqueue + immediate return + background worker handoff (with worker cap + orphan cleanup)
- `skill/scripts/summarize_request.py` — summarize request completion/attachments for push reporting
- `skill/scripts/preflight_check.py` — first-run diagnostics + copy/paste fixups

## Requirements

- Python 3.9+
- `OPENROUTER_API_KEY` environment variable
- Python package `requests`
- Internet access to `https://openrouter.ai`

Install Python dependency:

```bash
python3 -m pip install requests
# or: pip install -r requirements.txt
```

## Quick start

### 0) First-time setup check (FTUX)

```bash
python3 skill/scripts/preflight_check.py
python3 skill/scripts/preflight_check.py --json
```

Generate one image:

```bash
python3 skill/scripts/generate_image.py \
  --prompt "A cinematic portrait of a cyberpunk crab" \
  --model google/gemini-3.1-flash-image-preview \
  --image-size low \
  --clarify-hints \
  --out ./generated/cyber-crab.png
```

Queue 4 variants with async handoff (recommended):

```bash
python3 skill/scripts/queue_and_return.py \
  --prompt "YouTube thumbnail: Snowcrab AI — Queue Mode Test, neon cyberpunk" \
  --count 4 \
  --baseline-image ./generated/base-thumbnail.png \
  --baseline-source-kind explicit_path_or_url \
  --confirm-external-upload \
  --variation-strength low \
  --lock-palette \
  --lock-composition \
  --must-keep "title placement" \
  --must-keep "logo region" \
  --image-size low \
  --clarify-hints \
  --out-dir ./generated \
  --prefix snowcrab-queue-test \
  --request-id "discord-<message-id>" \
  --queue-dir ./generated/imagegen-queue
```

Manual worker drain (worker context only):

```bash
python3 skill/scripts/run_image_queue.py --queue-dir ./generated/imagegen-queue --request-id "discord-<message-id>" --handoff-mode background
```

Background hardening knobs:

```bash
python3 skill/scripts/queue_and_return.py ... \
  --max-background-workers 2 \
  --orphan-timeout-sec 1800
```

### Iteration vs final quality

- Use `--image-size low` for fast/low-cost exploratory passes.
- Use `--image-size medium` or `--image-size high` for final-quality outputs.

### Prompt clarity hints

- Add `--clarify-hints` to print actionable prompt-quality hints (style, size/format, exact text, composition constraints).
- Add `--strict-clarify` to fail early when prompt appears underspecified.

### Provider data handling note (deny-by-default)

- Requests are sent to OpenRouter for generation/edit processing.
- When using baseline/edit flags (for example `--baseline-image`), that input image is transmitted to the provider.
- Local baseline uploads are blocked unless `--confirm-external-upload` is explicitly set.
- Only use images that the user has explicitly approved for external processing.

### Baseline-locked variants (on-rails)

- Use `--baseline-image` for true image-to-image varianting.
- Resolve baseline deterministically in caller: **current-message attachment > replied-message attachment > clarification request**.
- Record baseline provenance with `--baseline-source-kind current_attachment|reply_attachment|explicit_path_or_url`.
- Edit/variant intent prompts fail fast when no baseline is provided (override only with `--allow-no-baseline-on-edit-intent`).
- Default rails are auto-applied when baseline is present: `variation-strength=low`, `lock-palette`, `lock-composition`.
- Use `--variation-strength low|medium|high` to control divergence from baseline.
- Use repeatable `--must-keep` constraints for consistency.
- `enqueue_variants.py` writes a `<prefix>-manifest.json` file for reproducible reruns/debugging.

## Queue/result contract

- Pending jobs: `generated/imagegen-queue/pending/*.json`
- Success records: `generated/imagegen-queue/results/*.json`
- Failure records: `generated/imagegen-queue/failed/*.json`

Each result/failed record includes `request_id`, `out`, `exit_code`, stdout/stderr, and persisted provider metadata (including top-level generation id and provider response payload/path) for orchestration and edit/debug workflows.

Drift diagnostics are also persisted per job (`edit_intent_detected`, `baseline_applied`, `baseline_source`, `baseline_source_kind`, `baseline_resolution_policy`, `rails_applied`, `clarify_hints`) so agents can prove whether baseline rails were actually used.

Messaging behavior note:
- For multi-image requests, send an immediate queued ack, then a consolidated completion status update.
- **Do not run queue drain in the same foreground turn** for multi-image requests.
- Always attach generated files (never path-only).
- If your message adapter only supports one attachment per send, post file attachments as replies under the completion status message.

## Install & use in OpenClaw (GitHub)

### 1) Clone the repo

```bash
git clone https://github.com/ironystock/banana-claws.git
cd banana-claws
```

### 2) Place the skill where OpenClaw can discover it

Copy the `skill/` folder into your OpenClaw skills workspace (example shown below):

```bash
mkdir -p ~/.openclaw/workspace/skills/banana-claws
cp -R skill/* ~/.openclaw/workspace/skills/banana-claws/
```

### 3) Set required environment variable

```bash
export OPENROUTER_API_KEY="your_openrouter_api_key"
```

### 4) Refresh/restart agent runtime so skills are re-indexed

If the running agent session does not see the skill yet, restart/reload your OpenClaw runtime/session and verify the new skill is discoverable.

### 5) Prompt examples that should trigger this 
````
