portability
Skill này làm gì
Skill này chỉ cách định nghĩa bảng và viết truy vấn cơ sở dữ liệu hoạt động giống nhau cục bộ và trên PostgreSQL được host. Nó dành cho lập trình viên xây template ứng dụng agent-native.
Khi nào nên dùng
- ✓Khi bạn định nghĩa một bảng cơ sở dữ liệu hoặc schema mới cho ứng dụng.
- ✓Khi bạn viết SQL thô hoặc một route máy chủ mới đọc và lưu dữ liệu.
- ✓Khi bạn muốn ứng dụng chạy trên cơ sở dữ liệu cục bộ và cơ sở dữ liệu được host mà không cần đổi code.
Liên kết skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/portability/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm một bảng cho các bữa ăn và một route máy chủ lưu từng mục, đồng thời giữ cho nó chạy được trên mọi nền tảng host.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill yêu cầu agent dùng các công cụ PostgreSQL của Drizzle để định nghĩa bảng và truy vấn, để cùng một code chạy được trên cả cơ sở dữ liệu cục bộ và được host.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Schema nên dùng thư viện nào?
Nó dùng các export PostgreSQL của Drizzle để định nghĩa bảng và xây truy vấn.
Điều này có chạy với cơ sở dữ liệu cục bộ không?
Có. PGlite cục bộ và PostgreSQL được host được thiết kế để dùng chung hành vi SQL.
Khi nào nên dùng các trợ giúp schema dùng chung?
Chỉ cho các trợ giúp chia sẻ của framework, như cột có thể gán chủ sở hữu và bảng shares.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 7.6k
- Vị trí xếp hạng
- #13172
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
design-exploration
7.6kGiúp agent của bạn khám phá nhiều hướng thiết kế giao diện song song, để bạn chọn một hướng rồi tinh chỉnh thiết kế đã chọn.
visual-edit
7.6kGiúp agent của bạn mở một ứng dụng cục bộ đang chạy trong trình chỉnh sửa trực quan, để bạn xem và sửa các màn hình thật cùng nhau.
turn-into-app
7.6kBiến quy trình, bảng tính hoặc dự án thành ứng dụng trực quan có màn hình đầy đủ dữ liệu, với agent làm việc phía sau các điều khiển.
visual-plan
7.6kBiến một kế hoạch viết bằng văn bản thuần thành kế hoạch trực quan tương tác, có sơ đồ, bản đồ file, đoạn code và các câu hỏi còn mở.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.