---
name: golden-record
description: Save winning ComfyUI generation parameters from a PNG image for reproduction.
allowed-tools: Read, Bash, Write, Glob, AskUserQuestion
argument-hint: "[image_path | --list | --load record.json]"
---

# /golden-record — Save & Reproduce Winning Generations

Extract generation parameters from a ComfyUI output PNG and save them as a Golden Record. Load records back to reproduce exact generations or iterate with overrides.

## Usage

```
/golden-record ~/ComfyUI/output/jinx_v2_00001_.png
/golden-record ~/ComfyUI/output/jinx_v2_00001_.png --name "jinx hero shot"
/golden-record --list
/golden-record --load ~/ComfyUI/golden_records/jinx_hero_shot.json
/golden-record --load jinx_hero_shot.json --seed 42
/golden-record --load jinx_hero_shot.json --prompt "same character, different lighting"
```

## Parameters

| Parameter | Default | Description |
|-----------|---------|-------------|
| `[image_path]` | — | Path to a ComfyUI output PNG to extract from |
| `--name` | filename stem | Descriptive name for the record |
| `--list` | — | List all saved Golden Records |
| `--load` | — | Load a saved record and regenerate |
| `--seed` | original | Override seed when loading |
| `--prompt` | original | Override prompt when loading |

## Execution Steps

### Mode 1: Extract & Save (default)

When the user provides an image path:

#### 1. Validate the image exists

Check the file exists and is a PNG. If not found, suggest checking `~/ComfyUI/output/` and list recent files.

#### 2. Extract parameters

Run:
```bash
python3 "/tools/golden_record.py" extract "<image_path>" --json
```

Display the extracted parameters to the user in a clear format:
```
Golden Record Parameters
═══════════════════════════════════════
  Seed:       7791
  Steps:      4
  CFG:        1.0
  Sampler:    euler
  Scheduler:  simple
  Resolution: 768x1024
  Model:      flux-2-klein-9b-Q8_0.gguf
  Prompt:     A striking young woman, late 20s...
═══════════════════════════════════════
```

#### 3. Ask to save

Ask the user if they want to save this as a Golden Record. If yes, ask for a descriptive name (or use the filename).

#### 4. Save the record

Run:
```bash
python3 "/tools/golden_record.py" save "<image_path>" --name "<name>"
```

Records are saved to `~/ComfyUI/golden_records/`.

#### 5. Confirm

Output:
```
Golden Record saved: ~/ComfyUI/golden_records/<name>.json

To reproduce this exact generation:
  /golden-record --load <name>.json

To iterate with a new seed:
  /golden-record --load <name>.json --seed <n>

To iterate with a new prompt:
  /golden-record --load <name>.json --prompt "new description"
```

### Mode 2: List Records

When `--list` is provided:

Run:
```bash
python3 "/tools/golden_record.py" list
```

Display the list of saved records with their key parameters.

### Mode 3: Load & Regenerate

When `--load` is provided:

#### 1. Load the record

If the path is just a filename (no directory), look in `~/ComfyUI/golden_records/`.

Run:
```bash
python3 "/tools/golden_record.py" show "<record_path>"
```

Display the parameters to the user.

#### 2. Apply overrides

If `--seed` or `--prompt` is specified, note the overrides.

#### 3. Generate the workflow

Run:
```bash
python3 "/tools/golden_record.py" workflow "<record_path>" [--seed <n>] [--prompt "<text>"] --out "/tmp/golden_record_workflow.json"
```

#### 4. Submit to ComfyUI

Check ComfyUI is running:
```bash
curl -s http://127.0.0.1:8188/system_stats
```

If running, submit the workflow:
```bash
curl -s -X POST http://127.0.0.1:8188/prompt -H "Content-Type: application/json" -d '{"prompt": <workflow_json>}'
```

#### 5. Wait for result

Poll `http://127.0.0.1:8188/history/{prompt_id}` every 15 seconds until complete or 3 minutes elapsed.

#### 6. Show the result

Read the output image using the Read tool and display it. Compare with the original if the source image is accessible.

Output:
```
Regenerated from Golden Record: <name>
Image: ~/ComfyUI/output/<filename>
Seed: <seed> (original | overridden)
```

## Records Directory

Golden Records are saved to `~/ComfyUI/golden_records/` as JSON files. Each record contains:

- **Metadata**: name, source image path, creation date
- **Parameters**: seed, steps, cfg, sampler, scheduler, resolution, models, prompt
- **Raw workflow**: The complete ComfyUI API workflow for exact reproduction

## Why This Matters

- ComfyUI embeds the full workflow in PNG metadata — Golden Record extracts and preserves it
- Seeds are reproducible: same seed + same prompt + same model = same image
- Records let you iterate systematically: change one variable at a time
- Building a library of winning parameters accelerates future generation
