SwiftUI Agent Skill:让 Claude、Codex 等 AI 助手写出更优 SwiftUI 代码
英文标题:🔥 twostraws/SwiftUI-Agent-Skill
开源项目 SwiftUI Pro 为 Claude Code、Codex、Gemini、Cursor 等 AI 编程助手提供 SwiftUI 专项 Agent Skill,覆盖 API 使用、设计、性能与无障碍等实践。该技能面向 iOS 26 及以上版本和 Swift 6.4 及以上版本,重点纠正 LLM 常见问题,如使用已废弃 API、造成性能隐患,以及编写无法被 VoiceOver 识别的控件。开发者可通过 npx 安装,也可在 Claude Code 中通过插件市场直接启用,并支持按项目或全局范围部署。项目采用 Agent Skills 格式和 MIT 许可证,为 AI 辅助 SwiftUI 开发提供可复用的规则集与审查能力。
1.5 KB
53.0 KB
3.5 KB
89.2 KB
中文
面向 AI 编程助手的 SwiftUI Agent Skill
这是一项 Agent Skill,可帮助 AI 编程助手编写更智能、更简洁、更现代的 SwiftUI 代码,涵盖 API 使用、设计、性能和无障碍方面的指导。其覆盖导航、布局、动画、状态管理、VoiceOver、已废弃 API 等内容,专门针对 LLM 实际会犯的错误。
同样可用:
可在 Swift Agent Skills 查找更多用于 Swift 和 Apple 平台开发的 Agent Skill。
该技能建立在我现有的 AGENTS.md 文件之上,这意味着你只需几分钟,就能将多年的知识和实践经验带入自己选择的编程 Agent。它采用 Agent Skills 格式,因此可顺畅适配 Claude Code、Codex、Gemini、Cursor 等工具。
你可以通过 npx 将这项技能安装到 Claude Code、Codex、Gemini、Cursor 等工具中:
npx skills add https://github.com/twostraws/swiftui-agent-skill --skill swiftui-pro
如果出现 npx: command not found 错误,意味着你当前未安装 Node。你需要运行以下命令,通过 Homebrew 安装 Node:
如果该操作也失败,通常意味着你需要先安装 Homebrew。
使用 npx 时,你可以在安装过程中准确选择希望使用哪些 Agent。你还可以选择仅为一个项目安装该技能,或者让它可用于你的所有项目。
Claude Code 用户可以添加 SwiftUI Agent Skill 市场,然后直接通过 Claude 安装插件,如下所示:
/plugin marketplace add twostraws/SwiftUI-Agent-Skill
/plugin install swiftui-pro@swiftui-agent-skill
或者,你也可以克隆整个仓库,并按自己的方式安装。
如果你使用 Xcode,可观看 YouTube 视频《如何在 Xcode 中安装和使用 Agent Skills》,了解完整操作流程。
该技能名为 SwiftUI Pro,可以通过多种方式触发。例如,在 Claude Code 中可以这样使用:
/swiftui-pro
在 Codex 中则可以这样使用:
$swiftui-pro
在两种情况下,如果你只希望进行部分审查,都可以提供具体指令。例如,在 Claude 中使用 /swiftui-pro Check for deprecated API,或在 Codex 中使用 $swiftui-pro Focus on accessibility。
你也可以通过自然语言触发该技能:
Use the SwiftUI Pro skill to look for performance problems in this project.
为什么要为 SwiftUI 使用 Agent Skill?
这项技能建立在数千小时的学习、实验和真实 SwiftUI 项目开发经验之上。其中的规则直接针对 LLM 常见的 SwiftUI 错误:它们有时会让按钮对 VoiceOver 不可见,经常使用已废弃的 API,也常会编写导致意外性能问题的代码。
你可以在我的文章中进一步了解我创建这项技能的原因:SwiftUI Agent Skill - 用 Claude、Codex 和其他 AI 工具编写更好的代码。
欢迎所有贡献,包括添加新的检查项、改进现有检查项,或编辑这份 README——所有人都受欢迎!
- 请保持 Markdown 简洁。使用技能会产生 token 成本,尤其是
SKILL.md,因此请尊重用户的 token 预算。 - 不要重复 LLM 已经知道的内容,因为这只会消耗 token 而没有收益。请重点关注边界情况、意外行为、软弃用及类似问题。
- 所有工作均须采用 MIT 许可证,以便让尽可能多的人受益。
请确保遵守行为准则。
SwiftUI Pro 最初由 Paul Hudson 创建;他在 Hacking with Swift 提供免费的 Swift 教程。该项目采用 MIT License,允许商业使用、修改、分发和私人使用。
English / 原文
SwiftUI Agent Skill for AI Coding Assistants
An agent skill that helps AI coding assistants write smarter, simpler, and more modern SwiftUI, including guidance on API usage, design, performance, and accessibility. Covers navigation, layout, animations, state management, VoiceOver, deprecated API, and more, targeting the mistakes LLMs actually make.
Also available:
Find more agent skills for Swift and Apple platform development at Swift Agent Skills.
The skill builds upon my existing AGENTS.md file, meaning that you can bring years of knowledge and practical experience into your coding agent of choice in just a few minutes. It uses the Agent Skills format, so it works smoothly with Claude Code, Codex, Gemini, Cursor, and more.
You can install this skill into Claude Code, Codex, Gemini, Cursor, and more by using npx:
npx skills add https://github.com/twostraws/swiftui-agent-skill --skill swiftui-pro
If you get the error npx: command not found, it means you don’t currently have Node installed. You need to run this command to install Node through Homebrew:
And if that fails it usually means you need to install Homebrew first.
When using npx, you can select exactly which agents you want to use during the installation. You can also select whether the skill should be installed just for one project, or whether it should be made available for all your projects.
Claude Code users can add the SwiftUI Agent Skill marketplace then install the plugin directly through Claude, like this:
/plugin marketplace add twostraws/SwiftUI-Agent-Skill
/plugin install swiftui-pro@swiftui-agent-skill
Alternatively, you can clone this whole repository and install it however you want.
If you’re using Xcode, watch the YouTube video on How to Install and Use Agent Skills in Xcode for a walkthrough.
The skill is called SwiftUI Pro, and can be triggered in various ways. For example, in Claude Code you would use this:
/swiftui-pro
And in Codex you would use this:
$swiftui-pro
In both cases you can provide specific instructions if you want only a partial review. For example, /swiftui-pro Check for deprecated API on Claude, or $swiftui-pro Focus on accessibility in Codex.
You can also trigger the skill using natural language:
Use the SwiftUI Pro skill to look for performance problems in this project.
Why Use an Agent Skill for SwiftUI?
This skill is built on thousands of hours of learning, experimenting, and building real-world SwiftUI projects. The rules contained here directly target common SwiftUI mistakes made by LLMs. They sometimes make buttons invisible to VoiceOver, they frequently use deprecated API, and they would often write code that causes surprise performance problems.
You can read more about why I created this skill in my article: SwiftUI Agent Skill - Write better code with Claude, Codex, and other AI tools.
I welcome all contributions, whether that's adding new checks, improving existing checks, or editing this README – everyone is welcome!
- Keep your Markdown concise. There is a token cost to using skills, particularly with SKILL.md, so please respect the token budgets of users.
- Do not repeat things that LLMs already know, because it burns tokens for no benefit. Focus on edge cases, surprises, soft deprecations, and similar.
- All work must be licensed under the MIT license so it can benefit the most people.
Please ensure you abide by the Code of Conduct.
SwiftUI Pro was originally created by Paul Hudson, who writes free Swift tutorials over at Hacking with Swift. It’s available under the MIT License, which permits commercial use, modification, distribution, and private use.