SwiftUI-Agent-Skill README

The project's README from github.com/AvdLee/SwiftUI-Agent-Skill. As one markdown file: README.md.

SwiftUI Expert Skill

License: MIT Weekly Installs GitHub Release GitHub Stars

Expert guidance for any AI coding tool that supports the Agent Skills open format — SwiftUI state management, view composition, performance, and iOS 26+ Liquid Glass adoption.

This repository distills practical SwiftUI best practices into actionable, concise references for agents and code review workflows.

This repository is packaged as a portable Agent Plugin (spec 1.0.0): compatible clients discover the skill automatically from the root plugin.json manifest and the skills/ directory. Client-specific manifests for Claude Code, Cursor, Codex, and pi are included as well.

Who this is for

See also my other skills:

How to Use This Skill

Install this skill with a single command:

npx skills add https://github.com/avdlee/swiftui-agent-skill --skill swiftui-expert-skill

For more information, visit the skills.sh platform page.

Then use the skill in your AI agent, for example:

Use the swiftui expert skill and review the current SwiftUI code for state-management and performance improvements

Option B: ChatGPT & Codex (OpenAI Plugins Directory)

This plugin is distributed through the universal OpenAI Plugins Directory shared by ChatGPT and Codex:

  1. In the ChatGPT desktop app, select Codex (or ChatGPT with Work enabled), or use the plugin browser in Codex CLI.
  2. Open Plugins and search for "SwiftUI Expert".
  3. Install the plugin. The skill becomes available in new chats and sessions.

Option C: Claude Code Plugin

Personal Usage

To install this Skill for your personal use in Claude Code:

  1. Add the marketplace:
/plugin marketplace add AvdLee/SwiftUI-Agent-Skill
  1. Install the Skill:
/plugin install swiftui-expert@swiftui-expert-skill

Project Configuration

To automatically provide this Skill to everyone working in a repository, configure the repository's .claude/settings.json:

{
  "enabledPlugins": {
    "swiftui-expert@swiftui-expert-skill": true
  },
  "extraKnownMarketplaces": {
    "swiftui-expert-skill": {
      "source": {
        "source": "github",
        "repo": "AvdLee/SwiftUI-Agent-Skill"
      }
    }
  }
}

When team members open the project, Claude Code will prompt them to install the Skill.

Option D: Cursor Plugin

Load the plugin from a local clone by placing it in ~/.cursor/plugins/local, or install it from the Cursor Marketplace once listed. Cursor supports both the portable Agent Plugins manifest (plugin.json) and the Cursor Plugin manifest (.cursor-plugin/plugin.json) included in this repository.

Using another tool?

See INSTALLATION.md for all other installation options: pi, Gemini CLI, Autohand Code, and manual installation.

How to verify:

Your agent should reference the workflow/checklists in skills/swiftui-expert-skill/SKILL.md and jump into the relevant reference file for your task.

What's Inside

This skill covers the full surface of SwiftUI development -- from state management and view composition to Swift Charts, macOS multi-window scenes, animations, and iOS 26+ Liquid Glass -- without bloating your agent's task context. Reference files load on demand, so your agent gets deep guidance only for the topic at hand.

Non-opinionated: focuses on correctness and performance, not architecture or code style.

Recording & Analysing Instruments Traces

Unlike the other reference files — which are text guidance — this part of the skill ships an executable Python toolchain that wraps xctrace. It lets the agent record a new .trace and analyse an existing one end-to-end: the parser reads the Time Profiler, Hangs, Animation Hitches, SwiftUI updates, and SwiftUI cause-graph lanes, correlates hangs/hitches with main-thread samples, and emits JSON + markdown so the agent can reason over structured data instead of the raw xctrace export firehose.

When it triggers:

What the agent can then ask:

Analyse ~/Desktop/MyApp.trace and tell me what's wrong.

Focus analysis on what happens right after the 'feed loaded' log.

Which of my SwiftUI views is responsible for the hang around 6s?

Record a new trace: attach to MyApp on my iPhone — I'll tell you when I'm done.

Under the hood:

Key diagnostic: main_running_coverage_pct on each hang/hitch correlation. < 25 % → main thread was blocked (I/O, lock, sync await); ≥ 75 % → CPU-bound. This single metric separates two radically different fix paths.

Full guidance: skills/swiftui-expert-skill/references/trace-analysis.md and skills/swiftui-expert-skill/references/trace-recording.md.

Skill Structure

skills/swiftui-expert-skill/
  SKILL.md
  references/
    accessibility-patterns.md - Accessibility traits, grouping, Dynamic Type, and VoiceOver
    animation-advanced.md - Performance, interpolation, and complex animation chains
    animation-basics.md - Core animation concepts, implicit/explicit animations, timing
    animation-transitions.md - View transitions, matchedGeometryEffect, and state changes
    charts-accessibility.md - Charts accessibility, fallback strategies, and WWDC sessions
    charts.md - Swift Charts marks, axes, selection, styling, composition, and Chart3D
    focus-patterns.md
    image-optimization.md - AsyncImage usage, downsampling, caching
    latest-apis.md
    layout-best-practices.md - Layout patterns and GeometryReader alternatives
    liquid-glass.md - iOS 26+ glass effects and fallback patterns
    list-patterns.md - ForEach identity and list performance
    localization.md
    macos-scenes.md - Scene lifecycle, multi-window setups, and menu bar scenes on macOS
    macos-views.md - macOS-specific SwiftUI views and platform differences from iOS
    macos-window-styling.md - Window chrome, toolbar, and title bar styling in SwiftUI
    performance-patterns.md - Hot-path optimizations and update control
    previews.md
    scroll-patterns.md - ScrollViewReader and programmatic scrolling
    sheet-navigation-patterns.md - Sheets and type-safe navigation
    soft-deprecation.md
    state-management.md - Property wrapper selection and data flow
    text-patterns.md
    trace-analysis.md
    trace-recording.md
    view-structure.md - View extraction and composition patterns

Maintenance

The repository includes a maintenance skill for keeping API guidance current:

.agents/skills/update-swiftui-apis/
  SKILL.md               - Workflow for scanning Apple docs and updating latest-apis.md
  references/
    scan-manifest.md     - Categorized API areas, doc paths, and search queries to scan

Use this skill after new iOS or Xcode releases to refresh the deprecated API reference. It requires the Sosumi MCP to be available. See AGENTS.md or CONTRIBUTING.md for details.

Note: only swiftui-expert-skill is intended to be published in the Cursor plugin. The maintenance skill remains a repository workflow utility.

Contributing

Contributions are welcome! This repository follows the Agent Skills open format, which has specific structural requirements.

Please read CONTRIBUTING.md for:

Acknowledgments

Several SwiftUI guidelines in this skill were inspired by or derived from the following works:

About the authors

Created by Antoine van der Lee and Omar Elsayed. With years of experience in Swift & SwiftUI, this skill distills practical knowledge into actionable guidance for AI assistants. Antoine published tens of articles on SwiftUI on his blog called SwiftLee.

Resources

License

This skill is open-source and available under the MIT License. See LICENSE for details.

SwiftUI-Agent-Skill (AvdLee/SwiftUI-Agent-Skill)

Searching Database…

这是什么?一个打包好的专家技能,以开放的 Agent Skills 格式为 AI 编程工具提供深入的 SwiftUI 最佳实践指导——涵盖状态管理、视图组合、性能优化以及 iOS 26+ Liquid Glass 的适配。
那它是需要加到我应用里的 Swift 库吗,还是别的东西?都不是:它是一个可移植的 Agent 插件(spec 1.0.0),由你的 AI 代理按需加载的 markdown 参考文档组成,还附带一套用于分析 Instruments 跟踪数据的 Python 工具链。兼容的客户端会自动发现它。
怎么把它装到我的 AI 编程工具里?有四种文档写明的安装方式:一条命令通过 skills.sh 安装(推荐)、在 ChatGPT 或 Codex 中使用 OpenAI 插件目录(搜索 'SwiftUI Expert')、Claude Code 市场,或本地克隆给 Cursor 使用。INSTALLATION.md 还介绍了 pi、Gemini CLI 和手动安装方法。
哪些 AI 编程工具能真正用上这个技能?任何支持 Agent Skills 开放格式的客户端都可以:已为 Claude Code、Cursor、Codex 和 pi 提供各自的清单文件,INSTALLATION.md 还补充了 Gemini CLI、Autohand Code 和手动安装方式。
技能里的所有功能在任何电脑上都能用吗?Instruments 相关工具只能在 macOS 上运行,因为 xctrace 随 Xcode 附带;其余部分都是纯标准库 Python 3 加文本指导。这个技能在设计上不预设架构观点——关注正确性和性能,而不是架构或代码风格。
谁最能从中受益?正在采用现代 SwiftUI API、希望快速获得正确默认做法的团队;需要审查或重构 SwiftUI 视图和数据流的开发者;以及任何要发布高性能列表、滚动、弹窗和导航功能的人。
这些指导具体覆盖哪些主题?覆盖 SwiftUI 的全部内容:property wrapper 的选择与 @Observable 状态、视图组合、性能与懒加载、Lists 和 ForEach 的标识机制、NavigationStack 和基于枚举的弹窗、Swift Charts、动画与 @Animatable 宏、macOS 场景、iOS 26+ Liquid Glass、无障碍访问、图片优化,还有一份从 iOS 15+ 到 iOS 26+ 的过时 API 迁移指南。
这么多指导内容会把我的代理的上下文窗口撑爆吗?不会——参考文件按需加载,代理只会针对当前处理的主题拉取深入指导。README 明确强调:覆盖完整的 SwiftUI 内容,同时不会膨胀代理的任务上下文。
内置的 Instruments 工具是做什么的?它对 xctrace 做了端到端封装:recordtrace.py 录制新的 .trace(支持附加进程、启动应用或全部进程、设置时限、代理驱动的停止文件),analyzetrace.py 把 Time Profiler、Hangs、Animation Hitches、SwiftUI 更新和 cause-graph 各条目解析为 JSON 和 markdown。它的关键指标 mainrunningcoveragepct 能区分被阻塞的主线程(<25%)和 CPU 密集型的主线程(≥75%)。
这个技能怎么跟上新发布的 iOS 版本?仓库自带一个维护技能,在每次 iOS 或 Xcode 发布后刷新过时 API 参考;它要求 Sosumi MCP 可用。只有主技能 swiftui-expert-skill 是给 Cursor 插件用的——维护技能只是仓库内部的工作流工具。
Creator
AvdLee
Size
1 MB
Stars
3.7K
Age
8mo
Commits · 90 Days