Ha IOS Persistence
Developmentha-ios-persistenceHa IOS Persistence is an Agent Skill for development published in the home-assistant/iOS repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Data persistence across GRDB, Realm, and UserDefaults. Use when adding or migrating a persistent model, choosing a storage layer, implementing DatabaseTableProtocol, or reading/writing config for Watch, CarPlay, widgets, or the entity registry.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/home-assistant/iOS/blob/HEAD/.agents/skills/ha-ios-persistence/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/ha-ios-persistence, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Data Persistence
The project uses two database layers:
- GRDB (
GRDB.swift): newer layer, accessed viaCurrent.database(). Used for Watch config, CarPlay config, widget config, entity registry, panels, etc. When adding a new persistent model, prefer GRDB: implementDatabaseTableProtocol(definestableName,definedColumns, andcreateIfNeeded) and register it inDatabaseQueue.tables()inGRDB+Initialization.swift. The protocol'smigrateColumnshelper auto-handles additive migrations. - Realm (
RealmSwift): legacy layer, used for older models (actions, zones, sensors, etc.). Access viaCurrent.realm(). - UserDefaults: simple preferences and watch communication.