Community程式設計與開發github.com

dimillian/swiftui-performance-audit

透過程式碼審查與架構分析,診斷並改善 SwiftUI 執行時期效能。適用於 SwiftUI 應用程式中緩慢渲染、滾動卡頓、高 CPU/記憶體使用率、過多的檢視更新或版面配置抖動等問題,並在純程式碼審查不足時提供使用者執行 Instruments 效能分析的指引。

swiftui-performance-audit 是什麼?

此技能可透過靜態程式碼審查與架構分析,診斷 SwiftUI 應用程式的執行時期效能問題,例如緩慢渲染、滾動卡頓、高 CPU/記憶體使用率、過多的檢視更新或版面配置抖動。它專注於找出常見的 SwiftUI 效能瓶頸,如不必要的檢視更新、複雜的佈局計算、字串處理、影像解碼或過多的環境物件傳遞。當程式碼審查不足以確定根本原因時,它會建議使用者執行 Instruments 工具(如 Time Profiler、SwiftUI 分析範本、Allocations)以取得更多執行時期資料。此技能支援透過簡潔的提示詢問特定問題,例如「檢查此檢視的更新次數」或「找出記憶體壓力來源」,並可提供修正策略,例如使用 EquatableView、識別器最佳化、延遲載入或 Lazy 容器與佈局容器的最佳搭配。

相容平台~Claude Code~Codex CLI~Cursor
Part ofMobile
npx skills add https://github.com/dimillian/skills/tree/main/skills/swiftui-performance-audit

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

swiftui-performance-audit 是做什麼的?

透過程式碼審查與架構分析,診斷並改善 SwiftUI 執行時期效能。適用於 SwiftUI 應用程式中緩慢渲染、滾動卡頓、高 CPU/記憶體使用率、過多的檢視更新或版面配置抖動等問題,並在純程式碼審查不足時提供使用者執行 Instruments 效能分析的指引。

使用方式

提出與 SwiftUI 效能相關的問題或程式碼片段,此技能將分析潛在的問題點,提供修正建議,並建議適當的 Instruments 工具(如 Time Profiler、SwiftUI 分析範本、Allocations)以驗證改善效果。

範例問題

  • 「此檢視在滾動時會掉幀,請檢查是否有不必要的更新。」
  • 「這個清單的 CPU 使用率偏高,請分析可能的佈局計算瓶頸。」
  • 「應用程式記憶體持續增加,請檢查是否有循環參照或未釋放的檢視。」
  • 「請診斷此 List 中的佈局抖動原因。」
  • 「當 code review 不足以找出問題時,請推薦要使用的 Instruments 範本。」

支援的平台

  • iOS / iPadOS
  • macOS
  • tvOS
  • watchOS

常見的 SwiftUI 效能問題

  • 不必要的檢視更新(因未正確實作 Equatable 或使用了複雜的 @State/@ObservedObject)
  • 複雜的佈局計算(例如巢狀 GeometryReader 或未最佳化的 LazyVStack/LazyHStack)
  • 過多的 @EnvironmentObject 依賴
  • 影像或資源解碼與快取
  • 無謂的 onAppear/onChange/onReceive 副作用
  • 使用 PreferenceKey 或 Anchor 時產生過多的協調

修正策略

  • 使用 EquatableView 或自訂的 == 實作來減少不必要更新
  • 盡量使用 LazyVStack/LazyHStack 搭配 id: 識別器
  • 避免將 GeometryReader 放在檢視樹狀結構的高層
  • 使用 .drawingGroup() 來減少離屏渲染
  • 善用 @State 和 @StateObject 的鎖定範圍,避免全域狀態
  • 對於大量影像,考慮使用 AsyncImage 或第三方快取程式庫

當程式碼審查無法找到問題時,技能會提示使用者執行 Instruments 工具,並提供如何設定分析範本、讀取火焰圖與時間軸的指引。

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

dimillian/app-store-changelog

Create user-facing App Store release notes by collecting and summarizing all user-impacting changes since the last git tag (or a specified ref). Use when asked to generate a comprehensive release changelog, App Store "What's New" text, or release notes based on git history or tags.

dimillian/ios-debugger-agent

Use XcodeBuildMCP to build, run, launch, and debug the current iOS project on a booted simulator. Trigger when asked to run an iOS app, interact with the simulator UI, inspect on-screen state, capture logs/console output, or diagnose runtime behavior using XcodeBuildMCP tools.

dimillian/macos-spm-app-packaging

Scaffold, build, and package SwiftPM-based macOS apps without an Xcode project. Use when you need a from-scratch macOS app layout, SwiftPM targets/resources, a custom .app bundle assembly script, or signing/notarization/appcast steps outside Xcode.

dimillian/swift-concurrency-expert

Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file. Concrete actions include adding Sendable conformance, applying @MainActor annotations, resolving actor isolation warnings, fixing data race diagnostics, and migrating completion handlers to async/await.

dimillian/swiftui-liquid-glass

Implement, review, or improve SwiftUI features using the iOS 26+ Liquid Glass API. Use when asked to adopt Liquid Glass in new SwiftUI UI, refactor an existing feature to Liquid Glass, or review Liquid Glass usage for correctness, performance, and design alignment.

dimillian/swiftui-ui-patterns

Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens with VStack/HStack, managing @State or @Binding, building declarative iOS interfaces, or needing component-specific patterns and examples.

dimillian/swiftui-view-refactor

Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency injection, and correct Observation usage. Use when cleaning up a SwiftUI view, splitting long bodies, removing inline actions or side effects, reducing computed `some View` helpers, or standardizing `@Observable` and view model initialization patterns.

相關技能