Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
Add road-to-1b production-readiness prompt set (baseline 00-14)
miniaturization1e4013b3b06d
diff --git a/prompts/road-to-1b/00-README.md b/prompts/road-to-1b/00-README.mdnew file mode 100644index 000000000..7efa85f13--- /dev/null+++ b/prompts/road-to-1b/00-README.md@@ -0,0 +1,127 @@+# Road to $1B — production-readiness program++> Read this first, then `/CLAUDE.md`. Every prompt in this folder assumes both.++This is the **spine** that takes three.ws from "impressive demo" to a platform a+serious diligence team, a million users, and a $THREE holder base would all trust.+It is deliberately separate from the feature-expansion prompt libraries elsewhere in+`prompts/` (`feature-innovation/`, `agent-studio/`, `living-agents/`, …) — those add+surface area; **this track makes the surface area we already have correct, safe, fast,+and fundable.**++The only coin is **$THREE** (`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`). No+exceptions, anywhere. See `/CLAUDE.md`.++## How to run this++Each numbered file is a **self-contained prompt for a fresh chat**. Open a new+session, paste the file's contents (or say "do `prompts/road-to-1b/NN-*.md`"), and let+the agent execute it end to end. One prompt = one focused, shippable unit of work.++Run **in number order within a phase**. Phases are mostly sequential; inside a phase,+prompts marked `Parallel-safe with:` can run in separate chats at the same time.+Foundation (Phase 0) and hardening (Phase 1) come before everything — you cannot+polish or grow on top of stubs and security holes.++Each prompt ends with an **Acceptance** checklist. A prompt is not done until every+box is checked, `npm test` is green, and any user-visible change has a+`data/changelog.json` entry (`npm run build:pages` validates it).++## The repo in one breath++Vanilla-JS + Vite monorepo, 20 npm workspaces. ~125 pages (`pages/`), ~810 front-end+modules (`src/`), ~961 Vercel functions (`api/`), Cloudflare workers (`workers/`),+Three.js for 3D, Solana + pump.fun + x402 for money, real OpenAI/Anthropic via worker+proxies. `STRUCTURE.md` maps every surface to its directory — read it before+exploring. Useful existing gates: `npm run audit:web`, `audit:pages`,+`audit:handlers`, `audit:empty-handlers`, `check:images`, `test:gate`, `verify:solana`,+`smoke:onchain`, `audit:deploy`, `lint`, `typecheck`.++## Phase map++| # | Prompt | Phase |+|---|---|---|+| 01 | Production-readiness audit & scorecard | 0 — Foundation & truth |+| 02 | No stubs, mocks, TODOs — hard-rule cleanup | 0 |+| 03 | Dead paths, broken links & empty handlers | 0 |+| 04 | $THREE-only compliance sweep | 0 |+| 05 | Secrets & env hygiene | 1 — Correctness & hardening |+| 06 | Error handling & resilience | 1 |+| 07 | Security hardening | 1 |+| 08 | Rate limiting & abuse prevention | 1 |+| 09 | Test suite green & CI gate | 1 |+| 10 | Resilience of external calls | 2 — Reliability at scale |+| 11 | Observability (logs, metrics, alerts) | 2 |+| 12 | Frontend performance & Core Web Vitals | 3 — Experience quality |+| 13 | Accessibility (WCAG 2.2 AA) | 3 |+| 14 | Responsive & mobile | 3 |+| 15 | Every state designed + design-system consistency | 3 |+| 16 | SEO, metadata, Open Graph & structured data | 3 |+| 17 | Cross-browser & device QA | 3 |+| 18 | Studio suite completeness (Forge, Avatar, Animation, Scene) | 4 — Surface completeness |+| 19 | Agent creation & Agent Studio | 4 |+| 20 | Marketplace, skills & purchase flow | 4 |+| 21 | Trading & intelligence suite (Oracle, radars, leaderboards) | 4 |+| 22 | Launch suite (Launch a Coin, Launchpad, Coin Intel, Claim) | 4 |+| 23 | Worlds, Coin Clash & multiplayer | 4 |+| 24 | Wallets & payments (x402, agent wallets, USDC, pay-by-name) | 4 |+| 25 | SDK release-readiness | 5 — Developer platform |+| 26 | MCP servers & agent interoperability | 5 |+| 27 | Docs, tutorials & API reference | 5 |+| 28 | Onboarding, guided tour & activation funnel | 5 |+| 29 | Conversion funnel & landing optimization | 6 — Growth & business |+| 30 | Analytics & growth instrumentation | 6 |+| 31 | Monetization, pricing & $THREE utility | 6 |+| 32 | Legal, compliance & trust | 6 |+| 33 | Infrastructure, CI/CD & deploy safety | 6 |+| 34 | Launch-readiness gate & go-to-market QA | 6 |++## Why "$1B" is the bar, concretely++A $1B platform is not "more features." It is: **nothing is fake** (Phase 0), **nothing+leaks or breaks under load or attack** (Phases 1–2), **it feels world-class on any+device** (Phase 3), **every surface a user can reach is finished** (Phase 4),+**developers can build on it** (Phase 5), and **the funnel from first visit to paying,+retained user is measured and optimized** (Phase 6). Each phase is a precondition for+the next being worth anything.++## Prompt template (for adding new ones)++```+# NN — Title++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** N — <name>+**Owns:** <paths/surfaces this prompt may change>+**Depends on:** <numbers or "none"> · **Parallel-safe with:** <numbers or "—">++## Why this matters for $1B+<2–4 lines tying the work to trust / fundability / growth>++## Mission+<one crisp sentence>++## Map+<real repo paths, scripts, surfaces>++## Do this+1. … (specific, ordered, references real scripts/paths — never generic)++## Must-not+- …++## Acceptance+- [ ] … ; `npm test` green; changelog entry if user-visible.+```++## Global definition of done (applies to every prompt)++- No mocks, fake data, placeholders, TODOs, stubs, or `throw "not implemented"`.+- Every interactive element has hover/active/focus states; every page has designed+ loading/empty/error/populated states.+- Real APIs only; errors handled at network/input boundaries.+- `npm test` green; `npm run lint` and `npm run typecheck` clean for touched code.+- `git diff` self-reviewed; every changed line justified.+- User-visible change → `data/changelog.json` entry (plain language, holder-readable).+- You would demo it, unprompted, to a room of senior engineers.diff --git a/prompts/road-to-1b/01-production-readiness-audit.md b/prompts/road-to-1b/01-production-readiness-audit.mdnew file mode 100644index 000000000..a64fba3a7--- /dev/null+++ b/prompts/road-to-1b/01-production-readiness-audit.md@@ -0,0 +1,45 @@+# 01 — Production-readiness audit & scorecard++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 0 — Foundation & truth+**Owns:** read-only across the whole repo; output a report under `tasks/` or `docs/`.+**Depends on:** none. Run this first — it produces the backlog everything else executes.++## Why this matters for $1B+You cannot fix, fund, or scale what you haven't honestly measured. This prompt+produces the single prioritized punch list that prompts 02–34 work down. No hand-waving+— evidence with `file:line`.++## Mission+Produce an honest, reproducible production-readiness scorecard of three.ws with a+prioritized remediation list mapped to the prompts that fix each gap.++## Map+- Existing gates to run and capture: `npm run audit:web`, `npm run audit:pages`,+ `npm run audit:handlers`, `npm run audit:empty-handlers`, `npm run check:images`,+ `npm run lint`, `npm run typecheck`, `npm test`.+- Surface inventory: `STRUCTURE.md`, `data/pages.json` (all ~125 pages), `pages/`,+ `src/`, `api/`, `workers/`, the SDK dirs.++## Do this+1. Run every audit/lint/test script above and capture the raw output (don't fix yet).+2. Grep the tree for hard-rule violations and record `file:line` for each: `TODO`,+ `FIXME`, `HACK`, `throw new Error('not implemented'`, `setTimeout(` used for fake+ loading, `sample`/`mock`/`fake`/`placeholder` arrays, large commented-out blocks.+3. Walk `data/pages.json`: for every page, record whether it has a real backend, real+ data, and designed loading/empty/error states.+4. Score each major surface (Studios, Agents/Agent Studio, Marketplace, Trading suite,+ Launch suite, Worlds/Coin Clash, Wallets/Payments, SDKs, Docs) **Red/Amber/Green**+ on: completeness, designed states, error handling, mobile, a11y, performance.+5. Write a single `tasks/production-readiness-scorecard.md`: an executive summary, the+ surface scorecard table, the violation list with evidence, and an ordered+ remediation list where every Red item names the owning prompt number (02–34).++## Must-not+- Do not fix anything here — audit only. Do not soften or omit findings to look better.++## Acceptance+- [ ] `tasks/production-readiness-scorecard.md` exists with the surface table + evidence.+- [ ] Every Red/Amber item cites `file:line` and an owning prompt number.+- [ ] The audit is reproducible from the listed scripts; `npm test` still green.diff --git a/prompts/road-to-1b/02-no-stubs-mocks-todos.md b/prompts/road-to-1b/02-no-stubs-mocks-todos.mdnew file mode 100644index 000000000..2143db3f7--- /dev/null+++ b/prompts/road-to-1b/02-no-stubs-mocks-todos.md@@ -0,0 +1,43 @@+# 02 — No stubs, mocks, TODOs — hard-rule cleanup++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 0 — Foundation & truth+**Owns:** `src/`, `api/`, `workers/`, `pages/`, `scripts/`, SDK dirs (shippable code).+**Depends on:** 01. · **Parallel-safe with:** 04.++## Why this matters for $1B+CLAUDE.md forbids mocks, fake data, TODOs, stubs, and `throw "not implemented"`. A+single shipped placeholder tells a user — and a diligence team — "this company doesn't+finish things." Every one is a credibility leak.++## Mission+Eliminate every mock, fake-data fallback, placeholder, TODO/FIXME, stub function, fake+`setTimeout` loading, and commented-out code from shippable paths — by implementing the+real thing, never by hiding it.++## Map+- Violation inventory from prompt 01.+- `npm run audit:empty-handlers` catches no-op/empty handlers.+- Real integrations already in the repo (Pump.fun feed, Solana RPC, OpenAI/Anthropic+ worker proxies) — use them; never re-mock them.++## Do this+1. For each violation from 01, implement the real behavior: real API/endpoint/data per+ CLAUDE.md "No errors without solutions — there is always a correct answer."+2. Replace every `sample*`/fallback array shipped to production with a real fetch plus a+ designed empty state (a hollow list is not acceptable; tell the user what to do).+3. Convert fake progress bars / `setTimeout` loaders to real async indicators tied to+ actual work (skeletons preferred).+4. Delete commented-out code and dead imports; resolve every `// implement later`.+5. Replace any `throw new Error('not implemented')` with the implementation.+6. Re-run `npm run audit:empty-handlers` and the violation greps from 01 until clean.++## Must-not+- Do not hide a stub behind a feature flag or env check to "pass."+- Do not delete a feature to remove its stub — finish the feature.++## Acceptance+- [ ] Greps for the banned patterns return nothing in shippable code.+- [ ] `npm run audit:empty-handlers` clean; no fake loaders remain.+- [ ] `npm test` green; changelog entry only where user-visible behavior changed.diff --git a/prompts/road-to-1b/03-dead-paths-and-broken-links.md b/prompts/road-to-1b/03-dead-paths-and-broken-links.mdnew file mode 100644index 000000000..8e7e21648--- /dev/null+++ b/prompts/road-to-1b/03-dead-paths-and-broken-links.md@@ -0,0 +1,41 @@+# 03 — Dead paths, broken links & empty handlers++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 0 — Foundation & truth+**Owns:** `pages/`, `src/` UI + components, nav/footer, `data/pages.json`.+**Depends on:** 01. · **Parallel-safe with:** 02, 04.++## Why this matters for $1B+Every dead button, no-op link, or 404 is a trust leak and a conversion killer.+CLAUDE.md is explicit: if a button exists it must work; if a link exists it must go+somewhere; if a state exists there must be a way to reach it.++## Mission+Guarantee every link resolves, every button does something real, every declared state+is reachable, and every page is reachable from navigation.++## Map+- `npm run audit:pages`, `npm run audit:handlers`, `npm run audit:empty-handlers`.+- Primary nav: `src/dashboard-next/components/topbar.js`; footer + in-page CTAs across+ `pages/`. Route registry: `data/pages.json`. The "All pages" directory + guided tour+ should cover real routes only.++## Do this+1. Run `audit:pages`, `audit:handlers`, `audit:empty-handlers`; fix every flagged item.+2. Crawl the topbar, footer, and in-page CTAs for `href`s that 404 or point nowhere;+ fix the destination or remove the link with intent (no orphan links).+3. Verify every page in `data/pages.json` is linked from somewhere and renders.+4. Find buttons/handlers that are missing or no-ops; wire them to real behavior or+ remove the control if the action genuinely doesn't exist yet (then note the gap).+5. Verify deep-links, back/forward, and the guided tour land on real, working routes.+6. Confirm the "All pages" directory reflects the live route set.++## Must-not+- Do not mask a broken link by suppressing the click — fix the destination or remove it.+- Do not leave a control that looks interactive but does nothing.++## Acceptance+- [ ] `audit:pages`, `audit:handlers`, `audit:empty-handlers` all clean.+- [ ] Manual crawl of nav/footer/CTAs finds zero dead links or no-op buttons.+- [ ] Every `data/pages.json` route is reachable and renders; `npm test` green.diff --git a/prompts/road-to-1b/04-three-coin-compliance.md b/prompts/road-to-1b/04-three-coin-compliance.mdnew file mode 100644index 000000000..8b376aeef--- /dev/null+++ b/prompts/road-to-1b/04-three-coin-compliance.md@@ -0,0 +1,45 @@+# 04 — $THREE-only compliance sweep++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 0 — Foundation & truth+**Owns:** the entire repo — code, comments, tests, fixtures, docs, copy, metadata.+**Depends on:** none. · **Parallel-safe with:** 02, 03.++## Why this matters for $1B+Brand and legal integrity. The platform promotes exactly one coin — **$THREE**+(`FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`). CLAUDE.md treats any stray token+reference like a leaked secret. A diligence team will grep for exactly this.++## Mission+Ensure $THREE is the only coin referenced anywhere, while keeping the two legitimate+runtime-data exceptions intact.++## Map+- The two allowed exceptions (runtime-data only, keep them):+ 1. Generic coin-agnostic plumbing where a mint is supplied at runtime by the user+ (the pump.fun launcher accepting an arbitrary mint as input).+ 2. Platform launch directories rendering user-launched coins from our own records:+ the `/launches` feed, agent-profile launch history, `/api/pump/launches` over+ `pump_agent_mints`.++## Do this+1. Grep the whole tree for hardcoded mint addresses, token tickers, and coin names+ (base58 mint patterns, `$`-prefixed tickers, known-coin words).+2. Remove every non-$THREE reference from source, comments, copy, tests, fixtures,+ docs, metadata, and sample data — treat each like a leaked secret.+3. Verify the two exceptions still function and remain runtime-data-only — never a+ hardcoded specific non-$THREE mint in source or copy.+4. Confirm fixtures/tests use only the $THREE CA above or a clearly-synthetic+ placeholder (e.g. `THREEsynthetic1111…`) — no real third-party mainnet mints.+5. Add a CI grep guard (a `scripts/` check or a test) that fails the build if a+ non-$THREE mint/ticker is reintroduced outside the two exception paths.++## Must-not+- Do not remove the two legitimate runtime-data exceptions.+- Do not hardcode, market, or recommend any specific non-$THREE mint anywhere.++## Acceptance+- [ ] Tree grep shows no other coin in source, copy, tests, or docs.+- [ ] Both exceptions verified runtime-only and still working.+- [ ] CI guard rejects reintroduction; `npm test` green.diff --git a/prompts/road-to-1b/05-secrets-and-env-hygiene.md b/prompts/road-to-1b/05-secrets-and-env-hygiene.mdnew file mode 100644index 000000000..ae1c9e2b6--- /dev/null+++ b/prompts/road-to-1b/05-secrets-and-env-hygiene.md@@ -0,0 +1,56 @@+# 05 — Secrets & env hygiene++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 0 — Foundation+**Owns:** `.env*`, `vercel.json` (`env`), `api/`, `workers/`, `.gitignore`, anything reading `process.env`.+**Depends on:** none. Run early — a leaked key is a $1B-killer.++## Why this matters for $1B+A single leaked private key (Solana parent secret, RPC key, bot token) can drain+funds and end the company. Diligence teams scan git history for secrets. This must be+airtight.++## Mission+Guarantee no secret is committed, every secret is loaded from the environment with a+clear failure when missing, and the set of required env vars is documented and+validated at boot.++## Map+- Required secrets referenced across the codebase include (verify the live set):+ `THREEWS_SOL_PARENT_SECRET_BASE58`, Solana RPC keys, `TELEGRAM_BOT_TOKEN`,+ `TELEGRAM_CHANGELOG_CHAT_ID`, OpenAI/Anthropic keys (via worker proxies), x402+ facilitator config.+- `vercel.json` has an `env` block. Functions in `api/`, workers in `workers/`.++## Do this+1. Scan the working tree **and git history** for committed secrets (use+ `git log -p` filtered, or a tool like gitleaks/trufflehog run locally). Treat any+ hit as an incident: rotate the key, purge if feasible, and document.+2. Confirm `.gitignore` excludes `.env`, `.env.*` (except `.env.example`), key files,+ and any wallet keypair JSON. Add what's missing.+3. Create/maintain a complete `.env.example` listing **every** env var the app reads,+ grouped by surface, with a one-line description and whether it's required. Derive+ the list by grepping `process.env.` across `api/`, `workers/`, `src/`, `scripts/`.+4. Add a startup/env-validation step (a small `api/_lib/env.js` or similar) that, on+ cold start, asserts required vars are present and fails loud with a precise message+ naming the missing var — never a silent undefined that 500s later.+5. Ensure secrets are read server-side only. Grep `public/` and client `src/` for any+ secret-looking value or `VITE_`-exposed secret that should be server-only. Move+ them behind an API route or worker proxy.+6. Confirm the AI provider keys are only ever used via the worker proxies, never+ shipped to the client (per `/CLAUDE.md` stack notes).+7. Document secret rotation steps in `docs/` (where to rotate each, blast radius).++## Must-not+- Do not print secrets in logs or error messages.+- Do not commit a real key even to `.env.example` — use obvious placeholders.+- Do not expose any secret via a `VITE_`/client-bundled var.++## Acceptance+- [ ] git history + working tree scanned; zero live secrets present (rotations done if found).+- [ ] `.gitignore` covers all secret/keypair patterns.+- [ ] `.env.example` is complete and grouped, derived from actual `process.env` usage.+- [ ] Boot-time env validation fails loud on missing required vars, naming each.+- [ ] No secret reachable from the client bundle.+- [ ] Rotation runbook written in `docs/`.diff --git a/prompts/road-to-1b/06-error-handling-and-resilience.md b/prompts/road-to-1b/06-error-handling-and-resilience.mdnew file mode 100644index 000000000..3d71eccff--- /dev/null+++ b/prompts/road-to-1b/06-error-handling-and-resilience.md@@ -0,0 +1,59 @@+# 06 — Error handling & resilience++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 1 — Cross-cutting hardening+**Owns:** `api/` (~960 handlers), `workers/`, `api/_lib/`, client fetch wrappers in `src/`/`public/`.+**Depends on:** `04` (no fake fallbacks).++## Why this matters for $1B+At scale, dependencies fail constantly — RPC nodes time out, providers rate-limit,+pump.fun hiccups. A $1B platform degrades gracefully and self-heals. `/CLAUDE.md`:+"No errors without solutions. Ship working fallbacks and failsafes. Lazy error+propagation is not engineering."++## Mission+Every external call has timeout, retry-with-backoff, circuit-breaking where+appropriate, and a designed failure path. Every handler returns correct status codes+and structured errors. No unhandled rejections.++## Map+- Resilience helper: **cockatiel** is the vetted choice (see existing usage in+ `api/_lib/`). Reuse it — do not hand-roll retry loops.+- Real upstreams: Solana RPC (already has "resilient Solana RPC" work — see git log),+ Pump.fun feed, OpenAI/Anthropic worker proxies, x402 facilitator.+- Recent hardening precedent: `api/x402-checkout.js` ATA-probe hardening against+ malformed RPC replies — match that rigor.++## Do this+1. Inventory every outbound call in `api/` and `workers/`. For each, confirm:+ explicit timeout, bounded retry with jittered backoff (cockatiel), and a+ circuit-breaker for hot paths that hammer a flaky upstream.+2. Standardize a shared `fetchWithResilience` / RPC-client wrapper in `api/_lib/`+ and migrate unprotected callers to it (additive — don't churn already-protected+ code, per memory guidance).+3. Validate and defensively parse every upstream response. Never assume shape;+ malformed replies must not throw raw — they map to a clean error or a safe+ default. (Generalize the x402 ATA-probe pattern.)+4. Standardize API error responses: correct HTTP status, a stable `{ error: { code,+ message } }` shape, no stack traces or secrets leaked to clients. Log full detail+ server-side.+5. Add a top-level handler wrapper that catches unhandled rejections/exceptions per+ request and converts them to a clean 5xx with a request id.+6. Client side: every `fetch` has a timeout + abort, and surfaces a designed,+ actionable error state (ties to prompt `12`). Add retry on idempotent GETs.+7. Add tests for the failure paths: simulate timeouts, 429s, malformed JSON, partial+ responses. Confirm graceful degradation, not crashes.++## Must-not+- Do not swallow errors silently or return `200` with empty data on failure.+- Do not leak stack traces, internal URLs, or secrets in error responses.+- Do not retry non-idempotent writes blindly (risk of double-spend/double-mint).++## Acceptance+- [ ] Every external call has timeout + bounded retry; hot paths have circuit-breakers.+- [ ] Shared resilient client adopted across previously-unprotected handlers.+- [ ] All upstream responses defensively parsed; malformed input handled, never thrown raw.+- [ ] Uniform structured error responses with correct status codes; no leaks.+- [ ] Failure-path tests added and green.+- [ ] No unhandled promise rejections (cross-check prompt `03`).diff --git a/prompts/road-to-1b/07-security-hardening.md b/prompts/road-to-1b/07-security-hardening.mdnew file mode 100644index 000000000..3bc8c9bae--- /dev/null+++ b/prompts/road-to-1b/07-security-hardening.md@@ -0,0 +1,62 @@+# 07 — Security hardening++> Part of **Road to $1B** (`prompts/road-to-1b/`). Read `00-README.md` and `/CLAUDE.md` first.++**Phase:** 1 — Cross-cutting hardening+**Owns:** `api/`, `workers/`, auth middleware in `api/_lib/`, `vercel.json` (headers/routes), wallet/payment paths.+**Depends on:** `05` (secrets), `06` (error handling). Pairs with `08` (rate limiting).++## Why this matters for $1B+This platform custodies wallets and moves money (x402, $THREE, skill purchases). One+authz bug = drained funds = dead company. Security is the difference between a+fundable platform and a liability.++## Mission+Close every authn/authz gap, validate every input, set hardening headers, and ensure+money-moving paths are airtight. Run a real security review and fix what it finds.++## Map+- Auth/ownership model: `agent_identities.user_id` is immutable, one agent = one+ owner (see `prompts/agent-wallets/00-README-orchestration.md`). Only the owner can+ withdraw / set limits / rebrand.+- Money paths: `api/x402-*`, `api/payments/*`, `api/pump/*`, withdrawal endpoints,+ `api/_lib/agent-wallet.js`, `api/_lib/skill-license-onchain.js`.+- `vercel.json` controls routes + can set headers.++## Do this+1. Run the repo's security-review skill/process (`/security-review`) over the current+ state and triage findings by severity.+2. **AuthZ on every mutating endpoint:** confirm the caller owns the resource before+ any write/withdraw/rebrand/spend. Audit `api/` for endpoints that trust a+ client-supplied `user_id`/`agent_id` without verifying the session. Fix every one.+3. **Input validation at boundaries:** validate/normalize every request body, query+ param, and path param (lengths, types, ranges, address formats, amount bounds).+ Reject early with 400. Prevent injection (SQL/NoSQL/command), path traversal, SSRF+ (especially anywhere a URL is fetched on the user's behalf).+4. **Money-path invariants:** amount sanity bounds, idempotency keys on+ transfers/mints to prevent double-spend, replay protection on signed requests,+ server-side recomputation of prices (never trust client-sent amounts).+5. **Security headers** via `vercel.json` or middleware: `Content-Security-Policy`+ (tightened, not `unsafe-inline` everywhere), `Strict-Transport-Security`,+ `X-Content-Type-Options`, `Referrer-Policy`, `Permissions-Policy`, frame controls+ for embeds (allow only intended embed routes).+6. **CORS:** lock API CORS to known origins; don't reflect arbitrary `Origin`.+7. **Dependency audit:** `npm audit` (and `npm audit --workspaces`); fix high/critical+ by upgrade. Document any accepted advisory with rationale.+8. **Secrets in transit/logs:** confirm prompt `05` outcomes hold; no PII/secrets in+ logs.+9. Add regression tests for each fixed authz/validation hole.++## Must-not+- Do not trust any client-supplied identity, amount, or price.+- Do not weaken CSP to "make something work" — fix the inline/eval cause.+- Do not retry or replay money-moving requests without idempotency.++## Acceptance+- [ ] `/security-review` findings triaged and resolved (or risk-accepted with written rationale).+- [ ] Every mutating endpoint verifies ownership/session server-side.+- [ ] All inputs validated at the boundary; injection/traversal/SSRF closed.+- [ ] Money paths have amount bounds + idempotency + server-side price recomputation.+- [ ] Hardening headers + locked CORS in place; CSP tightened.+- [ ] `npm audit` clean of high/critical (or documented).+- [ ] Regression tests cover the fixed holes; `npm test` green.diff --git a/prompts/road-to-1b/10-resilience-external-calls.md b/prompts/road-to-1b/10-resilience-external-calls.mdnew file mode 100644index 000000000..5a009f47c--- /dev/null+++ b/prompts/road-to-1b/10-resilience-external-calls.md@@ -0,0 +1,71 @@+# 10 — Resilience on every external call++**Phase 2. [parallel-safe]** with 07–09, 11.++## Where you are++`/workspaces/three.ws` — three.ws, 3D AI-agent platform. It depends on external+services that WILL fail intermittently: Solana RPC, pump.fun feed, OpenAI/+Anthropic via worker proxies, x402 facilitators, R2/storage, Telegram. Read+[CLAUDE.md](../../CLAUDE.md). Your memory notes a `cockatiel` resilience helper+and a preference for vetted OSS over hand-rolling. The only coin is **$THREE**.++## Objective++Every outbound network call has a timeout, bounded retries with backoff+jitter+for transient failures, and a circuit breaker or graceful degradation so one+slow dependency can't cascade into an outage. Solana RPC and pump.fun especially+get multi-endpoint failover.++## Why it matters++Public RPCs rate-limit and flake constantly; pump.fun and LLM providers have+incidents. Without timeouts and breakers, a single hung upstream call exhausts+function concurrency and takes the whole platform down. Resilience is what lets a+$1B platform claim real uptime on top of unreliable dependencies.++## Instructions++1. **Find every outbound call:**+ ```bash+ grep -rIn "fetch(\|axios\|new Connection(\|getAccountInfo\|sendTransaction\|https.request\|undici" --include=*.js src/ api/ workers/ | grep -v node_modules+ ```+ Classify by dependency (RPC, pump, LLM, x402, storage, misc).+2. **Adopt one shared resilience helper** (reuse the existing `cockatiel`-based+ helper if present — check the codebase and the+ [prefer-vetted-oss-additive] memory; otherwise wrap `cockatiel`). Expose:+ `retry(policy)`, `timeout(ms)`, `circuitBreaker(opts)`, composed into a+ `resilientFetch()` / `withResilience(fn)`. Do not hand-roll bespoke retry+ loops per file.+3. **Timeouts everywhere.** No `fetch` without an `AbortController` + timeout.+ Pick sane per-dependency budgets (RPC ~8s, LLM longer, feeds ~5s).+4. **Retries only for transient errors** (network, 429, 5xx, RPC node errors) —+ never for 4xx/validation. Exponential backoff + jitter. Respect `Retry-After`.+5. **Solana RPC failover.** There is prior art ("resilient Solana RPC" in recent+ commits) — extend it: a prioritized pool of RPC endpoints with health-aware+ rotation, so a dead/throttled node is skipped. Same idea for any multi-+ provider dependency.+6. **Circuit breakers + degradation.** When a dependency is failing, open the+ breaker and serve a degraded-but-honest response (cached data with a+ "stale" marker, or a designed error state — coordinate with+ [18 — state design](18-state-design-sweep.md)). Never hang.+7. **Idempotency for retried writes.** Any retried mutation/payment must carry an+ idempotency key so a retry can't double-execute (cross-check+ [08 — API hardening](08-api-hardening.md)).+8. **Tests.** Use the existing resilience test patterns (e.g.+ `tests/api/pump-trending-resilience.test.js`) to add coverage: timeout fires,+ retry recovers on second attempt, breaker opens after N failures, failover+ picks the next endpoint.++## Definition of done++- [ ] Zero `fetch`/RPC call without a timeout in `src/ api/ workers/`.+- [ ] One shared resilience helper used across all outbound calls (no per-file+ hand-rolled retry loops).+- [ ] Retries are transient-only with backoff+jitter; 4xx never retried.+- [ ] Solana RPC (and other multi-provider deps) have health-aware failover.+- [ ] Circuit breakers degrade gracefully to cached/honest states, never hang.+- [ ] Retried writes are idempotent.+- [ ] Resilience tests added and passing (`npm test`).+- [ ] Changelog: `improvement`/`infra` entry if users see fewer transient errors+ (e.g. "More resilient data loading during network hiccups").diff --git a/prompts/road-to-1b/11-observability.md b/prompts/road-to-1b/11-observability.mdnew file mode 100644index 000000000..d560e40ef--- /dev/null+++ b/prompts/road-to-1b/11-observability.md@@ -0,0 +1,73 @@+# 11 — Observability: logging, monitoring, alerting++**Phase 2. [parallel-safe]** with 07–10.++## Where you are++`/workspaces/three.ws` — three.ws, 3D AI-agent platform on Vercel functions ++Cloudflare workers, with PostHog and Vercel Analytics already loaded on the+frontend and a `public/error-reporter.js`. Read [CLAUDE.md](../../CLAUDE.md). The+only coin is **$THREE**.++## Objective++You can see what the platform is doing in production: structured logs with+request/trace context, client + server error reporting into one pipeline, uptime+and latency monitoring on every critical path, and alerting that pages a human+before users complain. No silent failures, no blind spots on money flows.++## Why it matters++At a billion-dollar bar you operate the platform, not just ship it. If a payment+endpoint starts 500ing or RPC latency spikes, you must know in minutes — from a+metric, not a tweet. Observability is the difference between a 5-minute incident+and a 5-hour one.++## Instructions++1. **Structured logging.** Replace ad-hoc `console.log` in server code+ (`api/`, `workers/`) with a structured logger (level, message, requestId,+ userId/agentId where safe, dependency, duration). Never log secrets, private+ keys, full tokens, or PII. Add a `requestId` at the edge and thread it through.+ ```bash+ grep -rIn "console.log\|console.error\|console.warn" --include=*.js api/ workers/ | grep -v node_modules | wc -l+ ```+2. **Unified error reporting.** Wire client errors (`public/error-reporter.js`)+ and server errors into one sink (Sentry or the existing pipeline — check+ deps/env before adding a new vendor). Capture: message, stack, requestId,+ route, release/commit. De-dupe and group. Cross-check with+ [03 — error boundaries](03-harden-error-boundaries.md): every reported catch+ lands here.+3. **Critical-path monitoring.** Define SLOs for the money/chain and core paths+ (forge generate, x402 checkout, pump launch, login, marketplace load). Add+ uptime + latency checks (synthetic monitors or a `/api/health` + external+ pinger). Record p50/p95/p99 latency and error rate per path.+4. **Health endpoints.** Ensure a real `/api/health` (and per-worker health) that+ checks downstream deps (RPC reachable, DB reachable, KV reachable) and returns+ structured status — used by monitors and the status page+ ([26 — trust surfaces](26-trust-surfaces.md)).+5. **Alerting.** Configure alerts on: error-rate spike, p95 latency breach, money+ -path failure, breaker-open events (from [10](10-resilience-external-calls.md)),+ and health-check failure. Route to a real channel (the existing Telegram+ integration is a candidate). Document thresholds in+ `docs/observability.md`.+6. **Dashboards.** Stand up (or document) a dashboard view of the core metrics so+ on-call has one place to look. PostHog is already present for product+ analytics — keep product vs ops signals distinct.+7. **Verify it fires.** Trigger a synthetic error and a synthetic latency breach;+ confirm it shows up in the sink and the alert routes.++## Definition of done++- [ ] Server code uses a structured logger with requestId threading; no secret/+ PII logged; raw `console.*` in `api/`/`workers/` reduced to near-zero.+- [ ] Client + server errors flow into one reporting sink with release/commit and+ requestId; verified by a synthetic error.+- [ ] `/api/health` (+ worker health) checks real downstream deps.+- [ ] SLOs + uptime/latency monitoring exist for every critical path; metrics+ recorded.+- [ ] Alerting configured and verified to fire on error-spike / latency / money-+ path / health failure, routed to a real channel.+- [ ] `docs/observability.md` documents SLOs, alert thresholds, and the runbook+ pointer (feeds [28 — incident response](28-incident-response-oncall.md)).+- [ ] Changelog: skip (internal) unless a user-facing status surface shipped.diff --git a/prompts/road-to-1b/12-frontend-performance.md b/prompts/road-to-1b/12-frontend-performance.mdnew file mode 100644index 000000000..e5b8191ba--- /dev/null+++ b/prompts/road-to-1b/12-frontend-performance.md@@ -0,0 +1,71 @@+# 12 — Frontend performance & Core Web Vitals++**Phase 3. [parallel-safe]** with 13–14.++## Where you are++`/workspaces/three.ws` — three.ws, vanilla-JS modules + Vite, 125 pages, 118+public JS files, Three.js for 3D. Read [CLAUDE.md](../../CLAUDE.md) — "Performance+by default: lazy-load heavy modules, debounce input, paginate lists, use+`will-change`/`transform` for animations. Don't ship jank." The only coin is+**$THREE**.++## Objective++Hit "good" Core Web Vitals (LCP < 2.5s, INP < 200ms, CLS < 0.1) on the top+landing surfaces on a mid-tier mobile device and a throttled connection. Cut+bundle weight, defer non-critical work, and remove layout jank.++## Why it matters++Growth and conversion are gated by speed. A platform that competes with Vercel/+Linear/Stripe loads instantly. Every 100ms of LCP and every CLS shift costs+sign-ups. This is directly upstream of the $1B growth math.++## Instructions++1. **Measure first.** Build and run Lighthouse/CWV on the top surfaces (home,+ forge, marketplace, trending, an agent profile):+ ```bash+ npm run build && npm run audit:web # existing web auditor+ npx lighthouse https://localhost:3000/ --preset=perf --form-factor=mobile --throttling-method=simulate+ ```+ Record LCP/INP/CLS/TBT and bundle sizes per route as the baseline.+2. **Bundle analysis.** Inspect the Vite build output and chunking. Find the+ heaviest modules (Three.js, character-studio, model-viewer, web3 libs).+ ```bash+ ls -laSh dist/assets/*.js | head -20+ ```+ Code-split route-heavy and 3D-heavy code behind dynamic `import()`. The 3D+ engine must never block first paint on non-3D pages.+3. **Lazy-load the heavy stuff.** Three.js, GLB loaders, and the avatar engine+ load on interaction/visibility, not on document load. Use+ `IntersectionObserver` for below-the-fold 3D and images+ (`loading="lazy"`, `decoding="async"`).+4. **Kill CLS.** Reserve space for images/canvas/embeds (width/height or+ aspect-ratio). No content that shifts when fonts/data arrive. Preload the+ primary font; `font-display: swap`.+5. **Optimize the critical path.** Inline critical CSS for above-the-fold,+ defer the rest. `preconnect`/`dns-prefetch` for RPC/API/analytics origins.+ Ensure analytics (PostHog, Vercel) load non-blocking (they already do —+ confirm they're not on the critical path).+6. **Improve INP.** Debounce search/input handlers, break long tasks, move heavy+ compute off the main thread (Worker) where it blocks interaction. The+ `MaxListenersExceededWarning` noise in console is the MetaMask extension, not+ us — ignore it; focus on our own long tasks.+7. **Caching headers.** Static assets immutable + far-future cache; HTML+ appropriately revalidated. Verify via `vercel.json` headers.+8. **Re-measure** and prove the deltas.++## Definition of done++- [ ] Before/after CWV recorded for the top 5 surfaces (mobile, throttled); LCP <+ 2.5s, INP < 200ms, CLS < 0.1 on each, or a documented reason + plan if a+ specific surface can't yet.+- [ ] Three.js / 3D engine code-split and lazy-loaded; non-3D pages don't ship+ it on the critical path.+- [ ] Images/canvas/embeds reserve space; CLS verified low.+- [ ] Heaviest chunks reduced; bundle-size deltas recorded.+- [ ] Static-asset caching headers correct in `vercel.json`.+- [ ] `npm run build` + `npm test` pass; no new console errors.+- [ ] Changelog: `improvement` entry ("Faster page loads / smoother 3D").