dimitriremoiville/cc-mobile/drift-persistence
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
Local database patterns for this Flutter project — drift with sqlcipher, schema definition, DAOs, migrations, watch queries, and repository integration. Load whenever writing or editing a table, DAO, or migration.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/drift-persistenceSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/drift-persistence.
drift + sqlcipher
Encrypted SQLite with a type-safe Dart query API. Schema and DAOs are colocated per feature unless a table is genuinely shared.
Setup
sqlcipher_flutter_libsprovides both SQLite and encryption. Don't also includesqlite3_flutter_libs— they conflict.- The passphrase lives in
flutter_secure_storage. Generate on first launch withcrypto.Random.secure()+ base64. NativeDatabase.createInBackgroundto keep opens off the UI isolate.
Tables
Prefer per-feature table definitions; register them with the central AppDatabase.
Rules:
- Column names:
snake_case(drift generates them from the getter name, but you can override via.named('...')). - Store enums as text, not as int. Enum ordering is a migration hazard.
- DateTimes as `dateTime()` — drift stores ISO-8601, safe across timezones if you always write UTC (
DateTime.now().toUtc()). - Indexes: declare in migration or via
@DataClassNameannotations. Don't skip them — unindexedWHEREon millions of rows is slow even with encryption.
DAOs
Rules:
- One DAO per feature/table-cluster. Don't have a god-DAO.
- Return drift's row types from DAOs; map to domain entities in the repository, not the DAO.
watch*queries are cheap and first-class. Repositories that exposeStream<Either<Failure, T>>usually drive them fromwatch.
Migrations
- Bump
schemaVersionwith every schema change. Never edit a past migration; always add a new step. - Write a schema-roundtrip test: open a DB at version N, then upgrade to N+1, then assert the new column / index exists. Drift's
drift_dev schema dump+drift_dev schema generatemakes this straightforward — commit the schema snapshots underdrift_schemas/. - Destructive migrations (drop column, rename table) need a data copy into a new table, then rename. Don't skip it for "low-risk" columns.
Repository + drift + remote
- Reads can be offline-first (stream from drift, trigger a refresh in the background).
- Writes are optimistic or remote-first, your call per feature — but be consistent within a feature.
- Don't wrap drift exceptions as
NetworkFailure; they'reCacheFailure. Map them in the repo.
Test seams
- Use
NativeDatabase.memory()for unit tests — fast, isolated, no files. - Inject an
AppDatabaseinto repositories, not a DAO globally — makes fakes trivial. - Seed data via helper builders; don't write SQL fixtures.
Don'ts
- Raw SQL scattered across the app. Use drift's DSL; it's type-safe.
- DAO methods returning
dynamicorMap<String, Object?>. Always row types. - Long-running transactions on the UI thread. Drift's background executor covers this by default; don't block it.
- Storing secrets in drift.
flutter_secure_storageexists for a reason. - Skipping migrations because "dev only". Migrations are cheap to add and expensive to add later.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingflutter/.claude/skills/drift-persistence/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/drift-persistence)