davidortinau/maui-skills/maui-sqlite-database
Claude Code and agent skill by davidortinau/maui-skills
- community
Checking that the SKILL.md file is still in the repository.
Add SQLite local database storage to .NET MAUI apps using sqlite-net-pcl. Covers data models with ORM attributes, async database service with lazy init, DI registration, WAL mode, and file management. Works with any UI pattern (XAML/MVVM, C# Markup, MauiReactor). USE FOR: "SQLite database", "local database", "sqlite-net-pcl", "offline storage", "CRUD database", "database service", "WAL mode", "CreateTableAsync", "local data persistence", "ORM attributes". DO NOT USE FOR: REST API data fetching (use maui-rest-api), secure credential storage (use maui-secure-storage), or file picking (use maui-file-handling).
Install
npx vskill@latest install davidortinau/maui-skills/maui-sqlite-databaseSKILL.md
SQLite Database — Gotchas & Best Practices
For full service implementation, constants, data model templates, and common patterns, see references/sqlite-database-api.md.
⚠️ Wrong Package Trap
Common Mistakes
❌ Using Environment.GetFolderPath for Database Path
❌ Multiple SQLiteAsyncConnection Instances
SQLiteAsyncConnection is not thread-safe for multiple instances pointing at the same file. Use a single instance via DI singleton:
❌ Forgetting WAL Mode
Without WAL, readers block writers. Always enable it at initialization:
❌ File Operations on Open Database
Platform Pitfalls
| Platform | Pitfall | |
|---|---|---|
| iOS | FileSystem.AppDataDirectory is iCloud-backed — use FileSystem.CacheDirectory to exclude DB from iCloud backup | |
| All | Multiple SQLiteAsyncConnection instances to same file → data corruption | |
| All | No WAL → readers block writers, poor concurrent performance | |
| All | File operations on open DB → corruption |
Decision Framework
| Question | Recommendation | |
|---|---|---|
| DI lifetime? | Singleton — one connection, WAL handles concurrent reads | |
| WAL mode? | Always enable — no reason not to on mobile | |
| Database path? | FileSystem.AppDataDirectory — never Environment.GetFolderPath | |
| Save pattern? | Check Id != 0 → Update, else Insert | |
| Multiple tables? | Add all CreateTableAsync<T>() calls in lazy init | |
| Need to export/backup? | Close connection first, then File.Copy |
Performance Tips
- Use transactions for batch writes — individual inserts are slow; wrap in
RunInTransactionAsync - Add `[Indexed]` to frequently queried columns — especially foreign keys
- WAL mode eliminates reader/writer contention
- Avoid `ToListAsync()` on large tables — use
Where()filtering and pagination - Use raw SQL for complex queries —
QueryAsync<T>is faster than chained LINQ for joins
Checklist
- [ ] Install
sqlite-net-pcl+SQLitePCLRaw.bundle_green(notMicrosoft.Data.Sqlite) - [ ] Database path uses
FileSystem.AppDataDirectory - [ ] Models have
[PrimaryKey, AutoIncrement] - [ ] Single
DatabaseServicewith lazy async init pattern - [ ] WAL enabled via
PRAGMA journal_mode=WAL - [ ]
DatabaseServiceregistered as singleton in DI - [ ] Connection closed before any file move/copy/delete
- [ ] iOS: DB excluded from iCloud backup if needed
Security
- Security scanPassed, 100 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 repositoryCheckingplugins/maui-skills/skills/maui-sqlite-database/SKILL.md
Popularity
- Repository stars
- 131
- Repository forks
- 16
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 3 May 2026, 6 months ago.
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/davidortinau/maui-skills/maui-sqlite-database)