Communitygithub.com

evalix098/tiktoklive

為這個 TanStack Start 應用程式新增使用者帳號與登入功能。當應用程式需要身份驗證、登入、使用者帳號、受保護路由或每個使用者的資料時使用。

tiktoklive 是什麼?

這個技能提供了一個基於 Better Auth 的完整身份驗證系統,內建於 TanStack Start 應用程式中。它支援三種登入方式:Google、X 與電子郵件/密碼,並透過 genericOAuth 外掛與共享的 Grok 身份驗證代理 (`auth.grok.me`) 進行聯合。此技能預設為關閉狀態;啟用時,它會處理真實的登入流程,包括彈出視窗、承載權杖傳遞與請求附加,並提供 `SignedIn`、`SignedOut` 與 `SignInGate` 等閘道元件。此外,它強制要求所有處理每個使用者資料的伺服器函數都必須使用 `authMiddleware`,將查詢範圍限定在 `context.userId`,以確保資料安全。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/evalix098/tiktoklive/tree/HEAD/.grok/skills/auth

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Auth

這個應用程式在 /api/auth/* 執行自己的 Better Auth,並透過 genericOAuth 外掛與共享的 Grok 身份驗證代理 (auth.grok.me) 進行聯合。此模板預先接好了 Google 與 X。

支援的登入方式 — 僅限使用這三種;不支援其他方式:Google、X 與電子郵件/密碼。 沒有其他的社交/OAuth 提供者(GitHub、Apple、Discord…),沒有魔法連結、通行金鑰、一次性密碼、電話/SMS 或匿名登入。請勿在 GROK_PROVIDERS 中新增條目。登入方式的詳細資訊以及電子郵件/密碼開關(僅編輯 src/lib/auth/email-password.ts):references/sign-in-methods.md。 例外情況 — 閘道檢視者已經登入;絕對不要為他們顯示登入/重新驗證按鈕。連接器 / 應用資料應用程式:僅限閘道「使用 Grok 繼續」,不顯示 Google/X 按鈕:references/grok-identity.md。

登入功能預設為關閉 — 模板附帶了 .grok/app-env.json,內容為 {"VITE_AUTH_ENABLED": "false"},因此只有在需求要求時才新增帳號(AGENTS.md §0.5)。啟用登入功能的方法請參考下方的「開啟登入功能」。

一旦開啟,登入功能就是真實的 — 包括在沙箱即時預覽中。 請勿建立示範/模擬/硬編碼使用者。預覽:彈出視窗 + 內建預覽客戶端;部署後:每個應用程式的客戶端 + DATABASE_URL + 零點擊閘道登入(references/prewired-and-env.md)。

當關閉時(VITE_AUTH_ENABLED=false),會回傳一個開發者使用者,以便非身份驗證應用程式在沒有已登入訪客的情況下也能渲染 — 僅限開發與預覽環境。部署後,該旗標由平台設定(永遠為 "true"),因此 requireUserId 會拒絕所有訪客 — 關閉身份驗證的應用程式不會使用它或 authMiddleware。

所有內容都已預先安裝並預先配置在 src/lib/auth/ 中 — 請勿執行 npm install;better-auth 是唯一的身份驗證套件(絕對不是 @neondatabase/*、@stackframe/* 或 @clerk/*)。請勿編輯或重寫 src/lib/auth/ 下的任何檔案 — 尤其是 server.ts — 除了 email-password.ts 中的那個旗標。每個檔案的對應關係:references/prewired-and-env.md。

/auth/popup 已由模板的 Vite 外掛處理(vite.config.ts → popup.server.ts):它永遠不會繪製 React 應用程式。請勿建立 src/routes/auth/popup.tsx(或該路徑下的任何 React 頁面 / 客戶端 OAuth)— 這會導致彈出視窗中顯示完整應用程式,這是常見的失敗模式。

永遠不要在此沙箱中編寫 .env / .env.local / .env.example:即時預覽不需要任何環境設定,而部署後的應用程式會由平台注入其變數。可用的設定選項位於 references/prewired-and-env.md — 絕對不要將非 VITE_ 的變數暴露給客戶端。

migrations/auth/0001_auth.sql 是 Better Auth 的資料庫綱要 — 請勿編輯。它位於全域的 migrations/ 目錄之外(兩個應用程式都不會套用它),因此不會應用於沒有登入功能的應用程式;「開啟登入功能」會將它複製上去。

開啟登入功能

執行以下所有步驟 — 僅路由本身會渲染停用的分支:

  1. 旗標: 從 .grok/app-env.json 中刪除 VITE_AUTH_ENABLED 鍵,然後重新啟動開發伺服器。Vite 在啟動時讀取環境變數,因此 HMR 不會偵測到變更。npm run dev、npm run build 與 npm run preview 都會透過 scripts/with-app-env.mjs 讀取該檔案,因此預覽與建置輸出會同時切換 — 永遠不要直接啟動 Vite。
  2. 資料庫綱要: 執行 cp migrations/auth/0001_auth.sql migrations/0001_auth.sql,然後重新啟動以套用它。它會根據基底名稱在 _migrations 中追蹤,因此已經具有此綱要的資料庫不會重新執行。
  3. 路由: 新增 src/routes/api/auth/$.ts + src/routes/login.tsx — 從 references/wiring.md 複製兩者(catch-all API 路由是讓 /api/auth/* 與代理回呼正常運作的關鍵)。
  4. 登出: 沒有登出方式的登入是不完整的 — 從 @/lib/auth/gates 渲染 <UserButton />(它會呼叫 signOut();對閘道工作階段隱藏登出按鈕)。
  5. 現有資料: 將應用程式的伺服器函數包裝在 authMiddleware 中(關閉身份驗證的應用程式之前不得使用它 — 請參閱 neon 技能)。在登入功能存在之前的資料列是開發資料:除非使用者另有指示,否則請刪除並重建它們 — 不要將它們交給第一個登入的人。

啟用後的擴充功能

  • 登入 / 登出: 從 @/lib/auth/client 使用 signIn(providerId) 與 signOut();GROK_PROVIDERS 會渲染按鈕。彈出視窗、承載權杖傳遞與請求附加是內部實作 — 請勿修改。建議優先使用 <UserButton />(它會處理等待與失敗狀態);signOut() 在部署後如果伺服器未確認,則會拒絕 — 請捕捉此情況。永遠不要使用 authClient.signOut():它會將預覽承載權杖附加到後續每個請求,導致訪客保持登入狀態。
  • 讀取使用者: useCurrentUser() 僅供顯示使用(null 表示載入中或已登出,因此永遠不要單獨用它進行重新導向);請改用 useCurrentUserState() 的 isPending 來進行防護。閘道(SignedIn、SignedOut、SignInGate、RedirectToSignIn、UserButton)位於 @/lib/auth/gates。行動呼籲的嚴格規則、骨架畫面以及 Cookie SSR 零閃爍:references/session-ui.md。
  • 每個使用者的資料(強制): 每個處理每個使用者資料的伺服器函數都必須使用預先配置的 authMiddleware,並將每個讀取與寫入的範圍限定在 context.userId — PostgreSQL 驅動程式具有完整的資料庫存取權限,因此沒有其他方式可以限制查詢。請將 user_id 欄位保持為 TEXT 型別;永遠不要信任用戶端提供的使用者 ID;當使用者登出時,中介軟體會拋出 UnauthorizedError(401)。程式碼與停用模式的語意:references/per-user-data.md。
  • 安全模型: 無頭代理、__Host- cookies + trustedOrigins,以及 Fetch-Metadata 兄弟隔離都已預先配置 — 永遠不要為了消除錯誤而弱化它們(references/sign-in-methods.md 涵蓋了模型與「無效來源」的修復方式)。

Individual skills in this repo

This repo contains 17 individual skills — each has its own dedicated page.

evalix098/tiktoklive

Build browser games and interactive/canvas/3D experiences in this TanStack Start + React app. Use for any game, simulation, or WebGL/Canvas experience — 2D or 3D, single-player. Covers the game loop & timing, 3D orientation/camera conventions, collision, performance, assets, audio, save, game feel, and per-genre playbooks. For WASD / vehicle / flight **input signs and inverted A/D**, open the **`controls`** skill — do not rely on this file or racing-kart alone. Triggers on "game", "minecraft", "fps", "platformer", "racing", "tetris", "snake", "shooter", "3d", "three.js", "canvas", "voxel", "physics".

evalix098/tiktoklive

Player-facing input signs for browser games: WASD, vehicles, flight, FPS mouse-look, and the #1 failure mode (inverted A/D). Mandatory control self-tests and a tiny test interface so you can verify A turns left before shipping. Load for ANY game with movement, steering, flying, driving, tanks, boats, mechs, drones, planes, karts, third-person follow cams — not only racing. Triggers on "controls", "WASD", "inverted", "steer", "flight", "airplane", "kart", "vehicle", "yaw", "roll", "pitch", "mouse look", "A/D".

evalix098/tiktoklive

Design and build polished, non-generic UI for this TanStack Start + React + Tailwind v4 + shadcn/Radix app. Use whenever you create or restyle any interface surface — pages, landing pages, dashboards, forms, modals, nav, and game overlays (start screens, HUD, menus). Covers design tokens, layout, typography, color, spacing, motion, and the anti-"AI-slop" rules that keep output from looking generic. Triggers on "design", "UI", "make it look good", "polish", "landing page", "theme", "style", "redesign", "ugly", "clean up".

evalix098/tiktoklive

Deep guide for game ANIMATION assets: motion cycles, action keyframes, effect sequences, and animation sprite sheets — built around a video-first pipeline. In this app-builder sandbox, execute via the video2dsprite / generate2dsprite skills (magenta + scripts), not ad-hoc ffmpeg. Use whenever generating anything that moves: walk/run cycles, attacks, idles, FX, flags, fire, animation sheets. Complements game-asset-core.

evalix098/tiktoklive

Core discipline for ANY game-asset generation with Imagine tools: the engine-ready defaults users don't state, spec checklists, style anchoring, read-back verification, honest defect flagging. Use whenever generating any game art (sprites, sheets, animations, tiles, UI, FX) — then ALSO load the matching specialist skill: game-animation-frames for anything that moves, game-tilesets for tiles/terrain, game-character-consistency for recurring characters, game-ui-icons for UI and icons.

evalix098/tiktoklive

Deep guide for CHARACTER IDENTITY across images: turnarounds (front/side/ back), state and damage variants, palette swaps, equipment changes, and same-character-in-context sets. Use whenever generating character turnarounds, character sheets, variants of an existing sprite, or any same-subject multi-image set. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game TILE assets: seamless tileable textures, terrain transition tilesets, autotiles, and ground/platform tiles. Use whenever generating tileable textures, tilesets, terrain transitions, or seamless patterns. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game UI assets: buttons with interaction states, panels, bars, wordmark logos, and icon sets. Use whenever generating game UI elements, HUD assets, inventory icons, icon sets, buttons, or title logos. Complements game-asset-core.

evalix098/tiktoklive

Generate production-oriented 2D game maps with `imagine_text_to_image`: RPG/top-down maps, side-scroller parallax stages, tilemaps, layered raster maps, prop packs, collision zones, and walkable areas. Use when building browser games that need real map art (not pure code-drawn tiles), layered props, or map collision metadata. Triggers on "map", "level", "stage", "tilemap", "overworld", "dungeon", "side scroller background", "prop pack", "2D map".

evalix098/tiktoklive

Generate and postprocess 2D game sprites and animation sheets: pixel-art characters, NPCs, creatures, spells, projectiles, impacts, props, summons, and transparent PNG/GIF exports. Use when building browser games that need real sprite sheets (not code-drawn placeholders), matching a map art style, or producing magenta-background sheets for chroma-key cleanup. Triggers on "sprite", "sprite sheet", "animation sheet", "pixel art character", "walk cycle", "attack animation", "projectile sprite", "2D game asset".

evalix098/tiktoklive

How to use the Imagine tools in Grok Build: imagine_text_to_image, imagine_image_to_image, imagine_reference_to_image, imagine_text_to_video, imagine_image_to_video, imagine_reference_to_video, and render_file for chat previews. When to build a visual with code instead of generating it, prompt-craft, reference-first handling of real people, factual grounding, and asset-consistency. Load this whenever generating or editing an image or video is on the table. Tool-usage-driven, not triggered by a user merely mentioning images.

evalix098/tiktoklive

Peer-to-peer realtime multiplayer over WebRTC data channels: every user of the deployed app connects directly to every other user (full mesh), the server only brokers the handshake at /api/rtc. Lowest possible latency, zero per-message server cost. Use for 2-8 player co-op/casual realtime: shared cursors, drawing, party games, casual action. Triggers: p2p, peer to peer, webrtc, low latency multiplayer, direct connection.

evalix098/tiktoklive

Use Neon Postgres (the database) in this TanStack Start app. Use when the app needs to store or query data, persist state, or keep per-user data. Triggers on "database", "Postgres", "Neon", "save data", "store data", "persist", "tables", "SQL", "query", "migrations".

evalix098/tiktoklive

Share-link previews and app identity for apps on *.grok.me: the injector-owned og:image card, the SVG favicon, and PWA icons for installable apps. Use when scaffolding, renaming, or restyling the app — and for share / unfurl / OG / Twitter card questions. A custom 1200×630 card from the app's own art is the default — games of every kind (DOM board/word games included), whimsical apps, creative tools, and brand-forward pages; only plain utilities keep the placeholder. Always run the brand-asset pass as a `task` subagent and never wait for it. Triggers on "share", "rename", "app name", "OG", "Open Graph", "twitter card", "unfurl", "og:image", "og:type", "x:game:image", "x-banner", "link preview", "social card", "thumbnail", "preview image", "favicon", "app icon", "PWA", "manifest", "installable", "home screen", "SEO", "meta description".

evalix098/tiktoklive

Official Three.js API and TSL (Three.js Shading Language) reference for LLM code generation. Load when writing or debugging three.js / WebGL / WebGPU / custom materials / shaders / GLTF / advanced three APIs beyond basic game loop/controls. Prefer building-games for game correctness (loop, WASD, camera, orientation); use this skill for full API/TSL depth. Triggers on "three.js", "threejs", "WebGPU", "TSL", "NodeMaterial", "shader", "GLTF", "MeshStandard", "OrbitControls", "WebGLRenderer".

evalix098/tiktoklive

Grok Build only. Turn a 2D character still into denser animation sprites via imagine_text_to_image base → imagine_image_to_video (6s/10s run-in-place) → ffmpeg frames → magenta chroma-key → dense sampled strips/grids/GIFs. Use when the user wants video-to-sprite, smoother run/walk cycles, or denser intermediate poses. Prefer generate2dsprite for crisp production pixel sheets. Triggers on "video to sprite", "imagine_image_to_video sprite", "dense walk cycle", "smooth run animation from video".

evalix098/tiktoklive

Call the xAI API (Grok) from this app's server code using the injected XAI_API_KEY: chat/LLM features, image and video generation (Imagine), and voice (text-to-speech). Use when the app needs any "AI" / "assistant" / "chatbot" / "Grok" functionality, runtime image/video generation, or speech. Triggers on "AI", "LLM", "chatbot", "assistant", "Grok", "xAI", "generate text", "summarize", "generate image", "AI video", "voice", "text to speech", "TTS", "OpenAI" (use xAI instead).

相關技能