Communitygithub.com

evalix098/tiktoklive

このTanStack StartアプリでNeon Postgres(データベース)を使用します。アプリがデータの保存、クエリ、状態の永続化、またはユーザーごとのデータ保持を必要とする場合に使用します。「database」「Postgres」「Neon」「save data」「store data」「persist」「tables」「SQL」「query」「migrations」などのキーワードでトリガーされます。

tiktoklive とは?

このスキルは、TanStack Startアプリ(Reactベースのフルスタックフレームワーク)にNeon Postgresデータベース統合を提供します。データベースは**オプトイン**であり、ブラウザセッションを超えて存続するデータやデバイス間で共有されるデータが必要な場合にのみ使用します。それ以外の場合は、`@/lib/db`をインポートせず、`localStorage`やzustandで状態を管理します。このテンプレートは**デュアルモード**のデータベース統合を備えており、Neon Postgresが設定されている(環境変数が設定され、デプロイされている)場合は本番のNeon Postgresを使用し、設定されていない場合(サンドボックスライブプレビュー)はローカルのPGLite(埋め込みWASM Postgres)にフォールバックします。どちらのモードも同じAPIで動作するため、開発と本番の差異を気にせずに開発できます。`pg`(node-postgres)と`@electric-sql/pglite`(ローカルDBフォールバック)はプリインストールされており、`npm install`は不要です。**ユーザーアカウント、サインイン、現在のユーザーの読み取り**については、別の**`auth`スキル**を参照してください。このスキルはデータベースのみを担当します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/evalix098/tiktoklive/tree/HEAD/.grok/skills/neon

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Neon Postgres

データベースはオプトインです(AGENTS.md §0.5):ブラウザセッションを超えて存続するデータ、またはデバイス間で共有されるデータがアプリに必要な場合にのみ使用してください。それ以外の場合は、マイグレーションを含めず、@/lib/dbをインポートせず、localStorage / zustandで状態を管理してください。

このテンプレートには、すぐに使えるデュアルモードのデータベース統合が含まれています:

  • 設定済み(環境変数が設定されている、例:デプロイ済み):実際のNeon Postgres。
  • 未設定(サンドボックスライブプレビュー):DBはローカルのPGLite(埋め込みWASM Postgres)にフォールバックするため、プレビューは常にレンダリングされます。@/lib/dbヘルパーを対象にビルドしてください。どちらのモードも同じAPIで動作します。

パッケージはプリインストール済みです — npm install しないでください:pg(node-postgres、通常のPostgresドライバー)と@electric-sql/pglite(ローカルDBフォールバック)が含まれています。

ユーザーアカウント、サインイン、現在のユーザーの読み取りについては、別の**authスキル**を参照してください — このスキルはデータベースのみを扱います。

データベースを有効にする

.grok/app-env.json で deploy.database を true に設定します:

{ "VITE_AUTH_ENABLED": "false", "deploy": { "database": true } }

これにより、デプロイされたアプリにNeonをプロビジョニングするようプラットフォームに指示します。falseのままにすると、デプロイには DATABASE_URL が設定されず、アプリは行が失われる使い捨てのPGLite上でサイレントに実行されます。migrations/*.sql の出荷、またはサインインは、このフラグに関係なくNeonをプロビジョニングします — このフラグは、@/lib/db をクエリするが、それらのどちらも持たないアプリのためのものです。これは VITE_ キーではなく、ブラウザに渡されることはありません。

環境変数 — .env ファイルを作成しないでください

データベース用の .env / .env.local / .env.example を決して作成しないでください。サンドボックスライブプレビューでは、DATABASE_URL を未設定のままにしてください — @/lib/db は自動的に埋め込みPGLiteを使用します。アプリがデプロイされると、プラットフォームが DATABASE_URL(Neon)を注入します。自分でプロビジョニングしたり記述したりする必要はありません。

変数場所目的
DATABASE_URLサーバーデプロイ時のNeon接続文字列(オプション — 未設定の場合はPGLiteにフォールバック)

決してハードコードしないでください。VITE_ 以外の変数をクライアントに公開しないでください。

データベース(サーバー専用)

@/lib/db は getSql() と dbSource をエクスポートします:DATABASE_URL に対する通常のPostgresドライバー(node-postgres、pg)、または未設定の場合のローカルPGLiteフォールバックです。どちらの場合も同じAPI — タグ付きテンプレート(および .query())で、rows[] に解決されます。createServerFn ハンドラー / サーバーローダーからのみ呼び出し、クライアントコンポーネントからは決して呼び出さないでください。スキーマはインラインではなく migrations/ で定義します。

import { createServerFn } from "@tanstack/react-start";
import { getSql } from "@/lib/db";

export const listPosts = createServerFn({ method: "GET" }).handler(async () => {
  const sql = await getSql();
  // 行の型を指定 — サーバー関数の戻り値は確実にシリアライズ可能である必要があります。
  return sql<{ id: number; title: string }>`select id, title from posts order by id desc`;
  // または:return sql.query<{ id: number; title: string }>("select id, title from posts where id = $1", [id]);
});

ユーザーごとのデータ(アプリにサインイン機能が追加された後のみ)。 通常のドライバーはDBへのフルアクセスを持つため、すべてのクエリをサーバーサイドで認証済みユーザーにスコープし、クライアントから送信されたIDを決して信頼しないでください。プリワイヤードの authMiddleware を使用して検証済みの context.userId を取得し、それでフィルタリングします。完全なパターン(ミドルウェア、クライアントコードからの呼び出し、フェイルクローズドセマンティクス)は authスキル にあります:

import { authMiddleware } from "@/lib/auth/middleware";

export const listTodos = createServerFn({ method: "GET" })
  .middleware([authMiddleware])
  .handler(async ({ context }) => {
    const sql = await getSql();
    return sql<{ id: number; title: string }>`select id, title from todos where user_id = ${context.userId} order by id desc`;
  });
// ミューテーションも書き込みをスコープする必要があります:`... where id = ${id} and user_id = ${context.userId}`

サインインなし(デフォルト)の場合、authMiddleware / requireUserId を使用しないでください**。フォールバックする開発ユーザーはプレビュー専用の便宜的なものです。デプロイされたアプリの VITE_AUTH_ENABLED は、このワークスペースではなくプラットフォームによって設定されるため(現在、デプロイヤーは常に "true" に設定します)、デプロイされると、両方ともすべての訪問者を拒否します — そして認証オフのアプリには、ユーザーが回復するためのサインインルートがありません。データベース専用アプリは、行を所有権なしに保ちます(user_id カラムなし、またはリテラル定数)。ミドルウェアは、サインインをオンにする(authスキルのアップグレード手順)一部として追加し、その時に行を再スコープまたは削除します。

所有権のない行は、パブリックサーバー関数を通じてワールドリーダブルかつワールドライタブルです:個人データや機密データ(名前、メールアドレス、個人に関するフリーテキスト)をこのモードで永続化せず、破壊的な一括ミューテーション(全削除、全上書き)も含めないでください — アプリがそれらを必要とする場合は、代わりにサインインを提案してください。

マイグレーション

migrations/*.sql が唯一のスキーマソースです。これらはデプロイ時のNeon(npm run build は DATABASE_URL に対して db:migrate を実行するため、Vercelはスキーマが準備された状態で出荷されます)とPGLiteプレビューに起動時に自動的に適用されるため、開発環境と本番環境が一致します。

どちらの適用ツールもサブディレクトリには降りないため、migrations/auth/0001_auth.sql のBetter Authスキーマは、アプリがサインインをオンにしてそれをコピーしない限り適用されません(編集しないでください — authスキルを参照)。アプリのスキーマは 0002 から始まる新しい順序付きファイルに配置します:

-- migrations/0002_schema.sql — todosアプリの例。YOURアプリのテーブルを使用してください
create table if not exists todos (
  id         serial primary key,
  user_id    text not null,
  title      text not null,
  done       boolean not null default false,
  created_at timestamptz not null default now()
);
create index if not exists todos_user_id_idx on todos (user_id);

適用済みのファイルは決して編集しないでください — 名前で _migrations に追跡され、再実行されません(代わりに新しいファイルを追加してください。新しいファイルは次のリクエスト時に実行中のプレビューに適用されます)。べき等なステートメント(… if not exists)を推奨します。ユーザーごとのデータを持つテーブルには user_id text not null カラムを含める必要があります(TEXT、UUIDではありません — プレビューの開発ユーザーIDは文字列 'dev-user' です)。

プレビュー ↔ 本番のパリティ

getSql() は結果の型を正規化し、両方のバックエンドが同一のJSONセーフな形状を返すようにします:bigint/count(*) → number、date → 'YYYY-MM-DD' 文字列、interval → テキスト、numeric → 文字列。注意すべき残りの相違点:

  • 2^53を超える bigint はnumberとして精度を失います — 巨大な整数が必要な場合は ::text にキャストしてください(行数は問題ありません)。
  • プレビューDBはインメモリです:開発サーバー再起動時にクリアされ、シングル接続(ロック競合や同時書き込み競合なし)、拡張機能はロードされません — create extension はしないでください。コアPostgresに限定してください。
  • Neonのプールエンドポイントはセッション状態を保持しません — SET、LISTEN/NOTIFY、セッションアドバイザリロックに依存しないでください。
  • user_id カラムは text のままにしてください — プレビューは 'dev-user' を使用し、本番はBetter AuthのテキストIDを使用します。uuid カラムはプレビューの挿入を壊します。
  • デプロイされたNeonクエリはネットワークを経由し(コールドリジュームの可能性あり) — インプロセスのプレビューDBに対して気軽に使えるN+1クエリパターンを避けてください。

Individual skills in this repo

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

evalix098/tiktoklive

Add user accounts and sign-in to this TanStack Start app. Use when the app needs authentication, sign-in, user accounts, protected routes, or per-user data. Triggers on "auth", "login", "log in", "sign in", "sign up", "account", "users", "authentication", "protected", "who is logged in", "current user", "per-user".

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

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).

関連スキル