storing-data
Was er macht
Dieser Skill erklärt, dass eine Agent-Native-App ihre Datensätze in SQL speichert, während große Dateien wie Bilder und Videos in den Dateispeicher gehen. Er richtet sich an Entwickler, die Datenmodelle ergänzen oder App-Daten lesen und schreiben.
Wann du ihn nutzt
- ✓Wenn du ein neues Datenmodell oder eine neue Tabelle zu einer App hinzufügst.
- ✓Wenn du entscheiden musst, ob Daten in die Datenbank oder in Dateien gehören.
- ✓Wenn eine App ein Bild, ein Video oder ein PDF speichern muss.
Link zum Skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/storing-data/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Füge eine Möglichkeit hinzu, vom Nutzer hochgeladene Bilder zu speichern, und halte für jedes Bild einen Eintrag in der Datenbank.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Datensätze und Verweise werden in der Datenbank gespeichert, Binärinhalte laufen über die Werkzeuge des Dateispeichers. In der Datenbank wird nur die zurückgegebene ID oder URL gespeichert.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen
Dürfen App-Daten als Dateien auf der Festplatte gespeichert werden?
Normalerweise nicht. Dauerhafte App-Daten gehören nicht ins Dateisystem, außer in einem bestimmten Dateimodus.
Soll ich Bilder als Base64-Text in der Datenbank speichern?
Nein. Der Skill sagt, mit einem Hinweis zur Einrichtung abzubrechen, statt Dateiinhalte in der Datenbank zu speichern.
Was speichere ich in der Datenbank für eine Datei?
Nur deren URL, Asset-ID oder einen undurchsichtigen Verweis.
Details
Originalbeschreibung des Autors
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
Beliebtheit
- GitHub-Sterne
- 7.6k
- Platz im Ranking
- #13185
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
design-exploration
7.6kHilft deinem Agenten, mehrere UI-Design-Richtungen nebeneinander zu erkunden, dich eine auswählen zu lassen und das gewählte Design danach zu verfeinern.
visual-edit
7.6kHilft deinem Agenten, eine laufende lokale App in einem visuellen Editor zu öffnen, damit du ihre echten Bildschirme gemeinsam prüfen und bearbeiten kannst.
turn-into-app
7.6kVerwandelt einen Arbeitsablauf, eine Tabelle oder ein Projekt in eine ausgearbeitete visuelle App mit gefüllten Bildschirmen und einem Agenten im Hintergrund.
visual-plan
7.6kVerwandelt einen einfachen Textplan in einen interaktiven visuellen Plan mit Diagrammen, Dateiübersichten, Code-Ausschnitten und offenen Fragen.
Ähnliche Skills
discrawl
394kLässt deinen Agenten ein gespeichertes lokales Archiv von Discord-Nachrichten durchsuchen und zusammenfassen, dessen Aktualität prüfen und Direktnachrichten lesen.
clickhouse-io
280kHilft deinem Agenten, Abfragen und Schemas in ClickHouse zu optimieren. Nutzt Best Practices für schnelle Analyse-Workloads. Ideal, wenn Auswertungen zu langsam laufen.
scientific-db-pubmed-database
280kHilft deinem Agenten, wissenschaftliche Artikel im biomedizinischen Bereich zu suchen. Nützlich für Recherchen mit speziellen medizinischen Informationen.