通过代码审查和架构审核和改进 SwiftUI 运行时性能。用于诊断 SwiftUI 应用程序中渲染缓慢、滚动卡顿、CPU/内存使用率高、视图更新过多或布局抖动的请求,并在代码审查时为用户运行的 Instruments 分析提供指导
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install swiftui-performance-audit或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install swiftui-performance-audit⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/swiftui-performance-audit/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: swiftui-performance-audit description: Audit and improve SwiftUI runtime performance from code review and architecture. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps, and to provide guidance for user-run Instruments profiling when code review alone is insufficient. ---
_Attribution: copied from @Dimillian’s Dimillian/Skills (2025-12-31)._
Audit SwiftUI view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps.
Collect:
Focus on:
id churn, UUID() per render).body (formatting, sorting, image decoding).GeometryReader, preference chains).Provide:
Explain how to collect data with Instruments:
Ask for:
Prioritize likely SwiftUI culprits:
id churn, UUID() per render).body (formatting, sorting, image decoding).GeometryReader, preference chains).Summarize findings with evidence from traces/logs.
Apply targeted fixes:
@State/@Observable closer to leaf views).ForEach and lists.body (precompute, cache, @State).equatable() or value wrappers for expensive subtrees.Look for these patterns during code review.
bodyvar body: some View {
let number = NumberFormatter() // slow allocation
let measure = MeasurementFormatter() // slow allocation
Text(measure.string(from: .init(value: meters, unit: .meters)))
}
Prefer cached formatters in a model or a dedicated helper:
final class DistanceFormatter {
static let shared = DistanceFormatter()
let number = NumberFormatter()
let measure = MeasurementFormatter()
}
var filtered: [Item] {
items.filter { $0.isEnabled } // runs on every body eval
}
Prefer precompute or cache on change:
@State private var filtered: [Item] = []
// update filtered when inputs change
body or ForEachList {
ForEach(items.sorted(by: sortRule)) { item in
Row(item)
}
}
Prefer sort once before view updates:
let sortedItems = items.sorted(by: sortRule)
ForEachForEach(items.filter { $0.isEnabled }) { item in
Row(item)
}
Prefer a prefiltered collection with stable identity.
ForEach(items, id: \.self) { item in
Row(item)
}
Avoid id: \.self for non-stable values; use a stable ID.
Image(uiImage: UIImage(data: data)!)
Prefer decode/downsample off the main thread and store the result.
@Observable class Model {
var items: [Item] = []
}
var body: some View {
Row(isFavorite: model.items.contains(item))
}
Prefer granular view models or per-item state to reduce update fan-out.
Ask the user to re-run the same capture and compare with baseline metrics. Summarize the delta (CPU, frame drops, memory peak) if provided.
Provide:
Add Apple documentation and WWDC resources under references/ as they are supplied by the user.
references/optimizing-swiftui-performance-instruments.mdreferences/understanding-improving-swiftui-performance.mdreferences/understanding-hangs-in-your-app.mdreferences/demystify-swiftui-performance-wwdc23.md安装 Swiftui 性能审计 后,可以对 AI 说这些话来触发它
Help me get started with Swiftui Performance Audit
Explains what Swiftui Performance Audit does, walks through the setup, and runs a quick demo based on your current project
Use Swiftui Performance Audit to audit and improve SwiftUI runtime performance from code review and ...
Invokes Swiftui Performance Audit with the right parameters and returns the result directly in the conversation
What can I do with Swiftui Performance Audit in my developer & devops workflow?
Lists the top use cases for Swiftui Performance Audit, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/swiftui-performance-audit/ 目录(个人级,所有项目可用),或 .claude/skills/swiftui-performance-audit/(项目级)。重启 AI 客户端后,用 /swiftui-performance-audit 主动调用,或让 AI 根据上下文自动发现并使用。
Swiftui 性能审计 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Swiftui 性能审计 可免费安装使用。请查阅仓库了解许可证信息。
通过代码审查和架构审核和改进 SwiftUI 运行时性能。用于诊断 SwiftUI 应用程序中渲染缓慢、滚动卡顿、CPU/内存使用率高、视图更新过多或布局抖动的请求,并在代码审查时为用户运行的 Instruments 分析提供指导
Swiftui 性能审计 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Swiftui Performance Audit
Identifies repetitive steps in your workflow and sets up Swiftui Performance Audit to handle them automatically