/ 目录 / 演练场 / SwiftUI Agent Skill
● 社区 twostraws ⚡ 即开即用

SwiftUI Agent Skill

作者 twostraws · twostraws/SwiftUI-Agent-Skill

Paul Hudson's SwiftUI patterns packaged as a Claude skill.

By Paul Hudson (Hacking with Swift), this skill teaches Claude modern SwiftUI: @Observable, NavigationStack, async views, proper state ownership. The result: SwiftUI code that actually compiles and follows Apple's current guidance.

为什么要用

核心特性

实时演示

实际使用效果

swiftui-agent-skill.replay ▶ 就绪
0/0

安装

选择你的客户端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "swiftui-agent-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/twostraws/SwiftUI-Agent-Skill",
        "~/.claude/skills/SwiftUI-Agent-Skill"
      ],
      "_inferred": true
    }
  }
}

打开 Claude Desktop → Settings → Developer → Edit Config。保存后重启应用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "swiftui-agent-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/twostraws/SwiftUI-Agent-Skill",
        "~/.claude/skills/SwiftUI-Agent-Skill"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用与 Claude Desktop 相同的 mcpServers 格式。项目级配置优先于全局。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "swiftui-agent-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/twostraws/SwiftUI-Agent-Skill",
        "~/.claude/skills/SwiftUI-Agent-Skill"
      ],
      "_inferred": true
    }
  }
}

点击 Cline 侧栏中的 MCP Servers 图标,然后选 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "swiftui-agent-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/twostraws/SwiftUI-Agent-Skill",
        "~/.claude/skills/SwiftUI-Agent-Skill"
      ],
      "_inferred": true
    }
  }
}

格式与 Claude Desktop 相同。重启 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "swiftui-agent-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/twostraws/SwiftUI-Agent-Skill",
        "~/.claude/skills/SwiftUI-Agent-Skill"
      ]
    }
  ]
}

Continue 使用服务器对象数组,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "swiftui-agent-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/twostraws/SwiftUI-Agent-Skill",
          "~/.claude/skills/SwiftUI-Agent-Skill"
        ]
      }
    }
  }
}

加入 context_servers。Zed 保存后热重载。

claude mcp add swiftui-agent-skill -- git clone https://github.com/twostraws/SwiftUI-Agent-Skill ~/.claude/skills/SwiftUI-Agent-Skill

一行命令搞定。用 claude mcp list 验证,claude mcp remove 卸载。

使用场景

实战用法: SwiftUI Agent Skill

Build a settings screen the right way (iOS 17+)

👤 iOS devs ⏱ ~15 min intermediate

何时使用: You want a Settings screen that's actually idiomatic for iOS 17+.

前置条件
  • Server/skill installed and authenticated — See repo README
步骤
  1. Plan
    Using the SwiftUI skill, design a Settings view with sections: Account, Notifications, About. Use @Observable for the view model.✓ 已复制
    → View hierarchy + ViewModel sketch
  2. Code
    Write the full file with toggles, NavigationLink to subpages, and a confirmation dialog for sign-out.✓ 已复制
    → Compiles on Xcode 15+

结果: Idiomatic SwiftUI you don't have to rewrite next year.

注意事项
  • Don't mix @StateObject with @Observable — Don't mix @StateObject with @Observable — the skill enforces one or the other; follow it.

成本与限制

运行它的成本

API 配额
See provider docs for rate limits
每次调用 Token 数
Varies by tool
费用
See repo README for pricing details
提示
Cache tool results and avoid repeated identical calls.

安全

权限、密钥、影响范围

凭据存储: Use environment variables; never commit secrets
数据出站: Tool calls go to the provider's API as documented

故障排查

常见错误与修复

view doesn't update on state change

Ensure the property is on an @Observable class, not a struct. The skill's checklist covers this.

验证: @Observable annotation present
preview crashes

@Observable views need a real instance in #Preview. The skill's examples show the pattern.

验证: Preview compiles

替代方案

SwiftUI Agent Skill 对比其他方案

替代方案何时用它替代权衡
wholiver/swiftui-design-skillYou want design direction, not code patternsDesign-focused; twostraws is code-focused

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills