SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and…

MITAuto-check passedMobile

Install Data Flow

skills CLI
$ npx skills add rshankras/claude-code-apple-skills --skill data-flow -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rshankras/claude-code-apple-skills data-flow --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/swiftui/data-flow .claude/skills/data-flow && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
data-flow
GitHub stars
781
Token cost
~2.1k tokens
SKILL.md length
902 words
Files
1
Skills in repo
46
Repo updated
First seen
Licence
MIT

At a glance

SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and…

  • State resets mysteriously
  • SKILL.md covers When This Skill Activates, Identity: the root concept, Lifetime: state is tied to… and ForEach identifier rules (the…, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Views re-render too often

What it does

Data Flow is an agent skill from rshankras/claude-code-apple-skills. SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and the main-actor concurrency contract. Use when state resets mysteriously, views re-render too often, animations glitch between branches, choosing @State vs @Bindable vs plain property, or debugging "why did body run."

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering iOS development. It works with SwiftUI. The repository describes itself as: Claude Code skills for Apple platform development (iOS, macOS, iPadOS) — product validation, code generation, App Store optimization, and more. The licence is MIT.

When your agent uses it

  • State resets mysteriously
  • Views re-render too often
  • Animations glitch between branches
  • Choosing @State vs @Bindable vs plain property

Example prompts

  • “why did body run.”
  • “/data-flow”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Edit, Glob, Grep

What it can do on your machine

Read from SKILL.md and the folder at commit 9ffb831. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are swift).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • developer.apple.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Data Flow loads about 2.1k tokens when it runs. Until then it costs about 106 tokens; SKILL.md has 902 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~106
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rshankras/claude-code-apple-skills at commit 9ffb831, republished under its MIT licence (© rshankras). 902 words, ~2,060 tokens.

Download SKILL.mdSave it as .claude/skills/data-flow/SKILL.md (or your agent's skills folder).
name
data-flow
description
SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and the main-actor concurrency contract. Use when state resets mysteriously, views re-render too often, animations glitch between branches, choosing @State vs @Bindable vs plain property, or debugging "why did body run."
allowed-tools
Read, Write, Edit, Glob, Grep
last_verified
2026-07-16
review_by
2027-06-22
os_version
iOS 27 / macOS 27

SwiftUI Data Flow

Nearly every confusing SwiftUI bug — state that resets, animations that crossfade instead of move, lists that flash, bodies that run constantly — traces to identity, lifetime, or dependencies. This is Apple's own mental model (the Demystify sessions + Data Essentials + Observation), current through the WWDC26 @State macro.

When This Skill Activates

  • "@State resets when…" / state loses its value on a condition change
  • Views re-render too often; animations crossfade when they should move
  • Lists flashing, rows reordering wrongly, ForEach misbehaving
  • Choosing between @State, @Binding, @Bindable, @Environment, plain property
  • Debugging with Self._printChanges(); concurrency warnings in view code

Identity: the root concept

SwiftUI sees three things: identity, lifetime, dependencies. Views with the same identity are "different states of the same conceptual UI element"; distinct identities are distinct views.

  • Structural identity = type + position in the hierarchy. An if/else creates two identities (_ConditionalContent) — flipping the branch destroys/recreates the view: state resets, transitions crossfade instead of animating.

  • Explicit identity = id: in ForEach or .id(_:) (also the target for ScrollViewReader.scrollTo). Changing an explicit id is a new identity — new lifetime, fresh state. (That's the .id(item.id) force-refresh trick — use it knowingly.)

  • The inert-modifier rule (the most under-used fix): prefer one view whose modifiers vary over branching —

    swift
    // ❌ two identities; state resets, transition crossfades
    if expired { content.opacity(0.3) } else { content }
    // ✅ one identity; cheap, pruned when inert
    content.opacity(expired ? 0.3 : 1.0)

    Inert values (opacity 1, padding 0) cost nothing. "By default, try to preserve identity."

  • Conditionally include a view inside a stack rather than conditionally wrapping the stack.

Lifetime: state is tied to identity

  • View values are ephemeral — created for comparison, then destroyed. Never rely on the struct instance; identity provides continuity.
  • "Whenever the identity changes, the state is replaced" — @State/@StateObject storage tears down and reinitializes. If state "randomly resets," find the identity change.
  • WWDC26: @State is a macro with lazy initialization of @Observable classes (backported to iOS 17) — the stored object initializes once per lifetime, not on every view-value init. Remove default values when also assigning in init (source-breaking edge).

ForEach identifier rules (the flashing-list checklist)

  • Stable — never var id = UUID() computed per access (everything flashes/reanimates).
  • Not indices — insert-at-front reads as insert-at-end; rows animate wrongly.
  • Unique — duplicate IDs drop rows.
  • Use persistent/database-derived IDs; that's what Identifiable is for. Range ForEach (0..<n) only with a constant range.
  • Constant views per element: an if filter inside ForEach (0-or-1 views) or AnyView forces List to resolve every row just to count them. Filter in the data, and cache the filtered collection in the model — an inline .filter re-runs linearly on every body.
  • List/Table gather all identifiers eagerly — cheap IDs = fast loads.

Dependencies: the graph, not the tree

  • Every piece of data read in body is a dependency; only views whose dependency changed re-run, and value comparison prunes unchanged subtrees. Stable identity is "the backbone of the dependency graph."
  • Scope dependencies tightly: pass the subview what it renders (the Image, not the whole model). Extracting subviews is free — "breaking up one view into multiple doesn't hurt performance" — and shrinks invalidation scope.
  • Observation (@Observable) tracks per property, per instance — a view re-renders only when a property it actually read changes, including through computed properties, arrays, optionals, and nesting.
  • Migration from ObservableObject: drop conformance + @Published → @Observable; @ObservedObject → delete or @Bindable; @EnvironmentObject → @Environment. Invalidation narrows from whole-object to read-properties — a free performance win.
Show full SKILL.md (377 more words)Show less

State ownership: the decision rules

Ask Apple's three questions: what data does the view need · how does it manipulate it · where does truth live?

SituationUse
Display-only, parent owns itplain let property
Transient, view-local UI state@State (group related fields into one struct with mutating methods)
Write access to someone else's truth@Binding (bindings compose: $config.note)
Observable model owned by this view@State (lazy-init since WWDC26 macro)
Observable model, needs $model.field bindings only@Bindable
Observable model, globally available@Environment
Observable model, none of the aboveplain property
  • ❌ Never allocate a reference-type model inline as an @ObservedObject default — every re-run reallocates it (heap churn, data loss); use @StateObject or @State + @Observable.
  • ❌ Two siblings each holding @State for the same value desync — lift state to the container and hand children Bindings.
  • @SceneStorage (restoration state, per window) and @AppStorage (settings) are stores next to your model, not the model. Limit total sources of truth.

Body discipline

  • Body must be a pure function, free of side effects — no allocation, I/O, filtering, or string-building; move loading to .task { await … }.
  • Debug why body ran with Self._printChanges() (or expression Self._printChanges() at an LLDB breakpoint): @self = view value changed; a named property = that dependency changed. Debug-only — never ship it. Deeper workflow: performance/swiftui-debugging.
  • ❌ AnyView hides structure from SwiftUI (worse diagnostics/performance) — use @ViewBuilder helpers and switch instead.

Concurrency contract (WWDC25)

  • View is @MainActor: body, @State, members, and Task { } created in body are all main-actor — most view code needs zero annotations (and Swift 6.2's default-isolation mode removes the rest).
  • SwiftUI runs some of your closures off-main — Shape.path(in:), Layout methods, visualEffect, onGeometryChange — that's why they're Sendable. Don't touch self.someState there; copy the value in the capture list ([pulse]) and compute from the proxies SwiftUI hands you.
  • Every await can resume after the frame deadline, so time-sensitive state (gesture/scroll reactions, button loading indicators) must mutate synchronously before starting async work. Bridge UI↔async through a piece of state; keep view Tasks minimal ("inform the model") so async logic stays unit-testable.

Output Format

Data-flow review: Symptom | Root cause (identity / lifetime / dependency / ownership) | Fix — check identity first; it explains most of the rest.

References

© rshankras, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/swiftui/data-flow of rshankras/claude-code-apple-skills.

Open the folder on GitHubat commit 9ffb831

Compare with similar skills

Data Flow next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Data Flow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Data Flow this skillrshankras/claude-code-apple-skills781—~2.1kAutomated safety check: PassMIT
Swiftui Protwostraws/SwiftUI-Agent-Skill5k2 repos~1kAutomated safety check: PassMIT
Swiftui UI PatternsAFK-surf/OpenBridge4304 repos~887Automated safety check: PassMIT
Swiftui Performance Auditharperreed/dotfiles3348 repos~1.4kAutomated safety check: PassNone
Hig Project Contextraintree-technology/hig-doctor1425 repos~1.2kAutomated safety check: PassMIT
Hig Components Contentraintree-technology/hig-doctor1425 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Swiftui Pro

    twostraws/SwiftUI-Agent-Skill

    Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance.

    5k GitHub starsUsed in 2 repos~1k tokens
    MobileAuto-check passed
  • Swiftui UI Patterns

    AFK-surf/OpenBridge

    Best practices and example-driven guidance for building SwiftUI views and components.

    430 GitHub starsUsed in 4 repos~887 tokens
    MobileAuto-check passed
  • Swiftui Performance Audit

    harperreed/dotfiles

    Audit and improve SwiftUI runtime performance from code review and architecture.

    334 GitHub starsUsed in 8 repos~1.4k tokens
    MobileAuto-check passed
  • Hig Project Context

    raintree-technology/hig-doctor

    Create or update a shared Apple design context document that other HIG skills use to tailor guidance.

    142 GitHub starsUsed in 5 repos~1.2k tokens
    MobileAuto-check passed
  • Hig Components Content

    raintree-technology/hig-doctor

    Apple Human Interface Guidelines for content display components.

    142 GitHub starsUsed in 5 repos~1.3k tokens
    MobileAuto-check passed
  • Chunui

    liseami/ChunUI

    Build iOS apps with the ChunUI design system (Monochrome texture extracted from the production app Zinner/Chat0IM).

    523 GitHub stars~642 tokensUpdated 14 days ago
    MobileAuto-check passed

More from rshankras/claude-code-apple-skills

All 46 skills in this repo
  • Accessibility Generator

    rshankras/claude-code-apple-skills

    Generate accessibility infrastructure for VoiceOver, Dynamic Type, and accessibility features.

    781 GitHub stars~1.4k tokensUpdated 2 mo ago
    Auto-check: notes
  • Animation Patterns

    rshankras/claude-code-apple-skills

    SwiftUI animation patterns including springs, transitions, PhaseAnimator, KeyframeAnimator, SF Symbol effects, scroll-driven effects, mesh gradients, text renderers, and shader effects.

    781 GitHub stars~2.1k tokensUpdated 2 mo ago
    Auto-check passed
  • App Description Writer

    rshankras/claude-code-apple-skills

    Generate compelling App Store descriptions that convert browsers into users.

    781 GitHub stars~1.3k tokensUpdated 2 mo ago
    Auto-check passed
  • App Icon Generator

    rshankras/claude-code-apple-skills

    Generates an app icon for macOS or iOS — a fast CoreGraphics placeholder and/or flat layered source art to finish in Icon Composer (the Liquid Glass / iOS 26+ standard).

    781 GitHub stars~5.1k tokensUpdated 2 mo ago
    Auto-check: notes
  • App Namer

    rshankras/claude-code-apple-skills

    Turn an app idea into validated, App-Store-ready name candidates.

    781 GitHub stars~3.4k tokensUpdated 2 mo ago
    Auto-check passed
  • Bundles And Licensing

    rshankras/claude-code-apple-skills

    Revenue beyond the single-app price tag — own-app bundles, Family Sharing as a conversion lever, cross-developer bundles & suites, and institutional licensing via Group Purchases / Apple School &…

    781 GitHub stars~1.8k tokensUpdated 2 mo ago
    Auto-check passed

Works with

Categories

Questions about Data Flow

What does Data Flow do?

SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and…. Data Flow is an agent skill from rshankras/claude-code-apple-skills. SwiftUI's actual mental model — view identity, lifetime, and dependencies (the Demystify canon), state ownership decision rules, Observation's per-property tracking, body-performance discipline, and the main-actor concurrency contract.

When should I use Data Flow?

Data Flow fits situations like: state resets mysteriously; views re-render too often; animations glitch between branches; choosing @State vs @Bindable vs plain property.

How do I install Data Flow in Claude Code?

Run `npx skills add rshankras/claude-code-apple-skills --skill data-flow -a claude-code`. Or copy the skill folder (skills/swiftui/data-flow in rshankras/claude-code-apple-skills) into .claude/skills/data-flow in your project. Claude Code loads it when a task matches its description.

How do I install Data Flow in Codex?

Run `npx skills add rshankras/claude-code-apple-skills --skill data-flow -a codex`. Or copy the skill folder (skills/swiftui/data-flow in rshankras/claude-code-apple-skills) into .agents/skills/data-flow in your project. Codex loads it when a task matches its description.

Can I use Data Flow in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rshankras/claude-code-apple-skills --skill data-flow -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/data-flow, .gemini/skills/data-flow, .github/skills/data-flow and .opencode/skills/data-flow in your project.

What does Data Flow need to run?

SKILL.md names no scripts, command-line tools or credentials: Data Flow is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Edit, Glob, Grep.

Does Data Flow access the network?

SKILL.md names 1 domain. As links in the text: developer.apple.com. This is read from the text; nothing was executed.

Is Data Flow safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Data Flow use?

Data Flow is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Data Flow use?

About 2.1k tokens (SKILL.md is roughly 8.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Data Flow?

Skills that share tags, products or a category with Data Flow: Swiftui Pro (twostraws/SwiftUI-Agent-Skill, 5k stars), Swiftui UI Patterns (AFK-surf/OpenBridge, 430 stars), Swiftui Performance Audit (harperreed/dotfiles, 334 stars) and Hig Project Context (raintree-technology/hig-doctor, 142 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Data Flow?

rshankras (a GitHub user) maintains it in rshankras/claude-code-apple-skills, which has 781 GitHub stars. The repository holds 46 skills in this directory. The repository was last updated on July 24, 2026.

Source: rshankras/claude-code-apple-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.