dyor/sparksapp/data-persistence
Claude Code and agent skill by dyor/sparksapp
- community
Checking that the SKILL.md file is still in the repository.
Implement persistent Spark state with Zustand `useSparkStore` in `src/store/appStore.ts`, including safe load/save patterns that avoid hydration overwrite bugs. Use when building or updating any Spark that reads or writes user data across app sessions, especially when adding `getSparkData`/`setSparkData` logic, migrating from local storage patterns, or debugging data-loss after app restart.
Install
npx vskill@latest install dyor/sparksapp/data-persistenceSKILL.md
The same SKILL.md was published earlier as dyor/sparksapp/data-persistence.
Data Persistence
Use the centralized Spark store for all persisted Spark data.
Apply The Core Rule
Use useSparkStore for persisted Spark state.
- Import from
src/store/appStore.ts. - Read with
getSparkData(sparkId). - Write with
setSparkData(sparkId, data). - Do not call
@react-native-async-storage/async-storagedirectly in Spark components.
Prevent Hydration Overwrite
Guard all save effects with a dataLoaded flag to prevent overwriting stored data during async hydration.
- Initialize local guard state.
- Load persisted data from
getSparkDatain a mount/load effect. - Set
dataLoadedtotrueonly after load handling completes. - Return early from save effects while
dataLoadedisfalse.
Use this pattern:
Use Save/Load Checklist
Before merging persistence changes, verify all of the following:
- Spark uses a stable
sparkIdkey. - Initial render does not write default empty data.
- Save effect is guarded by
dataLoaded. - Load effect sets
dataLoadedafter load logic finishes. - No direct AsyncStorage usage in Spark component code.
Respect Gemini Key Precedence
When working on AI-related Sparks, preserve the key hierarchy implemented in src/services/GeminiService.ts:
- User custom Gemini API key (stored via
useSparkStore). - App default Sparks key fallback.
Do not re-implement this precedence inside individual Sparks unless a change to the global service is explicitly required.
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 repositoryCheckingCONTEXT/GENERAL/skills/data-persistence/SKILL.md
Popularity
- 7-day trend score
- 5
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/dyor/sparksapp/data-persistence)