Pular para o conteúdo
Skillpedia
Bancos de dados7,6 mil · #13185

storing-data

O que ela faz

Esta skill explica que um aplicativo Agent-Native mantém seus registros em SQL, enquanto arquivos grandes, como imagens e vídeos, vão para o armazenamento de arquivos. É para desenvolvedores que acrescentam modelos de dados ou leem e gravam dados do aplicativo.

Quando usar

  • ✓Quando você acrescenta um novo modelo de dados ou uma nova tabela a um aplicativo.
  • ✓Quando você precisa decidir se um dado deve ir para o banco de dados ou para arquivos.
  • ✓Quando um aplicativo precisa salvar uma imagem, um vídeo ou um PDF.

Link da skill

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

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/storing-data/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Acrescente uma forma de salvar imagens enviadas pelos usuários, e mantenha um registro de cada imagem no banco de dados.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

Registros e referências são armazenados no banco de dados, e o conteúdo binário passa pelas ferramentas de armazenamento de arquivos. Apenas o ID ou a URL retornados são salvos no banco de dados.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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

Perguntas frequentes

Os dados do aplicativo podem ser salvos como arquivos no disco?

Normalmente não. Dados duráveis do aplicativo não devem ir para o sistema de arquivos, a menos que um modo de arquivo específico seja usado.

Devo guardar imagens como texto base64 no banco de dados?

Não. A skill diz para falhar com orientações de configuração, em vez de guardar o conteúdo dos arquivos no banco de dados.

O que salvar no banco de dados para um arquivo?

Apenas a sua URL, o ID do recurso ou um identificador opaco.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
7,6 mil
Posição no ranking
#13185
Licença
MIT
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas