본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)7.6k · #13172

portability

하는 일

이 스킬은 로컬과 호스팅 PostgreSQL에서 같은 방식으로 작동하는 테이블과 데이터베이스 쿼리를 정의하는 방법을 보여 줍니다. Agent-Native 앱 템플릿을 만드는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓앱의 새 데이터베이스 테이블이나 스키마를 정의할 때.
  • ✓데이터를 읽거나 저장하는 원시 SQL이나 새 서버 경로를 작성할 때.
  • ✓앱을 바꾸지 않고 로컬 데이터베이스와 호스팅 데이터베이스 모두에서 실행하고 싶을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/portability/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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 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
자주 묻는 질문

스키마에 어떤 라이브러리를 써야 하나요?

테이블을 정의하고 쿼리를 만들 때 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬