State Restoration
Generates state preservation and restoration infrastructure for navigation paths, tab...
Install
npx skills add rshankras/claude-code-apple-skills --skill state-restoration -g -a claude-code -y- Repository
- rshankras/claude-code-apple-skills846
- Category
- Design
- Updated
- 3mo ago
- License
- MIT
- Context cost
- Mediumabout 2,394 tokens
- Runs scripts
- No, instructions only
What it does
Generates state preservation and restoration infrastructure for navigation paths, tab selection, scroll positions, and form data across app launches and background termination. Use when user wants to save/restore app state, remember where the user left off, or persist UI state.
State Restoration Generator
Generate production state restoration infrastructure that saves and restores app state (selected tab, scroll position, navigation path, form data) across launches and background termination. Uses Codable state models, @SceneStorage, @AppStorage, and custom file-based persistence.
When This Skill Activates
Use this skill when the user:
- Asks to "add state restoration" or "restore state"
- Wants to "save app state" or "persist UI state"
- Mentions "preserve navigation" or "remember navigation path"
- Asks to "remember scroll position" or "restore scroll position"
- Wants the app to "resume where left off" or "remember where I was"
- Asks about "saving form drafts" or "preserve form data"
- Mentions "tab selection persistence" or "remember selected tab"
Pre-Generation Checks
1. Project Context Detection
- Check Swift version (requires Swift 5.9+)
- Check deployment target (iOS 17+ / macOS 14+ for @Observable)
- Check for existing state saving code
- Identify source file locations
2. Conflict Detection
Search for existing state restoration:
Glob: **/*StateRestoration*.swift, **/*AppState*.swift, **/*SceneStorage*.swift
Grep: "SceneStorage" or "NavigationPath" or "selectedTab" or "scrollPosition"
If existing state management found:
- Ask if user wants to replace or extend it
- If extending, integrate with the existing approach
3. Navigation Pattern Detection
Determine which navigation pattern the app uses:
Grep: "NavigationStack" or "NavigationSplitView" or "TabView" or "NavigationLink"
This affects which restoration components to generate.
Configuration Questions
Ask user via AskUserQuestion:
- What state to restore? (multi-select)
- Navigation path (back stack, detail selection)
- Selected tab (TabView selection)
- Scroll position (list/scroll view offset)
- Form data (unsaved drafts and input fields)
- All of the above, recommended


