portability
できること
このスキルは、ローカルでもホスティングされた PostgreSQL でも同じように動くテーブルの定義と問い合わせの書き方を示します。アプリのテンプレートを作る開発者向けです。
使う場面
- ✓アプリに新しいデータベースのテーブルやスキーマを定義するとき。
- ✓データを読み書きする生の SQL や新しいサーバーのルートを書くとき。
- ✓コードを変えずに、ローカルのデータベースとホスティングされたデータベースの両方でアプリを動かしたいとき。
スキルのリンク
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/portability/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“食事の記録用のテーブルと、各記録を保存するサーバーのルートを追加してください。どのホスティングでも動くようにしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、テーブルの定義と問い合わせに Drizzle の PostgreSQL 用の機能を使うようエージェントに指示します。そのため、同じコードがローカルとホスティングの両方のデータベースで動きます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Portability
Rule
Templates use one PostgreSQL schema and query contract. Local PGlite and hosted PostgreSQL share the same SQL semantics.
Database
Use Drizzle's PostgreSQL exports directly for schemas and its query builder for reads/writes:
import { sql } from "drizzle-orm";
import {
boolean,
doublePrecision,
integer,
pgTable,
text,
} from "drizzle-orm/pg-core";
export const meals = pgTable("meals", {
id: text("id").primaryKey(),
name: text("name").notNull(),
calories: integer("calories").notNull(),
weight: doublePrecision("weight"),
archived: boolean("archived").notNull().default(false),
createdAt: text("created_at").notNull().default(sql`now()`),
});
| Export | Purpose |
|---|---|
pgTable |
Defines a PostgreSQL table |
text |
Defines a text column, with optional enum values |
integer |
Defines an integer column |
boolean |
Defines a boolean column |
doublePrecision |
Defines a double-precision column |
sql |
Builds SQL expressions such as now() |
Use @agent-native/core/db/schema only for framework-owned sharing helpers such
as ownableColumns() and createSharesTable().
Use Drizzle's PostgreSQL query builder for app code:
import { and, desc, eq } from "drizzle-orm";
const rows = await db
.select()
.from(meals)
.where(and(eq(meals.ownerEmail, userEmail), eq(meals.archived, false)))
.orderBy(desc(meals.createdAt));
Avoid db.execute(...), getDbExec(), and handwritten SQL in actions, handlers, and stores when Drizzle can express the query. Raw SQL should be limited to additive migrations, health checks, carefully reviewed advanced queries, or one-off maintenance scripts. For timestamps in Drizzle schemas, use .default(now()); for migration SQL, use runMigrations().
Raw SQL helpers
getDbExec()— executes parameterized PostgreSQL SQL- Use PostgreSQL types such as
BIGINTdirectly in raw SQL.
Never
When writing docs, say "PostgreSQL" or "PGlite" precisely.
Use Postgres syntax deliberately in advanced queries and migrations, and prefer Drizzle APIs or framework helpers for ordinary application code.
When giving deployment guidance, be precise about durability: local PGlite is for development, while shared and production environments need a persistent hosted PostgreSQL DATABASE_URL.
Hosting Agnostic
The server runs on Nitro with H3 as the HTTP framework. Templates must be deployable to any Nitro-supported target.
Never use Express
All server code uses H3/Nitro: defineEventHandler, readBody, getMethod, setResponseHeader, etc. Express is not a dependency. If you see Express types or patterns anywhere, replace them with H3 equivalents.
No platform-specific config in scaffolded template source
Files like netlify.toml, wrangler.toml, vercel.json, and netlify/functions/ must NOT appear in the CLI scaffold source (packages/core/src/templates/) — apps generated for users stay hosting-agnostic, with platform configuration living in CI/hosting dashboards.
This monorepo's own first-party deployed apps keep platform configuration in app-specific hosting manifests such as templates/*/netlify.toml; this rule only applies to the CLI scaffold source.
No Node APIs in server routes/plugins
Never use fs, child_process, or path in server routes and plugins. Use Nitro abstractions. (Actions in actions/ run in Node.js and can use Node APIs freely.)
No persistent-process assumptions
Never assume a persistent server process. Use the SQL database for all state.
Related Skills
storing-data— Schema patterns and the core SQL storesserver-plugins— Framework routes and H3 handler patternssecurity— SQL injection prevention via parameterized queries
よくある質問
スキーマにはどのライブラリを使いますか?
テーブルの定義と問い合わせの組み立てに、Drizzle の PostgreSQL 用の機能を使います。
ローカルのデータベースでも動きますか?
はい。ローカルの PGlite とホスティングされた PostgreSQL は、同じ SQL の動作を目指しています。
共有のスキーマ用ヘルパーはいつ使うべきですか?
所有者の列や共有テーブルなど、フレームワークが共有するヘルパーに限られます。
詳細
作者による元の説明
How to keep template code PostgreSQL-specific and hosting-agnostic. Use when defining schemas, writing raw SQL, or creating server routes.
repo: BuilderIO/agent-native
人気
- GitHubのスター
- 7.6k
- ランキング
- #13172
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
design-exploration
7.6kUIの複数のデザインの方向性を並べて検討し、1つを選んでもらい、選んだデザインを磨き上げるようエージェントを支援します。
visual-edit
7.6k実行中のローカルのアプリをビジュアルエディターで開き、本物の画面をまとめて確認し編集できるようエージェントを支援します。
turn-into-app
7.6kワークフロー、スプレッドシート、プロジェクトを、画面にデータが入り、操作の裏でエージェントが働く、洗練されたビジュアルアプリに変えます。
visual-plan
7.6kプレーンテキストの計画を、図、ファイルのマップ、コードの断片、未解決の質問を含む、対話できるビジュアルな計画に変えます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。