---
name: generate-image
description: Generate an image via ChatGPT DALL-E using a saved browser session. Usage: /generate-image [--profile=acc1] <prompt>
allowed-tools: Bash(npx:*) Bash(npm:*)
---

# generate-image skill

Generates images by automating ChatGPT with saved browser profiles. Supports parallel generation across multiple accounts.

## Step 1 — Install dependencies (once)

Check whether `node_modules` exists in the skill directory. If not, run:

```bash
cd ".claude/skills/generate-image" && npm install
```

## Step 2 — Discover available profiles

Always run this first before anything else:

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/list-profiles.ts
```

Parse the output:
- `PROFILES_READY:acc1,acc2` → accounts that are set up and ready to generate
- `PROFILES_AVAILABLE:acc3,acc4,acc5` → empty slots available to add new accounts
- `NO_PROFILES_FOUND` → no accounts set up yet

## Step 3 — Decide the flow

### Case A — No profiles set up (`NO_PROFILES_FOUND`)

Tell the user no accounts are logged in yet. Open Chrome **immediately** for acc1 without asking:

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/setup-profile.ts acc1
```

After setup completes, if the user had a prompt, generate with acc1 automatically. Then ask:

> Account added! What would you like to do next?  
> 1. Generate the image now with acc1  
> 2. Add another account first  
> 3. Cancel  

### Case B — Profiles exist AND user provided a prompt (no add-account request)

Skip asking. Generate immediately using all ready profiles (or the ones specified with `--profile`). Go to Step 4.

### Case C — Profiles exist AND user provided a prompt AND user wants to add more accounts

Do **not** ask for confirmation. Immediately:

1. Show which profiles are ready: e.g. `Ready: acc1, acc2 — Next slot: acc3`
2. Open Chrome right away for the next available slot:

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/setup-profile.ts <next_available_slot>
```

3. After Chrome setup completes, ask:

> New account added! What would you like to do with your prompt?  
> 1. Generate with all accounts (including the new one)   
> 2. Generate using selected existing accounts 
> 3. Add yet another account  

### Case D — Profiles exist AND no prompt was given

Show the user a compact summary, for example:

> **Ready accounts:** acc1, acc2  
> **Free slots:** acc3, acc4, acc5  
>  
> What would you like to do?  
> 1. Generate an image with all ready accounts  
> 2. Generate with specific accounts  
> 3. Add another account  

Wait for the user's choice before proceeding.

## Step 4 — Generate images (parallel)

Run with a comma-separated list of profiles. The script launches all profiles **simultaneously**:

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/generate-image.ts --profile=acc1,acc2 "your prompt here"
```

To use all ready accounts automatically, use `--all`:

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/generate-image.ts --all "your prompt here"
```

After the script exits:
- Report `✓`/`✗` status per account
- Show each image path (printed as `Image saved → <path>`)
- If an account shows "not set up" error, suggest running setup for that profile

## Step 5 — Add a new account

Run setup for the next available slot (e.g., `acc3`):

```bash
cd ".claude/skills/generate-image" && npx ts-node scripts/setup-profile.ts acc3
```

Chrome opens interactively. The user logs in manually, then presses Enter. The session is saved to `profiles/acc3/`.

After setup completes, offer to generate an image immediately with the newly added account.

## Parsing the `/generate-image` invocation

```
/generate-image [--profile=acc1|acc1,acc2] [--all] <image prompt text>
```

- `--profile=acc1,acc2` — use specific profiles (comma-separated)
- `--all` — use every ready profile
- No flag → auto-detect all ready profiles
- Everything else is the image prompt

## Environment (optional)

If Chrome is not in its default location, create `.env` from `.env.example` and set `CHROME_PATH`.
