# Lessons Learned ## Anthropic OAuth (Feb 18) - **`state` parameter is REQUIRED** — Anthropic rejects OAuth requests without it - **Auth response is `code#state`** — must split on `#` before token exchange, send both to `/v1/oauth/token` - **OAuth tokens start with `sk-ant-oat`** — NOT `sk-ant-api`. Both start with `sk-ant-` so prefix check must be specific - **OAuth requires special headers:** `anthropic-beta: oauth-2025-04-20`, `user-agent: claude-cli/2.1.2 (external, cli)`, URL `?beta=true` - **Bearer auth, not x-api-key** — OAuth tokens use `Authorization: Bearer`, regular API keys use `x-api-key` - **Reference implementation:** `github.com/anomalyco/opencode-anthropic-auth/blob/master/index.mjs` ## Reonomy Scraper (Feb 18) - **`agent-browser eval` returns `\n` as literal backslash-n** — must `.replace(/\\n/g, '\n')` before parsing - **"Building & Lot" tab uses ampersand** — not "Building and Lot" - **Don't overwrite good data:** `parseAddresses()` already validates addresses from search results — don't try to "upgrade" from detail page headings ## Cron systemEvent on main session = NO-OP (Feb 16) - `systemEvent` payloads on `sessionTarget: "main"` get swallowed silently (~10ms, does nothing) - They arrive as heartbeat-level events and get acked without execution - **FIX:** Use `sessionTarget: "isolated"` with `payload.kind: "agentTurn"` for crons that need actual work done - Also set `payload.to` and `payload.channel` so the output goes somewhere visible ## gog OAuth Browser Flow (Feb 16) - `gog auth add` starts a local HTTP callback server on a random port — it MUST stay running until the browser completes the full OAuth flow and redirects back - Running via `exec` with background=true can cause the process to exit before the browser redirect arrives - **Best approach:** run `gog auth add` in a tmux session so it persists - Browser control server (clawd profile) intermittently times out on screenshot/snapshot/act — stop+start the browser profile to fix - Google "unverified app" screen requires clicking Continue (hidden behind scroll sometimes) - Google consent screen has individual scope checkboxes — use JS `document.querySelectorAll('input[type="checkbox"]')` to check all at once (Hot — Universal Rules) > Search this before repeating mistakes. Older/situational lessons in lessons-archive.md. ## Upwork Pipeline Architecture (Feb 19, 2026) - **ONE unified system:** Gmail Pub/Sub daemon (`com.clawdbot.gmail-pubsub-daemon`) → wake cron `c9df3e78` → agent parses email + scores job + creates Discord forum post with tags + auto-applies or passes + auto-buys connects if out - **No polling.** No redundant Gmail scans. The daemon catches emails in seconds via Pub/Sub streaming pull, debounces at 30s, and wakes the cron via `/hooks/wake` - Cron schedule is `0 0 31 2 *` (Feb 31 = never) — it ONLY runs when woken by the daemon - Cron runs in `isolated` session with `agentTurn` payload containing full pipeline instructions - Forum channel: `1472706495635390565` (phase-1-scouting). Tags applied via Discord API PATCH. - Processed email IDs tracked in `upwork-pipeline/processed.json` - Proposals saved to `proposals/YYYY-MM-DD-short-name.md` ## Upwork — CRITICAL RULES - **$50/hr MINIMUM** on all proposals. No exceptions. Jake directive Feb 16 2026. - Never bid below $50/hr even if client budget says $15-25. Either bid $50+ or skip. - **AUTO-APPLY TO ANYTHING WORTH APPLYING FOR.** Jake directive Feb 18 2026. This means: - Hot leads (80+): apply IMMEDIATELY, no approval needed - Good leads (65-79): apply if it's in our wheelhouse (AI, MCP, automation, full-stack, Claude, React/Next.js) - Lukewarm (50-64): apply if the client has good stats ($50K+ spent, 4.5+ rating) OR the job is a perfect stack match - **DO NOT just scan and report.** APPLY. Jake was upset that scans ran all day but zero applications went out. The pipeline exists to APPLY, not to scout and wait. - Speed matters — be first to apply. If multiple leads come in at once, apply by priority (highest score first), queue the rest. Include deliverables in proposals. Jake directive Feb 17 2026. - **LOCATION GATE:** Always check "Preferred qualifications" for location restrictions BEFORE applying. If job prefers Europe, UK, or any non-US region → SKIP. Don't waste connects on location-mismatched jobs. (Lesson from Feb 17 2026 — nearly submitted 32-connect proposal for Europe-only job.) - **Check location requirements** before applying — skip Europe-only or region-restricted jobs (Jake is US-based). Feb 17 2026. ## Memory & Context - **CHECK SKILLS BEFORE BUILDING** — Scan available_skills descriptions FIRST. I built a static UITreeRenderer that the MCP Apps skill explicitly warns against ("AVOID: Dynamic JSON Tree Rendering"). Jake caught me. Reasoning mode now on to force thinking pause. - **`