data-flow

data-flow is a skill for Claude Code from rshankras/claude-code-apple-skills. It costs 83 tokens per session (2,005 once invoked), scanned A, original, MIT.

A guide to how SwiftUI decides when views are created, kept, updated, and redrawn. It explains state ownership, per-property change tracking, animation identity, and the main-actor rule for UI code.

In plain words
What is it for?
Use it to debug SwiftUI data-flow and rendering problems, choose where state should live, fix list and animation behavior, and inspect unnecessary view updates.
Why use it?
It helps explain state that unexpectedly resets, views that redraw too often, flashing lists, broken animations, and concurrency warnings. It gives a mental model for choosing between SwiftUI's state and data-sharing tools.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the apple-skills plugin — 182 skills shipped together , and of apple-skills

Good fit Use it to debug SwiftUI data-flow and rendering problems, choose where state should live, fix list and animation behavior, and inspect unnecessary view updates.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rshankras/claude-code-apple-skills/data-flow
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rshankras/claude-code-apple-skills --skill data-flow
Clone the repo
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills

Made for: Claude Code.

Or install apple-skills, the plugin that ships this one along with the rest of its 182 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for data-flow

README.md
[![agentmods](https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/data-flow/github.svg)](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/data-flow)
Your own site
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/data-flow"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/data-flow/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for data-flow

Your own site · 80×15
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/data-flow"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/data-flow.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,005 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00083 $0.02005
Opus 5.5 $0.00033 $0.00802
Sonnet 5.5 $0.00017 $0.00401
Haiku 4.5 $0.00008 $0.00200

Measured 2d ago against content hash f6f4a1e4b76d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

data-flow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/swiftui/data-flow/SKILL.md · 145 lines

How it starts

The opening of the file, as written. The whole thing — 145 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 —

    // ❌ 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

Read the full file on GitHub · 145 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 145 lines · 83 tokens per session scan A f6f4a1e4b76d

Subscribe to this mod's changes

data-flow is a skill published in the GitHub repository rshankras/claude-code-apple-skills (864 stars, last pushed 2d ago), licensed MIT. It adds 83 tokens to every session and 2,005 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.

Related

data-flow compared with skills from other repositories

data-flow next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
data-flowrshankras/claude-code-apple-skillsSkill8642d agoMITA83Claude Code
swift-expertpersonamanagmentlayer/pclSkill4411d agoApache-2.0A76Claude Code
ios-expertpersonamanagmentlayer/pclSkill4411d agoApache-2.0A64Claude Code
ios-swiftui-productJasonColapietro/ios-app-dev-skillsSkill92mo agoMITA67Codex
swiftui-maxDev869/swift-tothemaxSkill74mo agoMITA271Claude Code
apple-dev-conductorDev869/swift-tothemaxSkill74mo agoMITA156Claude Code
kotlin-patternssoftspark/ai-toolkitSkill17910d agoApache-2.0A51Claude Code