swiftui-ui-patterns
Skill430 starsChanged 6 months agoMITView on GitHub
Best practices and example-driven guidance for building SwiftUI views and components. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens, or needing component-specific patterns and examples.
21 other projects use a version of this, 16 of them edited.
Adopted by
Most recently taken up by
- lingyired/status-trioedited, first seen Nov 8, 2026
- MMACABRE/SKILLSedited, first seen Nov 8, 2026
- tornikegomareli/Skillsedited, first seen Nov 8, 2026
- VelimirMueller/claude-skillsedited, first seen Nov 1, 2026
- VelimirMueller/ai-development-skillsedited, first seen Nov 1, 2026
- deonmenezes/mobile-app-skilledited, first seen Nov 1, 2026
Used with
Projects with it also use swiftui-pro.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
kingsidharthSkillswiftui-pro
Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance. Use when reading, writing, or reviewing SwiftUI projects.
Also in 5 projects that use this
Other versions21 projects use a version of this.
Word for word · 4
- eugenepyvovarov/mcpbundler-agent-skills-marketplace★ 12100% same
- 199-biotechnologies/swiftui-claude-skills★ 7100% same
- GalvinGao/skills★ 1100% same
- Samueladewole/claude-skills★ 0100% same
Edited · 16
- openai/plugins★ 7.8k29% same
- Dimillian/Skills★ 4k31% same
- lingyired/status-trio★ 1.8k31% same
- omarshahine/HomeClaw★ 19130% same
- robinebers/skills★ 4829% same
- VelimirMueller/ai-development-skills★ 731% same
- VelimirMueller/claude-skills★ 731% same
- deonmenezes/mobile-app-skill★ 431% same
- Adhamxon/claude-code-skills★ 231% same
- ParkerRex/Skills★ 298% same
6 more not listed
Wrote their own version · 1
- ai4brands-design/claude-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- macos/AGENTS.mdAGENTS.md
- sandbox-vm/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- macos/CLAUDE.mdCLAUDE.md
- sandbox-vm/CLAUDE.mdCLAUDE.md
- app-store-changelogSkill
- bridge-agent-log-analyzerSkill
- gh-issue-fix-flowSkill
- githubSkill
- react-component-performanceSkill
- swift-concurrency-expertSkill
- swift-concurrencySkill
- swift-testing-expertSkill
- swiftui-expert-skillSkill
- swiftui-performance-auditSkill
- swiftui-view-refactorSkill
The file
We split this skill into the rules it gives an agent
11 rules. 3 are common, 1 is distinctive, and 7 are very specific to this project.
3
Common
Most of the 17 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Start with references/app-scaffolding-wiring.md to wire TabView + NavigationStack + sheets.
- Very specific: line 23
Add a minimal AppTab and RouterPath based on the provided skeletons.
- Very specific: line 29
Use modern SwiftUI state (@State, @Binding, @Observable, @Environment) and avoid unnecessary view models.
- Common: line 30
Prefer composition; keep views small and focused.
- Very specific: line 31
Use async/await with .task and explicit loading/error states.
- Common: line 33
Follow the project's formatter and style guide.
- Very specific: line 34
Sheets: Prefer .sheet(item:) over .sheet(isPresented:) when state represents a selected model.
- Distinctive: line 42
Add accessibility labels or identifiers when the UI is interactive.
- Very specific: line 47
Use references/components-index.md as the entry point.
- Common: line 94
Keep it short and actionable.
- Very specific: line 95
Update references/components-index.md with the new entry.
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SwiftUI UI Patterns
Quick start
Choose a track based on your goal:
Existing project
- Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
- Find a nearby example in the repo with
rg "TabView\("or similar, then read the closest SwiftUI view. - Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
- Choose the relevant component reference from
references/components-index.mdand follow its guidance. - Build the view with small, focused subviews and SwiftUI-native data flow.
New project scaffolding
- Start with
references/app-scaffolding-wiring.mdto wire TabView + NavigationStack + sheets. - Add a minimal
AppTabandRouterPathbased on the provided skeletons. - Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
- Expand the route and sheet enums as new screens are added.
General rules to follow
- Use modern SwiftUI state (
@State,@Binding,@Observable,@Environment) and avoid unnecessary view models. - Prefer composition; keep views small and focused.
- Use async/await with
.taskand explicit loading/error states. - Maintain existing legacy patterns only when editing legacy files.
- Follow the project's formatter and style guide.
- Sheets: Prefer
.sheet(item:)over.sheet(isPresented:)when state represents a selected model. Avoidif letinside a sheet body. Sheets should own their actions and calldismiss()internally instead of forwardingonCancel/onConfirmclosures.
Workflow for a new SwiftUI view
- Define the view's state and its ownership location.
- Identify dependencies to inject via
@Environment. - Sketch the view hierarchy and extract repeated parts into subviews.
- Implement async loading with
.taskand explicit state enum if needed. - Add accessibility labels or identifiers when the UI is interactive.
- Validate with a build and update usage callsites if needed.
Component references
Use references/components-index.md as the entry point. Each component reference should include:
- Intent and best-fit scenarios.
- Minimal usage pattern with local conventions.
- Pitfalls and performance notes.
- Paths to existing examples in the current repo.
Sheet patterns
Item-driven sheet (preferred)
@State private var selectedItem: Item?
.sheet(item: $selectedItem) { item in
EditItemSheet(item: item)
}Sheet owns its actions
struct EditItemSheet: View {
@Environment(\.dismiss) private var dismiss
@Environment(Store.self) private var store
let item: Item
@State private var isSaving = false
var body: some View {
VStack {
Button(isSaving ? "Saving…" : "Save") {
Task { await save() }
}
}
}
private func save() async {
isSaving = true
await store.save(item)
dismiss()
}
}Adding a new component reference
- Create
references/<component>.md. - Keep it short and actionable; link to concrete files in the current repo.
- Update
references/components-index.mdwith the new entry.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

