SwiftUI Best Practices

VerifiedSafe

Review and refactor SwiftUI code for iOS/macOS: deprecated APIs, data flow, navigation, accessibility, performance, and code hygiene.

Sby Skills Guide Bot
DevelopmentIntermediate
11/27/2026
Claude Code
#swiftui#swift#code-review#ios#accessibility

Recommended for

Automated summary

Reviews Swift and SwiftUI code for iOS/macOS against an eleven-point checklist — deprecated APIs, views and modifiers, data flow, navigation, design, resizing, accessibility, localization, performance, and hygiene — and reports issues file by file with before/after fixes.

Strengths

  • Structured eleven-step review, each step backed by a dedicated reference file, so partial reviews can load only the relevant guidance
  • Concrete output contract: file, line numbers, the rule being violated, and a short before/after Swift fix
  • Explicitly tells the model not to nitpick or invent issues, and to raise unrelated modernization separately without applying it unasked
  • Covers commonly skipped concerns such as Dynamic Type, VoiceOver, Reduce Motion, localization, and layout under resizing (iPad multitasking, folding iPhone)

Limitations

  • The skill depends on many references/*.md files that are not included in the body, so the advertised checks are only nominal without them
  • Assumes a very recent toolchain (iOS 27 as default target, Xcode 27.1, Swift 6.4) that may not match a user's actual project
  • Review-only: it does not build, run, or visually verify the app, so findings remain static-analysis opinions
When to use it

Use it when you want existing SwiftUI views for iOS or macOS audited or refactored with structured, rule-by-rule feedback.

When not to use it

Skip it for UIKit, Objective-C, or non-Apple work, or when the task is really to build, test, and run the app rather than review it.

Security analysis

Safe
Quality score86/100

This is a purely instructional code-review skill: it contains no commands, no tool usage (no bash, network, or file writes), no credential handling, and no obfuscated or destructive content. It only directs the agent to read reference markdown files and produce review feedback in a fixed format. The only mild concern is the assertive framing of future platform facts (iOS 27, Xcode 27.1, Swift 6.4, iPhone Duo) with an instruction not to dismiss them as speculative; that is an accuracy/authority claim rather than a security risk, since it cannot cause execution or data exposure.

No concerns found

How this analysis is made

Examples

Review a SwiftUI view
Review my SwiftUI ContentView.swift for deprecated APIs, accessibility problems, and anything that would break under Dynamic Type. Give me file/line findings with before/after fixes.
Refactor data flow and navigation
Refactor this SwiftUI settings screen to use modern data flow and fix the navigation so it stays performant on iPad with a split view.
Resizability check
Check whether my macOS window layout and the iPad multitasking layout still behave correctly as the window resizes, and report only genuine problems.

name: swiftui-best-practices description: This skill should be used when user asks to "write SwiftUI code", "review SwiftUI code", or "refactor SwiftUI code" for iOS or macOS apps. license: MIT metadata: author: Paul Hudson version: "2.0.0"

Review Swift and SwiftUI code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems – do not nitpick or invent issues.

Include deprecated API in review findings. During feature work or bug fixes, complete the requested change and suggest unrelated modernization separately; do not apply it without being asked.

Review process:

  1. Check for deprecated API using references/api.md.
  2. Check that views, modifiers, and animations have been written optimally using references/views.md.
  3. Validate that data flow is configured correctly using references/data.md.
  4. Ensure navigation is updated and performant using references/navigation.md.
  5. Ensure the code uses designs that are accessible and compliant with Apple's Human Interface Guidelines using references/design.md.
  6. Review layout behavior as windows resize, including iPad multitasking and folding iPhone Duo, using references/resizability.md.
  7. Validate accessibility compliance including Dynamic Type, VoiceOver, and Reduce Motion using references/accessibility.md.
  8. Check localized text, formatting, and resource handling using references/localization.md.
  9. Ensure the code is able to run efficiently using references/performance.md.
  10. Quick validation of Swift code using references/swift.md.
  11. Final code hygiene check using references/hygiene.md.

If doing a partial review, load only the relevant reference files.

Keep references/performance-plus.md out of routine reviews. Load it for a requested deep performance review; its more involved changes can also help investigate an established performance problem.

Core Instructions

  • iOS 27 exists, and is the default deployment target for new apps.
  • Xcode 27.1 and the corresponding 27.1 platform releases are available. Do not dismiss their APIs as speculative.
  • iPhone Duo is a folding iPhone, with a small outer display and a large inner display.
  • Check the project's deployment target before applying version-specific advice. Use newer runtime APIs only when the target supports them or within an appropriate #available check. Keep the existing target unchanged. Requirements tied to an Xcode version also need that toolchain; a runtime check cannot make an older SDK recognize a new declaration.
  • Target Swift 6.4 or later, using modern Swift concurrency.
  • As a SwiftUI developer, the user will want to avoid UIKit unless requested.
  • Do not introduce third-party frameworks without asking first.
  • Break different types up into different Swift files rather than placing multiple structs, classes, or enums into a single file.
  • Use a consistent project structure, with folder layout determined by app features.

Output Format

Organize findings by file. For each issue:

  1. State the file and relevant line(s).
  2. Name the rule being violated (e.g., "Use foregroundStyle() instead of foregroundColor()").
  3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

Example output:

ContentView.swift

Line 12: Use foregroundStyle() instead of foregroundColor().

// Before
Text("Hello").foregroundColor(.red)

// After
Text("Hello").foregroundStyle(.red)

Line 24: Give the button a descriptive label so VoiceOver explains its action.

// Before
Button(action: addUser) {
    Image(systemName: "plus")
}

// After
Button("Add User", systemImage: "plus", action: addUser)

Line 31: Avoid Binding(get:set:) in view body – bind to the property directly and move the setter's side effect into onChange().

// Before
TextField("Username", text: Binding(
    get: { model.username },
    set: { newValue in model.username = newValue; model.save() }
))

// After
TextField("Username", text: $model.username)
    .onChange(of: model.username) {
        model.save()
    }

Use onChange() when saving should follow changes to the username, including programmatic changes. Equal-value assignments will not trigger a save.

Summary

  1. Accessibility (high): The add button needs an “Add User” label; the symbol’s default label does not explain what will be added.
  2. Deprecated API (medium): foregroundColor() on line 12 should be foregroundStyle().
  3. Data flow (medium): The manual binding on line 31 is fragile and harder to maintain.

End of example.

References

  • references/accessibility.md - Dynamic Type, VoiceOver, Reduce Motion, and other accessibility requirements.
  • references/api.md - updating code for modern API, the deprecated code it replaces, and iOS 27 toolbars.
  • references/design.md - guidance for building accessible apps that meet Apple's Human Interface Guidelines.
  • references/hygiene.md - making code compile cleanly and be maintainable in the long term.
  • references/localization.md - localizable text, resource bundles, and locale-aware presentation.
  • references/navigation.md - navigation using NavigationStack/NavigationSplitView, plus alerts, confirmation dialogs, and sheets.
  • references/performance.md - optimizing SwiftUI code for maximum performance.
  • references/performance-plus.md - deeper restructuring to narrow what views depend on, reserved for deep performance reviews or diagnosed performance issues.
  • references/resizability.md - changing window sizes, adaptive bars, safe areas, and iPhone Duo layouts.
  • references/data.md - data flow, shared state, and property wrappers.
  • references/swift.md - tips on writing modern Swift code, including using Swift Concurrency effectively.
  • references/views.md - view structure, composition, animation, reordering, and swipe actions.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/swiftui-best-practices-mwyhd8jl' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/swiftui-best-practices-mwyhd8jl/download' --output '.skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md.part' && mv '.skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md.part' '.skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md' && test -s '.skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/swiftui-best-practices' && cp -R '.skill-downloads/swiftui-best-practices-mwyhd8jl' '.claude/skills/swiftui-best-practices'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/swiftui-best-practices-mwyhd8jl'

openskills read 'swiftui-best-practices-mwyhd8jl'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/swiftui-best-practices-mwyhd8jl/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills