state-restoration
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.
What this skill does
# 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:
1. **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
2. **Storage method?**
- @SceneStorage / @AppStorage (simple, per-scene, limited to basic types)
- UserDefaults (shared across scenes, limited size)
- File-based (Codable to JSON file in Application Support — recommended for complex state)
3. **Restore behavior?**
- Always restore (seamless resume on every launch)
- Time-limited (restore only if last session was within N minutes) — recommended
- Ask user (show "Resume where you left off?" prompt)
## Generation Process
### Step 1: Read Templates
Read `templates.md` for production Swift code.
### Step 2: Create Core Files
Generate these files:
1. `AppState.swift` — Codable struct capturing all restorable state
2. `StateRestorationManager.swift` — @Observable manager with auto-save and restore
### Step 3: Create Feature Files
Based on configuration:
3. `NavigationStateModifier.swift` — If navigation path selected
4. `ScrollRestorationModifier.swift` — If scroll position selected
5. `TabRestorationModifier.swift` — If tab selection selected
6. `FormDraftManager.swift` — If form data selected
### Step 4: Determine File Location
Check project structure:
- If `Sources/` exists -> `Sources/StateRestoration/`
- If `App/` exists -> `App/StateRestoration/`
- Otherwise -> `StateRestoration/`
## Output Format
After generation, provide:
### Files Created
```
StateRestoration/
├── AppState.swift # Codable state model
├── StateRestorationManager.swift # Auto-save/restore orchestrator
├── NavigationStateModifier.swift # Navigation path persistence (optional)
├── ScrollRestorationModifier.swift # Scroll position persistence (optional)
├── TabRestorationModifier.swift # Tab selection persistence (optional)
└── FormDraftManager.swift # Form draft auto-save (optional)
```
### Integration Steps
**Basic setup in App struct:**
```swift
@main
struct MyApp: App {
@State private var stateManager = StateRestorationManager()
var body: some Scene {
WindowGroup {
ContentView()
.environment(stateManager)
}
}
}
```
**Restore navigation path:**
```swift
struct ContentView: View {
@Environment(StateRestorationManager.self) private var stateManager
var body: some View {
@Bindable var sm = stateManager
NavigationStack(path: $sm.navigationPath) {
HomeView()
.navigationDestination(for: Route.self) { route in
RouteView(route: route)
}
}
.modifier(NavigationStateModifier(stateManager: stateManager))
}
}
```
**Restore tab selection:**
```swift
struct MainTabView: View {
@Environment(StateRestorationManager.self) private var stateManager
var body: some View {
@Bindable var sm = stateManager
TabView(selection: $sm.selectedTab) {
HomeTab().tag(0)
SearchTab().tag(1)
ProfileTab().tag(2)
}
.modifier(TabRestorationModifier(stateManager: stateManager))
}
}
```
**Restore scroll position:**
```swift
struct ItemListView: View {
let items: [Item]
var body: some View {
ScrollView {
LazyVStack {
ForEach(items) { item in
ItemRow(item: item)
}
}
}
.modifier(ScrollRestorationModifier(scrollViewID: "item-list"))
}
}
```
**Auto-save form drafts:**
```swift
struct ComposeView: View {
@State private var draftManager = FormDraftManager(formID: "compose")
@State private var title = ""
@State private var body = ""
var body: some View {
Form {
TextField("Title", text: $title)
TextEditor(text: $body)
}
.onAppear { draftManager.restore(into: &title, &body, keys: "title", "body") }
.onChange(of: title) { draftManager.save(key: "title", value: title) }
.onChange(of: body) { draftManager.save(key: "body", value: body) }
.onSubmit { draftManager.clearDraft() }
}
}
```
### Testing
```swift
@Test
func stateRestoredFromDisk() async throws {
let manager = StateRestorationManager(storage: .file(directory: tempDir))
manager.selectedTab = 2
manager.saveState()
let restored = StateRestorationManager(storage: .file(directory: tempDir))
restored.restoreState()
#expect(restored.selectedTab == 2)
}
@Test
func timeLimitedRestoreExpires() async throws {
let manager = StateRestorationManager(
storage: .file(directory: tempDir),
restoreBehavior: .timeLimited(minutes: 30)
)
// Simulate state saved 60 minutes ago
manager.appState.lastSavedDate = Date().addingTimeInterval(-3600)
manager.saveState()
let restored = StateRestorationManager(
storage: .file(directory: tempDir),
restoreBehavior: .timeLimited(minutes: 30)
)
restored.restoreState()
#expect(restored.selectedTab == 0) // Default, not restored
}
@Test
func formDraftClearedOnSubmit() async throws {
let draft = FormDraftManager(formID: "test", storage: .file(directory: tempDir))
draft.save(key: "title", value: "My Draft")
#expect(draft.value(for: "title") == "My Draft")
draft.clearDraft()
#expect(draft.value(for: "title") == nil)
}
```
## Common Patterns
### Save Navigation Path with Codable Routes
```swift
enum Route: Codable, Hashable {
case detail(id: UUID)
case settings
case profile(userID: String)
}
// NavigationPath supports Codable serialization
let representation = navigationPath.codable
let data = try JSONEncoder().encode(representation)
```
### Restore Tab Selection with String Tags
```swift
// Use String tags instead of Int for readability and stability
TabView(selection: $stateManager.selectedTab) {
HomeView().tag("home")
SearchView().tag("search")
ProfileView().tag("profile")
}
```
### Preserve Form Draft with Debounced Save
```swift
// Save draft only after user pauses typing (1 second)
.onChange(of: textContent) {
draftRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.