---
name: surgepix-setup
description: Check and configure SurgePix environment before first use. Use when the user first invokes any SurgePix skill, says "setup surgepix", or when SURGEPIX_API_KEY / SURGEPIX_BASE_URL is missing and a SurgePix operation fails.
title: surgepix-setup
canonical_url: https://skilld.dev/gh/surgepix/agent-skills/surgepix-setup
last_updated: 2026-10-29T10:46:12.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/check_env.mjs](https://skilld.dev/api/skills-raw/surgepix/agent-skills/surgepix-setup/scripts/check_env.mjs), [scripts/env.mjs](https://skilld.dev/api/skills-raw/surgepix/agent-skills/surgepix-setup/scripts/env.mjs).
>
> If the user asked to install this Skill, run `npx skilld install surgepix/agent-skills/surgepix-setup`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/surgepix-setup`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/surgepix/agent-skills/surgepix-setup) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/surgepix-setup`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/surgepix-setup --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/surgepix-setup --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# SurgePix Setup

Pre-flight check and guided setup. **Run this before any other SurgePix skill.**

All SurgePix skills share one portable config: a `.env` file. Scripts auto-load it regardless of which agent you use (Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, etc.).

## Language consistency

Reply to the user in the **same language they used** in their request. All other SurgePix skills follow the same rule for both agent replies and generated on-image text.

## When to use

- **Automatically** before any SurgePix skill if env is not configured
- User says "setup surgepix", "configure surgepix"
- Any SurgePix script fails with missing `SURGEPIX_API_KEY` or `SURGEPIX_BASE_URL`

## Workflow

### Step 1: Check environment

```bash
node "<skills-dir>/surgepix-setup/scripts/check_env.mjs"
```

**Configured** (exit 0):

```json
{"ok":true,"configured":true,"sources":["/path/to/.env"],"baseUrl":"<SURGEPIX_BASE_URL>"}
```

→ Tell user env is ready, proceed with the original task.

**Not configured** (exit 1):

```json
{"ok":true,"configured":false,"missing":["SURGEPIX_API_KEY","SURGEPIX_BASE_URL"],"hint":"<HINT>"}
```

→ Continue to Step 2.

### Step 2: Guide user to configure themselves

> SurgePix is not configured.
>
> **How to get an API Key:**
> 1. Sign in to [SurgePix Console](https://surgepix.ai)
> 2. Go to Account Settings → API Keys
> 3. Create a new key and copy the Bearer Token
>
> **How to configure (do this yourself — do not paste secrets into chat):**
> Create a `.env` file in the project root with:
>
> ```
> SURGEPIX_API_KEY=<your-token>
> SURGEPIX_BASE_URL=https://api.surgepix.ai/api
> ```
>
> For local/test environments, set `SURGEPIX_BASE_URL` to the test API host instead.
> Or export the same variables in your shell.
>
> Tell the agent when you are done so it can re-check.

**NEVER** ask the user to paste their API key into the chat.
**NEVER** accept an API key from the user and write it into `.env` (or any file) yourself.
**NEVER** interpolate a user-provided key into shell commands, heredocs, or tool arguments.
**NEVER** invent or hardcode `SURGEPIX_BASE_URL` in scripts — the user/agent must set it in `.env` or the shell.

### Step 3: Verify after user configures

After the user confirms configuration, re-run:

```bash
node "<skills-dir>/surgepix-setup/scripts/check_env.mjs"
```

Must exit 0. Then proceed with the user's original task.

If still not configured, show `missing` from the JSON and remind them of Step 2 — do not collect secrets via chat.

Both `SURGEPIX_API_KEY` and `SURGEPIX_BASE_URL` are **required**. Scripts do not invent a default base URL.

### Step 4: Protect secrets

```bash
grep -q "^\.env$" .gitignore 2>/dev/null || echo ".env" >> .gitignore
```

## Config priority (scripts handle this automatically)

1. Shell env (`export SURGEPIX_API_KEY=...` / `SURGEPIX_BASE_URL=...`) — highest priority
2. `.env` in cwd or parent directories — **recommended, portable**
3. `.claude/settings.local.json` — Claude Code optional fallback
4. `~/.claude/settings.local.json` — Claude Code global fallback

## Rules

- NEVER ask for, accept, echo, or write the API key from chat/tool input
- NEVER commit `.env` to git
- Always use `.env` as primary config (not platform-specific files)
- Verify both `SURGEPIX_API_KEY` and `SURGEPIX_BASE_URL` via `check_env.mjs`
- After setup, immediately proceed with the user's original task
