$npx -y skills add neuromechanist/research-skills --skill transparent-iconsThis skill should be used when the user asks to "make an icon", "generate an icon", "create a scientific icon", "make a transparent icon", "make a minimal icon", "icon for a figure", "icon for a paper", "generate an icon set", "batch icons", "icon batch", "batch generate icons",
| 1 | # Transparent Icons |
| 2 | |
| 3 | Generate flat scientific icons (Nature/Science journal style) with transparent backgrounds. Used as panel elements by the `[[scientific-figure]]` composer or as standalone graphics for posters, presentations, and grants. |
| 4 | |
| 5 | ## Backends |
| 6 | |
| 7 | Two generation backends, auto-selected: |
| 8 | |
| 9 | 1. **Codex CLI `image_gen` tool** (preferred). Uses the local Codex authentication (`~/.codex/auth.json`). No `OPENAI_API_KEY` required. Internally uses gpt-image-2 (April 2026). Default when `codex` is on `$PATH` and authenticated. |
| 10 | 2. **OpenAI Images API** (fallback). Calls `client.images.generate(model="gpt-image-2", ...)` directly. Requires `OPENAI_API_KEY` in environment or `.env`. |
| 11 | |
| 12 | Why two backends: many researchers have a ChatGPT subscription and `codex login` but no separate API key. Auto-selection routes through Codex first to keep the no-API-key path working; explicit `--backend codex` or `--backend api` overrides. |
| 13 | |
| 14 | ## Transparency |
| 15 | |
| 16 | `gpt-image-2` (April 2026) does **not** accept `background="transparent"` — both backends always generate opaque PNGs. Transparency is applied as a post-process. Two methods: |
| 17 | |
| 18 | - **`threshold`** (default) — drop near-white pixels via Pillow. Fast, no extra deps. Works well for flat 2-color icons on a clean white background. Can leave fringes on anti-aliased edges and may erase highlights where the foreground itself is near-white. |
| 19 | - **`birefnet`** (opt-in) — `rembg` + BiRefNet ONNX model with alpha matting. Cleaner edges, handles complex foregrounds. One-time ~400 MB model download on first run; requires extra deps (`rembg`, `onnxruntime`). |
| 20 | |
| 21 | Pick `threshold` for the canonical flat-icon use case. Pick `birefnet` when the icon contains light-colored content (white parts of a brain MRI, light reflections on glass) that the threshold method would erase, or when the icon will be composited at large sizes where fringes are visible. |
| 22 | |
| 23 | ## Usage |
| 24 | |
| 25 | Free-form prompt: |
| 26 | |
| 27 | ```bash |
| 28 | uv run --with openai --with python-dotenv --with pillow python scripts/generate_icon.py \ |
| 29 | "a human brain with EEG electrodes" -o brain_eeg.png --transparent |
| 30 | ``` |
| 31 | |
| 32 | From the icon bible (curated templates with palettes, descriptions, and prompt hints): |
| 33 | |
| 34 | ```bash |
| 35 | uv run --with openai --with python-dotenv --with pillow python scripts/generate_icon.py \ |
| 36 | --template brain-eeg -o brain_eeg.png --transparent |
| 37 | ``` |
| 38 | |
| 39 | With BiRefNet transparency (higher edge quality, extra deps): |
| 40 | |
| 41 | ```bash |
| 42 | uv run --with openai --with python-dotenv --with pillow --with rembg --with onnxruntime \ |
| 43 | python scripts/generate_icon.py --template neuron -o neuron.png \ |
| 44 | --transparent --transparency-method birefnet |
| 45 | ``` |
| 46 | |
| 47 | List templates: |
| 48 | |
| 49 | ```bash |
| 50 | uv run --with python-dotenv python scripts/generate_icon.py --list-templates |
| 51 | ``` |
| 52 | |
| 53 | Force a specific backend: |
| 54 | |
| 55 | ```bash |
| 56 | ... --backend codex # or --backend api |
| 57 | ``` |
| 58 | |
| 59 | ## Theme bible: keep an icon set consistent |
| 60 | |
| 61 | When generating multiple icons that need to look like they belong together (same line weight, same color palette, same perspective), use a `theme.json` file. The schema is in `references/theme.schema.json` and is shared with the `[[ai-full-figure]]` skill. At a minimum: |
| 62 | |
| 63 | ```json |
| 64 | { |
| 65 | "theme_id": "neuro-flat-v1", |
| 66 | "palette": {"primary": "#1F3A5F", "accent": "#E07A5F", "neutral": "#F4F1DE", "bg": "transparent"}, |
| 67 | "stroke": {"weight_px": 4, "linejoin": "round"}, |
| 68 | "style_tokens": ["flat 2D", "single continuous line", "no shading", "centered"], |
| 69 | "negative_tokens": ["text", "labels", "watermark", "gradient", "3D", "shadow"], |
| 70 | "composition": {"aspect": "1:1", "padding_pct": 12, "perspective": "orthographic"} |
| 71 | } |
| 72 | ``` |
| 73 | |
| 74 | `examples/icon_set.py` demonstrates loading a theme (including stroke weight and line-join hints) and generating an icon set with consistent prompts. |
| 75 | |
| 76 | ## When to use this skill vs the icon bible |
| 77 | |
| 78 | - **Bible templates** (`--template <id>`) are curated for common research subjects (brain, neuron, EEG cap, DNA, microscope, etc.) and produce predictable output. Use them first. |
| 79 | - **Free-form prompts** are right when the subject is not in the bible or needs a specific composition not captured by a template. |
| 80 | - **`--category`** generates every template in a category at once; useful for stocking a project's icon directory. |
| 81 | |
| 82 | See `references/icon-bible.md` for the template schema and `references/prompt-patterns.md` for what works and what |