generators-state-restoration

Generate SwiftUI state restoration infrastructure for navigation paths, tabs, scroll positions, and form drafts.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill generators-state-restoration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generators-state-restoration
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/generators-state-restoration
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill generators-state-restoration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When users leave an app or the system terminates a scene, the app can lose navigation context, selected tabs, scroll offsets, and in-progress form data; rebuilding that state manually is error-prone and leads to a poor user experience. This skill provides a repeatable, production-ready approach to capture and restore UI state so apps resume exactly where users left off.

Core Features & Use Cases

  • Navigation path persistence: Encode and restore NavigationStack paths so deep-linked or multi-step flows return to the correct screen.
  • Tab selection and scene-aware storage: Persist TabView selection across launches and support per-scene @SceneStorage or shared UserDefaults/file backends.
  • Scroll position and form draft autosave: Track top-visible items and debounce form drafts to Application Support or UserDefaults with clear-on-submit behavior.
  • Restore policies and safety: Time-limited restores, ask-before-restore prompts, state versioning and graceful fallbacks for schema changes.
  • Use Case: Resume a multi-window iPad app with each window restoring its own navigation stack, selected tab, and unsaved draft text after an update or background termination.

Quick Start

Ask the skill to generate a StateRestorationManager, AppState model, and optional modifiers for NavigationStack, TabView, scroll views, and form drafts targeted to your SwiftUI app.

Frequently Asked Questions about generators-state-restoration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I persist navigation path and scroll position in SwiftUI across app launches?

SwiftUI state restoration captures NavigationStack paths, selected tabs, scroll positions, and form drafts using Codable models with @SceneStorage or file-based backends. It encodes UI state deterministically so apps resume exactly where users left off after background termination or scene changes.

What's the best way to restore unsaved form drafts in an iOS app after background termination?

Form draft restoration uses debounced autosave to Application Support or UserDefaults, writing in-progress text periodically and clearing it on submit. This ensures unsaved drafts survive background termination and relaunch without requiring manual snapshot management.

Does state restoration work with per-scene storage for multi-window iPadOS apps?

State restoration supports per-scene @SceneStorage for multi-window iPadOS apps, allowing each window to independently persist and restore its own NavigationStack path, TabView selection, and draft text. Shared UserDefaults or file backends handle cross-scene state when needed.

How do I handle schema changes when restoring saved app state in SwiftUI?

State restoration includes state versioning and graceful fallbacks for schema changes, using Codable models that detect version mismatches and discard incompatible data. Time-limited restore policies and optional ask-before-restore prompts prevent stale or corrupted state from disrupting the user experience.

Can I use Environment-driven integration to restore NavigationStack and TabView state?

Environment-driven integration provides optional modifiers for NavigationStack and TabView that automatically capture and restore selection state. The StateRestorationManager coordinates these modifiers with Codable AppState models to synchronize navigation paths and tab selections across launches.

Why does my SwiftUI app lose its tab selection and navigation stack when the system terminates the scene?

Scene termination loses UI state when navigation paths, tab selections, and scroll offsets are not persisted. Without a StateRestorationManager encoding this data to @SceneStorage or a file backend, the app cannot rebuild the previous context and defaults to its initial view hierarchy.