# Amazon Returns

> Amazon Returns — Browser Skill

- Skill: `martin-pv/amazon-returns` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add martin-pv/amazon-returns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/martin-pv/amazon-returns/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: martin-pv (https://skillmd.com/u/martin-pv)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/martin-pv/amazon-returns

---


# Amazon Returns — Browser Skill

## Purpose
Two workflows: (A) download and print all existing Amazon return labels; (B) create a new return from a photo of the item.

## Dependencies
- browse CLI: `npm install -g @browserbasehq/browse-cli`
- Browserbase remote mode required (Amazon bot detection)
- Python venv: `/Users/martinp/Martin Secoond Brain/Amazon skills/.venv/`
- Packages: `Pillow pyzbar qrcode[pil]` + native `zbar` (brew)
- Printer: `DYMO_LabelWriter_4XL` (confirmed via lpstat)
- Cookies: `/Users/martinp/Martin Secoond Brain/Amazon skills/amazon-cookies.json`
  Refresh: `node "/Users/martinp/Martin Secoond Brain/Amazon skills/scripts/bootstrap-amazon-session.mjs"`

## Workflow A: Download All Existing Return Labels

### Step 1 — Inject auth
```bash
cd "/Users/martinp/Martin Secoond Brain/Amazon skills"
node scripts/inject-cookies.mjs --platform amazon
```

### Step 2 — Run autobrowse loop
```bash
node ~/.claude/skills/autobrowse/scripts/evaluate.mjs \
  --task amazon-return-labels-download \
  --workspace autobrowse \
  --env remote
```

### Step 3 — Process and print each label
For each entry in the output JSON:
```bash
.venv/bin/python3 process-return-label.py \
  "<screenshot_path>" "<item_name>"
```

## Workflow B: Create New Return from Photo

### Step 0 — Identify item (outer skill — NOT in browse session)
Use Claude vision on the attached photo:
> "Identify this item in 10 words or less: brand, model, key features."
Store as ITEM_DESCRIPTION.

### Step 1 — Write item description into task
Use the Write tool to replace `ITEM_DESCRIPTION_PLACEHOLDER` in:
`/Users/martinp/Martin Secoond Brain/Amazon skills/autobrowse/tasks/amazon-create-return/task.md`

### Step 2 — Inject auth
```bash
node "/Users/martinp/Martin Secoond Brain/Amazon skills/scripts/inject-cookies.mjs" --platform amazon
```

### Step 3 — Run autobrowse
```bash
node ~/.claude/skills/autobrowse/scripts/evaluate.mjs \
  --task amazon-create-return \
  --workspace "/Users/martinp/Martin Secoond Brain/Amazon skills/autobrowse" \
  --env remote
```

### Step 4 — Print label
```bash
cd "/Users/martinp/Martin Secoond Brain/Amazon skills"
.venv/bin/python3 process-return-label.py \
  "<screenshot_path from output JSON>" \
  "$ITEM_DESCRIPTION"
```

## Browse CLI Reference
- `browse stop` — kill existing session
- `browse env remote` — start fresh Browserbase cloud session
- `browse newpage <url>` — open URL (required in remote mode)
- `browse wait timeout <ms>` — wait for SPA rendering
- `browse get title` — verify page / auth state
- `browse get text body` — read all visible text
- `browse snapshot` — accessibility tree with ref IDs [X-Y]
- `browse click [X-Y]` — click by ref
- `browse fill "<selector>" "<value>"` — fill input
- `browse back` — navigate back
- `browse screenshot <path>` — save PNG to CWD-relative path

## Site-Specific Gotchas
- Amazon fires bot detection on every fresh browser session — Browserbase remote is mandatory
- Returns page direct URL: `/gp/css/returns/homepage.html` — skip account menu
- SPA pages need `browse wait timeout 2000` after navigation before `browse snapshot`
- QR code label pages: QR may load async — wait 3000ms before screenshotting
- Free shipping check: scan for "$0.00" or "Free" text; UPS/USPS/Kohl's drop-off are usually free
- After `browse back`: wait 1000ms before next click

## Auth / Cookie Refresh
If title shows "Sign-In" mid-workflow:
1. Re-run bootstrap: `node scripts/bootstrap-amazon-session.mjs`
2. Re-run inject: `node scripts/inject-cookies.mjs --platform amazon`
3. Retry from Step 2

## Failure Recovery
- "no page available" → use `browse newpage` not `browse open` in remote mode
- Spinner/blank page → `browse wait timeout 3000` then `browse snapshot`
- Order not found → use "past 3 months" time filter before failing

## Expected Output (Workflow B)
```json
{
  "success": true,
  "order_id": "113-XXXXXXX-XXXXXXX",
  "item_name": "Matched item from order",
  "screenshot_path": "screenshots/return-label-1234567890.png",
  "label_type": "qr_code"
}
```

