AGENT SKILL

swift-ios

SwiftUI and iOS engineering standards: state and data flow, view structure, navigation, layout, modern and deprecated APIs, accessibility, animation, performance, Swift concurrency, SwiftData and Liquid Glass. TRIGGER — load BEFORE writing or editing Swift, not after: any .swift, Package.swift, .xcodeproj or .xcworkspace file is touched, SwiftUI, iOS, iPadOS, Xcode or Swift concurrency is named, or the working directory holds an Xcode project or Swift package and the task is implementation, refactor, review or test-writing. Plain requests in an iOS repo ("add a screen", "fix this view", "why does this list flicker", "make this async") count; the user will not say "SwiftUI best practices". Load it for test files too, alongside swift-testing, and even when another skill (tdd, simplify) is active. SKIP only when no Swift file is involved and Swift is not named.

License 许可
MIT
最近更新
2026-11-11
Stars
★ 0
Forks
0

01 前言 Front Matter

name
swift-ios
license
MIT
metadata
{ "sources": "Merged and rewritten from MIT-licensed skills: twostraws/SwiftUI-Agent-Skill@1eac100, AvdLee/SwiftUI-Agent-Skill@204dba7, twostraws/Swift-Concurrency-Agent-Skill@bee3f69, AvdLee/Swift-Concurrency-Agent-Skill@d577081, twostraws/SwiftData-Agent-Skill@8051f17, Dimillian/Skills@05ba982.\n" }
description
SwiftUI and iOS engineering standards: state and data flow, view structure, navigation, layout, modern and deprecated APIs, accessibility, animation, performance, Swift concurrency, SwiftData and Liquid Glass. TRIGGER — load BEFORE writing or editing Swift, not after: any .swift, Package.swift, .xcodeproj or .xcworkspace file is touched, SwiftUI, iOS, iPadOS, Xcode or Swift concurrency is named, or the working directory holds an Xcode project or Swift package and the task is implementation, refactor, review or test-writing. Plain requests in an iOS repo ("add a screen", "fix this view", "why does this list flicker", "make this async") count; the user will not say "SwiftUI best practices". Load it for test files too, alongside swift-testing, and even when another skill (tdd, simplify) is active. SKIP only when no Swift file is involved and Swift is not named.
allowed-tools
Read, Edit, Write, Glob, Grep, Bash(xcodebuild:*), Bash(swift:*), Bash(xcrun:*), Bash(git:*), Agent

02 资源文件 23

03 SKILL.md 正文

Swift iOS

House rules for SwiftUI apps on iOS and iPadOS. The rules below apply to every change; the references hold the detail. Read only the references the task touches.

Before you write

  1. Read the project's settings. Deployment target (IPHONEOS_DEPLOYMENT_TARGET in the .pbxproj, platforms: in Package.swift), Swift language mode, default actor isolation (SWIFT_DEFAULT_ACTOR_ISOLATION, or .defaultIsolation(MainActor.self) in swiftSettings) and strict-concurrency level. Advice that depends on any of these is wrong until you know them. Keep the existing target; don't raise it to use an API.
  2. Read the neighbouring code. Its architecture, folder layout and naming win over this skill's defaults. If the codebase uses view models, add view models.
  3. Check dated facts in references/platform-facts.md before calling an API speculative or new. That file is the only place this skill names OS, Xcode or Swift versions as current.

Operating rules

  • Architecture: MV. Views own UI state with @State; app logic lives in @Observable models and services injected through the environment or initialisers. Don't add a per-screen view model unless one of the cases in references/views-and-state.md § "When a view model is justified" applies, or the codebase already uses them.
  • @MainActor follows the project's isolation. In a MainActor-default target, don't annotate. Otherwise give UI-state @Observable models @MainActor and leave non-UI services (networking, parsing, persistence) unisolated. Never add @MainActor, @unchecked Sendable, nonisolated(unsafe) or @preconcurrency just to silence a diagnostic; find the isolation bug (references/concurrency.md).
  • Deprecated APIs: in code the task touches, replace hard-deprecated APIs and flag soft-deprecated ones (deprecated: 100000.0, so the build stays quiet) without rewriting them. Never introduce either in new code. Don't scan or flag views the task doesn't touch (references/modern-api.md has the hard/soft table).
  • Availability: gate any API newer than the deployment target with #available and give it a working fallback. A runtime check doesn't help if the SDK lacks the symbol, so match the project's Xcode too.
  • Liquid Glass: keep the glass stock components give you. Don't fight it with opaque toolbar or tab-bar backgrounds. Don't hand-roll glassEffect or custom glass unless the user asks (references/liquid-glass.md).
  • Performance: apply the routine rules in references/performance.md always. Restructure for performance (splitting observation, narrowing dependencies) only for a diagnosed problem or a requested deep performance review.
  • Prefer SwiftUI to UIKit unless bridging is the only way. Don't add a third-party dependency without asking.
  • One primary type per file. Group folders by feature.

Correctness checklist

Treat a violation as a bug, in your own code and in code you review:

  • [ ] @State and @FocusState are private; parent-owned inputs are not copied into @State
  • [ ] @Observable over ObservableObject for new code; @State owns it, @Bindable for injected models that need bindings
  • [ ] @Binding only where the child writes parent state
  • [ ] No Binding(get:set:) in body; bind directly and react with onChange
  • [ ] ForEach identity is stable: never .indices or \.self on mutable values; one view per element
  • [ ] Tappable things are Buttons with a text label (use Button("Add", systemImage:) for icon buttons), not onTapGesture
  • [ ] .animation(_:value:), never without value:; new code uses foregroundStyle, not foregroundColor
  • [ ] Environment @Entry defaults are stable values, never Model(), Date() or UUID()
  • [ ] No GCD in new code; Task.sleep(for:), not nanoseconds
  • [ ] ModelContext and @Model instances never cross actors; pass PersistentIdentifier
  • [ ] Version-specific APIs are gated with #available and have fallbacks
  • [ ] Previews use in-memory, self-contained data; no network or live store

Where to look

If you're working on… Read
Property wrappers, data flow, @Observable models, environment, view decomposition, modifier order, async loading state, previews references/views-and-state.md
NavigationStack/NavigationSplitView, routes, sheets, alerts, dialogs, tabs, toolbars, search, deep links references/navigation.md
Stacks, grids, lists, forms, scroll views, safe areas, size classes, iPad multitasking, foldables references/layout.md
Whether an API is deprecated, its replacement, modern Swift idioms references/modern-api.md
VoiceOver, Dynamic Type, Reduce Motion, localisation, text formatting, HIG, theming, haptics references/accessibility-and-text.md
Implicit/explicit animation, transitions, matched geometry, phase and keyframe animation references/animation.md
Slow lists, janky scrolling, excess body evaluations, image decoding, a perf review references/performance.md
async/await, actors, Task, cancellation, Sendable errors, Swift 6 migration, bridging callbacks references/concurrency.md
@Model, @Query, predicates, relationships, indexes, CloudKit sync, ModelActor references/swiftdata.md
Toolbars, tab bars or custom controls on iOS 26+, any glassEffect request references/liquid-glass.md
Current OS, Xcode and Swift versions, new devices references/platform-facts.md
Writing or reviewing tests the swift-testing skill, if installed, alongside this one

Not covered, so don't assume this skill has an answer: macOS scenes, windows and views; Swift Charts; WebKit; document-based apps; styled text editing; focus management; Instruments trace recording and analysis; Core Data.

Feature work vs review

During feature work or a bug fix, make the change and stop. Don't rewrite unrelated code. If the code you edited uses soft-deprecated APIs, offer the migration in one line at the end.

When asked to review, report only real problems, grouped by file:

  1. The file and line(s).
  2. The rule broken, named in one line (e.g. "Use foregroundStyle() instead of foregroundColor()").
  3. A short before/after fix.

Skip files with no findings. End with a prioritised summary, most impactful first, each item tagged with its area and severity, e.g. Accessibility (high): the add button has no label. For a whole-app review, pick focus areas first and work through them one at a time.

04 同仓库更多 Skills

O-Marsters-1997
O-Marsters-1997/my-claude-code

obsidian-develop

Build, prototype, extend, debug and review Obsidian community plugins against a live vault: inspect the running app's UI, DOM, console and plugin state, prototype in the runtime, then verify each change with a build, reload and check loop. Use whenever the user is working on an Obsidian plugin, even when they just say "add a command", "make a sidebar view", "my settings tab is blank", "why isn't my view updating" or "get this ready for the community directory"; when they ask about the plugin API (obsidian.d.ts, Workspace, leaves, Vault, MetadataCache, FileManager, views, modals, settings tabs, CodeMirror 6 editor extensions, markdown post-processors, events); or when they want a running Obsidian instance's DOM, CSS, console or plugins inspected. Not for general note-taking, Obsidian Markdown syntax, themes without a plugin, or managing vault content (use ingest, to-vault or vault-recall for those).

★ 0
O-Marsters-1997
O-Marsters-1997/my-claude-code

vault-recall

Answer the user's conceptual or technical question using their Obsidian vault as well as general knowledge. Use when the user asks a question (not a task) whose topic appears in the vault MOC digest from session start. Not for task instructions, not mid-task, and not for writing to the vault (that is to-vault).

★ 0
O-Marsters-1997
O-Marsters-1997/my-claude-code

ingest

Ingest one external source (an article, course lesson, doc, PDF or URL) into the user's Obsidian vault: save the original to raw/, then build wiki/ pages per the vault's § Ingest. Use when the user types /ingest, or says "ingest this", "add this source to my wiki", "put this article/lesson in the vault as a wiki page". Works from any repo. Routing rule: someone else's words go to wiki/ (this skill); the user's own learnings and decisions go to notes/ (/to-vault).

★ 0
O-Marsters-1997
O-Marsters-1997/my-claude-code

to-tickets

Breaks a source into independently-grabbable GitHub tickets. For a code feature the source is the plan (`docs/plans/<feature>.md`, from /to-plan) and every new or changed symbol lands in exactly one ticket, its signatures copied into the ticket body; a non-code feature is cut from the PRD's slices. Cuts tickets for one feature per run. If a code feature has no approved plan, offers /to-plan instead of cutting from prose. In a repo that runs command-centre, also emits `[[task]]` blocks into its config; in a plain treepad repo, emits a Batch Manifest instead so the tickets materialise as stacked worktrees.

★ 0
O-Marsters-1997
O-Marsters-1997/my-claude-code

to-seams

Records an agreed-but-unlanded cross-repo interface as a seam: the file a consumer's agent gets pasted into its prompt as ground truth, plus the `[[seam]]` block command-centre reads for the retirement pointer. Use when two repos need to build against an interface neither has landed yet — "record a seam for X", "we agreed on this schema, seam it", "add a seam so Y can build against Z's new field". Halts for approval before writing either file.

★ 0
O-Marsters-1997
O-Marsters-1997/my-claude-code

to-roadmap

Prioritises settled features into a Now / Next / Later kanban board, rendered as a self-contained ./ideas/roadmap.html. Each card is a feature, not a ticket — one card later becomes several tickets via /to-prd -> /to-plan -> /to-tickets. Boards the features in ./docs/approach.md, or the "## Accepted ideas" in ./ideas/CONTEXT.md when there is no approach doc. The approach doc is settled truth: this assigns tiers and reasons about ordering, it never re-litigates what was decided.

★ 0