Langsung ke konten
Skillpedia
API & server (backend)7.6k Β· #13172

portability

Fungsinya

Skill ini menunjukkan cara mendefinisikan tabel dan menulis kueri basis data yang berfungsi sama secara lokal maupun di PostgreSQL yang dihosting. Skill ini untuk pengembang yang membangun templat aplikasi agent-native.

Kapan dipakai

  • βœ“Saat Anda mendefinisikan tabel atau skema basis data baru untuk aplikasi.
  • βœ“Ketika Anda menulis SQL mentah atau rute server baru yang membaca atau menyimpan data.
  • βœ“Saat Anda ingin aplikasi berjalan di basis data lokal maupun yang dihosting tanpa perubahan.

Link skill

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/portability/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/portability/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œTambahkan tabel untuk makanan dan rute server yang menyimpan setiap entri, dan pastikan tetap berfungsi di hosting apa pun.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini meminta agent memakai alat PostgreSQL dari Drizzle untuk tabel dan kueri, sehingga kode yang sama berjalan di basis data lokal maupun yang dihosting.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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 BIGINT directly 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 stores
  • server-plugins β€” Framework routes and H3 handler patterns
  • security β€” SQL injection prevention via parameterized queries
Pertanyaan umum

Pustaka mana yang dipakai skema?

Skema memakai ekspor PostgreSQL dari Drizzle untuk mendefinisikan tabel dan membangun kueri.

Apakah ini berfungsi dengan basis data lokal?

Ya. PGlite lokal dan PostgreSQL yang dihosting dimaksudkan untuk berbagi perilaku SQL yang sama.

Kapan helper skema bersama sebaiknya dipakai?

Hanya untuk helper berbagi framework, seperti kolom yang bisa dimiliki dan tabel shares.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
7.6k
Peringkat
#13172
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa