home / skills / willsigmon / sigstack / preferences-store-expert
This skill helps manage user preferences with SwiftData persistence and async observations, providing a single source of truth through load, update, and
npx playbooks add skill willsigmon/sigstack --skill preferences-store-expertReview the files below or copy the command above to add this skill to your agents.
---
name: Preferences Store Expert
description: Work with Leavn PreferencesStore - SwiftData persistence, snapshot patterns, async observation, entity relationships, migration from UserDefaults
allowed-tools: Read, Edit, Grep
---
# Preferences Store Expert
Expert in PreferencesStore architecture:
**Pattern**:
- Entities in SwiftData
- Snapshots (Sendable, Codable)
- Async observation
- Single source of truth
**Key files**:
- PreferencesStore.swift
- PreferenceModels.swift
- PreferencesStore+{Domain}.swift extensions
**Operations**:
- `loadX()` → snapshot
- `updateX { }` → mutation
- `observeSnapshots()` → AsyncStream
Use when: Preferences issues, settings persistence, SwiftData, user data
This skill provides deep expertise working with a PreferencesStore built on SwiftData, focusing on a single-source-of-truth preferences architecture. It covers entity modeling, Sendable/Codable snapshot patterns, async observation, and migration strategies from UserDefaults. The goal is reliable, testable, and concurrency-safe user settings persistence.
The store persists domain-specific preference entities in SwiftData and exposes immutable snapshots that are Sendable and Codable for safe cross-thread use. It offers loadX() methods to produce current snapshots, updateX { } mutation blocks for coordinated writes, and observeSnapshots() that returns an AsyncStream of snapshots for reactive UI/logic. Extensions split domain concerns into PreferencesStore+{Domain}.swift for clean separation and testability.
How do snapshots help with concurrency?
Snapshots are immutable, Sendable, and Codable so they can be safely sent across threads and used in async contexts without risking data races.
When should I migrate from UserDefaults?
Migrate when preferences require relationships, stronger typing, versioned schemas, or when you need transactional updates and async observation.