dart-drift — скилл для Claude Code: Drift в Dart без Flutter
Скилл для работы с Drift в Dart CLI, серверных и десктопных приложениях без Flutter: таблицы, запросы, миграции, PostgreSQL.
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a claude-codeЧто делает dart-drift
Скилл задаёт агенту роль инженера персистентности на Drift для не-Flutter проектов. Перед написанием кода он требует определить бэкенд: SQLite через package:drift/native.dart для CLI, серверных задач и локального хранилища на десктопе, либо PostgreSQL через drift_postgres и package:postgres с включённым диалектом Postgres в build.yaml. Если задача упирается в интеграцию с Flutter UI, скилл останавливается и отправляет к другому скиллу — flutter-drift.
Внутри — маршрутизация по задачам: отдельные файлы-справочники для настройки, таблиц, запросов, записей, стримов, миграций и PostgreSQL. Агент читает только те, что нужны под конкретную операцию, а не весь набор. Плюс обязательная проверка после правок: dart pub get после смены зависимостей, dart run build_runner build и dart analyze после изменения таблиц и DAO, dart run drift_dev make-migrations и сгенерированные тесты миграций после правок схемы.
Есть жёсткие ограничения. Скилл не поддерживает устаревшие примеры PostgreSQL на HostEndpoint, PgEndpoint, postgres_pool.dart, postgresUuid(), postgresJson() и gen_random_uuid. Для Postgres нельзя брать SQLite-хелперы вроде currentDateAndTime и большинства удобных dateTime() — вместо них PgTypes.date, PgTypes.timestampWithTimezone, PgTypes.timestampNoTimezone и now(). Если проект не даёт понять, SQLite это или PostgreSQL, агент спросит, а не угадает.
Какие задачи решает
- добавить SQLite в Dart CLI через
package:drift/native.dart - настроить PostgreSQL с
drift_postgresиpackage:postgres - написать типобезопасные таблицы и запросы на Drift
- починить падение
build_runnerилиdrift_dev - провести миграцию схемы и прогнать сгенерированные тесты
Примеры запросов агенту
- добавь Drift с SQLite в мой Dart CLI, начни с настройки зависимостей
- опиши таблицу заказов с индексом по дате и напиши запрос выборки за месяц
- схема изменилась — сделай миграцию и прогони тесты миграций
Как установить dart-drift
1Через Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a claude-code2Вручную: положить файлы
~/.claude/skills/dart-drift/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/dart-drift/
1Через Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a codex2Вручную: положить файлы
.agents/skills/dart-drift/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a cursor2Вручную: положить файлы
.cursor/skills/dart-drift/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install MADTeacher/mad-agents-skills dart-drift2Вручную: положить файлы
.github/skills/dart-drift/SKILL.md1Через Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a gemini-cli2Командой платформы
gemini skills install https://github.com/MADTeacher/mad-agents-skills --path dart-driftВручную: положить файлы
.devin/skills/dart-drift/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора10
Похожие
Рядом в теме «Данные и базы»
Все скиллы по теме «Данные и базы» →Вопросы о dart-drift
Как установить dart-drift в Claude?
Выполните npx skills add MADTeacher/mad-agents-skills --skill dart-drift -a claude-code. Файл скилла окажется в ~/.claude/skills/dart-drift/SKILL.md.
Что делает dart-drift?
Помогает агенту писать и чинить код Drift в Dart CLI, серверных и десктопных приложениях без Flutter: таблицы, запросы, записи, стримы, миграции. Отдельно закрывает настройку SQLite и PostgreSQL.
Чем dart-drift отличается от flutter-drift?
dart-drift работает только с не-Flutter кодом и не трогает StreamBuilder, Riverpod, Provider и drift_flutter. Для интеграции с Flutter UI он останавливается и передаёт задачу скиллу flutter-drift.
Исходный текст
SKILL.md · MIT
---
name: dart-drift
description: >-
Build, fix, audit, and migrate Drift persistence in Dart CLI, server-side,
and non-Flutter desktop apps. Use when adding SQLite with
package:drift/native.dart, configuring PostgreSQL with drift_postgres and
package:postgres, writing type-safe tables, queries, writes, streams, and
migrations, resolving build_runner or drift_dev failures, or validating Dart
database code with code generation, analysis, tests, and migration checks.
metadata:
author: Stanislav [MADTeacher] Chernyshev
version: "2.0"
---
# Dart Drift
You are a Dart persistence engineer for non-Flutter apps using Drift.
## Principle 0
Do not write Drift database code from memory. First identify the runtime
backend, read the routed reference for the operation, then verify generated code
with the Dart toolchain. Broken persistence code is worse than no persistence
code because schema and migration mistakes can silently lose data.
## Workflow
1. Inspect the project before changing code: `pubspec.yaml`, existing database
classes, `build.yaml`, generated parts, tests, migration files, and whether
the app targets SQLite, PostgreSQL, or both.
2. Choose the backend path:
- For Dart CLI, server jobs, or native desktop local storage, use SQLite via
`package:drift/native.dart`.
- For server-side PostgreSQL, use `drift_postgres` with `package:postgres`
and enable the Postgres SQL dialect in `build.yaml`.
- For Flutter UI integration, stop and use the `flutter-drift` skill instead.
3. Read only the reference files needed for the requested task.
4. Implement the smallest safe change using the APIs and caveats from those
references.
5. Run mandatory validation. If validation cannot run, report the blocker and
the concrete risk instead of presenting the change as verified.
## Resource Routing
| Task | Read or run | Why |
|---|---|---|
| Add Drift to a Dart app, choose dependencies, open SQLite/Postgres connections, or fix build setup | `references/setup.md` | Current non-Flutter setup and imports |
| Define tables, constraints, indexes, defaults, or PostgreSQL custom types | `references/tables.md` | Schema APIs and backend-specific column caveats |
| Write SELECT, WHERE, JOIN, aggregate, subquery, or custom-column code | `references/queries.md` | Query-builder patterns that compile |
| Insert, update, delete, upsert, batch, or transaction code | `references/writes.md` | Safe write APIs and conflict handling |
| Add or repair reactive streams, custom SQL streams, update notifications, or table update listeners | `references/streams.md` | Drift stream APIs without Flutter UI assumptions |
| Add or change schema migrations | `references/migrations.md` | Guided migrations, generated tests, and migration safety rules |
| Configure PostgreSQL, pooling, custom types, or Postgres-specific functions | `references/postgres.md` | `drift_postgres` and `package:postgres` source of truth |
| Edit this skill or its examples | `scripts/verify-examples.sh` | Deterministic smoke check for the documented patterns |
## Mandatory Validation
- After dependency changes, run `dart pub get`.
- After changing Drift tables, database classes, DAOs, SQL files, or generated
parts, run `dart run build_runner build` and `dart analyze`.
- After changing behavior, run the narrowest relevant `dart test` target. If no
tests exist, add or describe a focused smoke test for the database operation.
- After migration changes, run `dart run drift_dev make-migrations` and the
generated migration tests from the configured `test_dir`.
- After editing this skill, references, or reusable examples, run
`dart-drift/scripts/verify-examples.sh`.
## Constraints
- Keep this skill scoped to Dart CLI, server-side, and non-Flutter desktop apps.
Do not add `StreamBuilder`, Riverpod, Provider, `drift_flutter`, or
Flutter-specific storage patterns here.
- Prefer `dart pub add ...` for new dependencies. Only hardcode versions when
matching an existing repository policy.
- Do not use deprecated PostgreSQL examples based on `HostEndpoint`,
`PgEndpoint`, `postgres_pool.dart`, `postgresUuid()`, `postgresJson()`,
`PostgresTypes`, or `gen_random_uuid`.
- For PostgreSQL, avoid SQLite-only helpers such as `currentDateAndTime` and
most `dateTime()` convenience APIs. Use `PgTypes.date`,
`PgTypes.timestampWithTimezone`, `PgTypes.timestampNoTimezone`, and `now()`.
- Do not replace code generation or migration validation with manual reasoning
unless the user explicitly waives the risk.
## Fallback
If the requested repository lacks enough context to choose a backend, ask
whether the target is SQLite or PostgreSQL. If network, database, or toolchain
access prevents validation, finish with the exact command that failed and the
remaining risk.
© Stanislav [MADTeacher] Chernyshev · MIT · MADTeacher/mad-agents-skills