storing-data
하는 일
이 스킬은 Agent-Native 앱이 레코드는 SQL에 보관하고, 이미지나 동영상 같은 큰 파일은 파일 저장소에 보관한다는 점을 설명합니다. 새 데이터 모델을 추가하거나 앱 데이터를 읽고 쓰는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓앱에 새 데이터 모델이나 테이블을 추가할 때.
- ✓데이터를 데이터베이스에 둘지 파일에 둘지 결정해야 할 때.
- ✓앱이 이미지, 동영상 또는 PDF를 저장해야 할 때.
스킬 링크
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/storing-data/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“사용자가 업로드한 이미지를 저장하는 방법을 추가하고, 각 이미지의 기록은 데이터베이스에 남겨 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
레코드와 참조는 데이터베이스에 저장되며, 바이너리 콘텐츠는 파일 저장 도구를 거칩니다. 데이터베이스에는 반환된 ID나 URL만 저장됩니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Storing Data — SQL is the Source of Truth
Rule
All application data lives in SQL (local PGlite, hosted Postgres in production). The agent and UI share the same database. SQL stores structured records, metadata, references, and searchable text — not large raw file payloads. Do not store durable app data in the filesystem unless the app is explicitly running a Local File Mode artifact flow described below.
Large binary or file-like payloads (images, video/audio, PDFs, ZIPs, screenshots, session replay chunks, thumbnails, generated assets, data: URLs, and base64 file bodies) must go through configured file/blob storage such as uploadFile() or putPrivateBlob(). Persist only the returned URL, asset id, or opaque blob handle in SQL. If storage is unavailable in hosted or persistent-database mode, fail closed with setup guidance instead of falling back to base64 in application_state, settings, resources, or app tables.
Uploaded files an action opens later (chat attachments, import controls, chunked commits) are one core AttachmentRef: mint with mintAttachmentRef, open with resolveAttachment and unwrapAttachment from @agent-native/core/private-blob. Never write a template descriptor, never branch on error text, and never truncate a ref (ATTACHMENT_REF_MAX_CHARS is the floor for any prompt or field that carries one). Each failure is typed: notFound, forbiddenScope, expired and malformed are definitive and stop the turn, except a value that is not a ref at all or is missing (malformed with unrecognized_scheme or empty), which is an ordinary action error the model corrects by passing the listed ref; only storageUnavailable is retryable, and the same ref works once storage is back, so never ask the user to attach the file again for it.
Local File Mode exception: some artifact apps (Content, Plans, Slides, Dashboards, Designs, etc.) can intentionally use repo files as the source of truth for the artifact itself. This must be explicit via agent-native.json, AGENT_NATIVE_MODE=local-files, or an app-owned local-file action helper. In that mode, the UI and agent still go through app actions, but those actions read/write scoped files through @agent-native/core/local-artifacts instead of SQL rows. App state, auth, settings, credentials, collaboration metadata, and hosted database mode remain SQL. File-to-database or file-to-provider synchronization is an explicit sync step, not an implicit side effect of editing.
When you add a data model, a list, or a read path, also follow the performance skill: project only the columns a list renders, index the columns hot queries filter/sort on, and avoid query waterfalls — so apps stay fast as data grows.
How It Works
Agent-Native apps use Drizzle ORM over PostgreSQL. Local development uses PGlite at data/pglite; production and shared preview deploys need a persistent hosted PostgreSQL DATABASE_URL.
For app code, use Drizzle's schema/query DSL by default. Raw SQL is an escape hatch for additive migrations, health checks, or one-off maintenance, not the normal way to build features.
Typed raw SQL fragments
When Drizzle cannot express a PostgreSQL query, import sql from
@agent-native/core/db and pass its fragment directly to
getDbExec().execute(). Use sql.value(value) for bound values,
sql.ident(name) for validated lowercase identifiers, sql.in(values) for a
nonempty list (it includes parentheses), and sql.join(fragments, separator)
or nested fragments for composition. The tag rejects plain string interpolation
at compile time; do not build { sql: ...${value}... } or pass interpolated
templates directly to execute(). The diff-scoped guard checks new
interpolated SQL reaching getDbExec().execute() through the helper and wrapper
paths it analyzes. A reviewed exception needs // raw-sql-ok: <reason> as
a standalone comment immediately before the sink statement or after it on the
same line. Markers inside SQL text, callbacks, and object properties do not opt
out. The guard does not audit Drizzle sql.raw() or raw adapter query() calls,
so use bound Drizzle fragments or the typed kernel instead of interpolating
dynamic values through those APIs.
Schema and migration ownership
Define PostgreSQL tables with Drizzle's drizzle-orm/pg-core exports and use
drizzle-orm for query operators. Import only framework-owned sharing helpers,
such as ownableColumns() and createSharesTable(), fro
자주 묻는 질문
앱 데이터를 디스크의 파일로 저장할 수 있나요?
보통은 안 됩니다. 특정 파일 모드를 쓰지 않는 한, 지속적인 앱 데이터는 파일 시스템에 두면 안 됩니다.
이미지를 base64 텍스트로 데이터베이스에 저장해야 하나요?
아니요. 파일 내용을 데이터베이스에 저장하는 대신, 설정 안내와 함께 실패하라고 이 스킬은 말합니다.
파일에 대해 데이터베이스에 무엇을 저장하나요?
URL, 에셋 ID 또는 불투명 핸들만 저장합니다.
상세 정보
작성자의 원본 설명
How to store application data in agent-native apps. All data lives in SQL. Use when adding data models, deciding where to store data, or reading/writing application data.
repo: BuilderIO/agent-native
인기도
- GitHub 스타
- 7.6k
- 순위
- #13185
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
design-exploration
7.6k에이전트가 여러 UI 디자인 방향을 나란히 보여 주고, 사용자가 하나를 고르면 그 디자인을 다듬도록 돕습니다.
visual-edit
7.6k에이전트가 실행 중인 로컬 앱을 시각 편집기에 열어, 실제 화면을 함께 검토하고 편집하도록 돕습니다.
turn-into-app
7.6k워크플로, 스프레드시트 또는 프로젝트를 데이터가 채워진 세련된 시각 앱으로 바꾸고, 컨트롤 뒤에서 에이전트가 작업하도록 합니다.
visual-plan
7.6k일반 텍스트 계획을 다이어그램, 파일 맵, 코드 조각, 열린 질문이 담긴 대화형 시각 계획으로 바꿔 줍니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.