{"success":true,"name":"brimind-idea-to-url","description":"When a public chat user asks for a website or app, build it with Next.js (default stack), deploy it through the tunnel, and deliver a working public URL. Use for \"create a website for X\", \"build me an app that does Y\", or any request that should result in a live, accessible URL — not just code or instructions.","category":"unitary","path":"unitary/brimind-idea-to-url/SKILL.md","file":"SKILL.md","content":"---\nname: brimind-idea-to-url\ndescription: When a public chat user asks for a website or app, build it with Next.js (default stack), deploy it through the tunnel, and deliver a working public URL. Use for \"create a website for X\", \"build me an app that does Y\", or any request that should result in a live, accessible URL — not just code or instructions.\n---\n> Imported from [PRIVATE_HOST] `~/unitary/agents/skills/brimind-idea-to-url`. Paths are relative to `[PRIVATE_HOST]:[PATH]`; run commands there via `ssh [PRIVATE_HOST] 'cd ~/unitary && ...'`. Owner send rules from skill i7-remote-ops still apply.\n\n\n# Idea to URL — Build and Deploy in One Turn\n\nWhen a query arrives from the public chat (BRIMIND AI Chat), the user expects a **working URL**, not a folder path, not instructions to run it themselves, and not a zip file.\n\nThis skill covers the full flow: build → tunnel → live URL.\n\n## Stack default\n\n**Next.js** (App Router, TypeScript, Tailwind CSS) unless the user names a different stack or the request genuinely cannot be a Next.js app.\n\nRelated skills:\n- `brimind-demo-site` — full prospect site workflow\n- `brimind-static-page-live` — pure static HTML (no build step)\n- `brimind-house-style` — design standards for client-facing pages\n\n## 1. Build the project\n\nCreate the project under `clients/projects/<slug>/` — never at the repo root.\n\n### Next.js setup\n\n```bash\n# Create the project\nSLUG=\"<slug>\"\nmkdir -p clients/projects/$SLUG\ncd clients/projects/$SLUG\n\n# Initialize Next.js with TypeScript and Tailwind\nnpx create-next-app@latest . --typescript --tailwind --app --no-src-dir --import-alias \"@/*\"\n\n# Configure for static export\n```\n\n**In `next.config.mjs`:**\n```js\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  output: 'export',\n  trailingSlash: true,\n  images: {\n    unoptimized: true\n  }\n}\n\nexport default nextConfig\n```\n\n**Build on a unique port** in `package.json`:\n```json\n{\n  \"scripts\": {\n    \"dev\": \"next dev -p <unique-port>\",\n    \"build\": \"next build\",\n    \"export\": \"next build\"\n  }\n}\n```\n\nPick an unused port (check existing projects in `clients/projects/*/package.json`).\n\n## 2. Build the actual content\n\nWrite the page in `app/page.tsx` according to what the user asked for.\n\n**Design requirements** (from `brimind-house-style`):\n- 44×44px minimum touch targets\n- Visible focus rings for keyboard navigation\n- 4.5:1 color contrast minimum\n- `prefers-reduced-motion` support for animations\n- Responsive design (mobile-first)\n\nIf it's a demo for a prospect:\n- Footer must include BRIMIND credit\n- If uncommissioned, state clearly: \"This is a demonstration. [Business] has not ordered this site.\"\n\n## 3. Export the static build\n\n```bash\ncd clients/projects/$SLUG\nnpm run build\n\n# Verify the export\nls -la out/    # Should contain index.html and assets\n```\n\n## 4. Deploy to the tunnel\n\nRead the current `sitesRoot` (never hardcode it):\n\n```bash\nSITES_ROOT=$(node -e \"console.log(require('./brimind-tunnel/wildcard/config/tenants.config.json').sitesRoot)\")\n```\n\nCopy the build to the sites directory:\n\n```bash\n# From repo root\nSLUG=\"<slug>\"\nSITES_ROOT=$(node -e \"console.log(require('./brimind-tunnel/wildcard/config/tenants.config.json').sitesRoot)\")\n\n# Dry run first to verify\nrsync -avn --delete clients/projects/$SLUG/out/ \"$SITES_ROOT/$SLUG/\"\n\n# Actual deployment\nrsync -av --delete clients/projects/$SLUG/out/ \"$SITES_ROOT/$SLUG/\"\n```\n\n## 5. Register the tenant\n\nAdd to `brimind-tunnel/wildcard/config/tenants.config.json` in the `tenants` array:\n\n```json\n{\n  \"slug\": \"<slug>\",\n  \"name\": \"<Human-readable name>\",\n  \"mode\": \"static\",\n  \"active\": true\n}\n```\n\n**Important:** `static` mode tenants have NO `port` key. Adding a port is the common mistake.\n\n## 6. Validate before going public\n\n```bash\ncd brimind-tunnel/wildcard\nnpm run check\n```\n\nThis catches:\n- Bad `sitesRoot` path\n- Missing folders\n- Duplicate slugs\n- Configuration errors\n\n**Never skip this step.**\n\n## 7. Start the tunnel (if not already running)\n\n```bash\n# Terminal 1: Start the wildcard dispatcher\ncd brimind-tunnel/wildcard\nnpm start    # Runs on :4444\n\n# Terminal 2: Start the SSH tunnel agent\ncd brimind-tunnel\nnpm run agent    # Forwards :4444 to [PRIVATE_HOST]\n```\n\nCheck tunnel status:\n```bash\nnpm run tunnel:status    # From repo root\n```\n\n## 8. Verify the live URL\n\n```bash\nSLUG=\"<slug>\"\ncurl -s -o /dev/null -w \"%{http_code}\\n\" https://$SLUG.offer.brimind.pro/\n```\n\nExpected: `200`\n\n| Code | Meaning |\n|------|---------|\n| `200` | ✅ Live — share it |\n| `404` | Folder empty or no `index.html` |\n| `502` | Dispatcher or tunnel down |\n| `000` | DNS/TLS issue, not your site |\n\n## 9. Return the URL to the user\n\n**Deliverable format:**\n\n```\n✅ Your site is live at:\n\nhttps://<slug>.offer.brimind.pro/\n\nThe site is built with Next.js and deployed through BRIMIND's tunnel.\n```\n\nShort, plain, one URL on its own line.\n\n**Do not return:**\n- File paths on the server\n- Port numbers\n- Internal process names\n- Container IDs\n- Build logs\n- Token counts\n\nThe user asked for a site — give them a working link.\n\n## Gotchas\n\n1. **The site is live only while the laptop and tunnel agent are running.** For persistent deployment, use Vercel instead (see `brimind-demo-site`).\n\n2. **Slug naming:** Use lowercase, hyphens only, no underscores. Keep it short and related to the content.\n\n3. **Port conflicts:** Each Next.js dev server needs its own port. Check existing projects before picking one.\n\n4. **The tunnel takes ~1 minute to propagate** after registration. If you get a 404 immediately after adding the tenant, wait 30-60 seconds and try again.\n\n5. **Build environment vars:** The dashboard process pollutes `NODE_ENV`. Strip it:\n   ```bash\n   env -u NEXT_RUNTIME -u __NEXT_PROCESSED_ENV -u __NEXT_PRIVATE_ORIGIN \\\n       -u NEXT_PRIVATE_TRACE_ID NODE_ENV=production npm run build\n   ```\n\n6. **Never delete a sitesRoot folder** you didn't create in this session.\n\n## Alternative: Pure static HTML (no build step)\n\nIf the request is truly just HTML/CSS/JS with no framework:\n\nUse `brimind-static-page-live` skill instead — same tunnel deployment, but skip the Next.js scaffolding and just copy the HTML folder directly.\n\n## Rollback\n\nTo take a site down:\n\n1. Set `\"active\": false` in `tenants.config.json`\n2. Run `npm run check` to validate\n3. Only then: `rm -rf \"$SITES_ROOT/<slug>\"`\n\n## Post-deployment\n\nRegister in documentation:\n- `clients/README.md` — add to projects table\n- `README.md` — document in the clients section\n- `USAGE.md` — add run commands if applicable\n\nFor prospect demos that will be used in outreach, hand the lead data to `dealflow`.\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}