Aller au contenu
Skillpedia
Bases de données7.6k · #13185

storing-data

Ce qu’il fait

Cette compétence explique qu'une application Agent-Native conserve ses enregistrements en SQL, tandis que les gros fichiers comme les images et les vidéos vont dans un stockage de fichiers. Elle s'adresse aux développeurs qui ajoutent des modèles de données ou lisent et écrivent les données de l'application.

Quand l’utiliser

  • ✓Quand vous ajoutez un nouveau modèle ou une nouvelle table de données à une application.
  • ✓Quand vous devez décider si une donnée doit aller dans la base ou dans des fichiers.
  • ✓Quand une application doit enregistrer une image, une vidéo ou un PDF.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/storing-data/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Ajoute un moyen d'enregistrer les images envoyées par les utilisateurs, et garde une trace de chaque image dans la base de données.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

Les enregistrements et les références sont stockés dans la base de données, et le contenu binaire passe par les outils de stockage de fichiers. Seuls l'identifiant ou l'URL renvoyé est enregistré dans la base.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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

Questions fréquentes

Les données de l'application peuvent-elles être enregistrées comme fichiers sur le disque ?

Normalement non. Les données durables ne doivent pas être stockées dans le système de fichiers, sauf mode de fichier spécifique.

Faut-il stocker les images en base64 dans la base de données ?

Non. La compétence indique d'échouer avec des conseils de configuration plutôt que de stocker le contenu des fichiers dans la base.

Que faut-il enregistrer dans la base pour un fichier ?

Seulement son URL, son identifiant d'actif ou son descripteur opaque.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
7.6k
Position au classement
#13185
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires