Communitygithub.com

ComeOnOliver/skillshub

コードレビューとアーキテクチャ分析からSwiftUIのランタイムパフォーマンスを監査・改善します。遅いレンダリング、カクつくスクロール、高CPU/メモリ使用率、過剰なビュー更新、レイアウトスラッシュの診断を依頼する場合に使用します。また、コードレビューだけでは不十分な場合には、ユーザーがInstrumentsでプロファイリングを行うためのガイダンスを提供します。

skillshub とは?

このスキルは、SwiftUIアプリのランタイムパフォーマンス問題をコードレビューとアーキテクチャ分析の観点から診断し、改善するための包括的なガイドラインを提供します。主な用途は、レンダリングの遅延、スクロールのカクつき、高CPU/メモリ使用率、過剰なビュー更新、レイアウトスラッシュなど、実行時に発生するパフォーマンス問題の根本原因を特定することです。このスキルは、ユーザーから提供されたコードを分析する「コードファーストレビュー」と、必要に応じてInstrumentsを使用したプロファイリングをガイドする「プロファイルガイド」の2段階のワークフローで構成されています。コードレビューでは、状態変更によるビュー無効化ストーム、リスト内の不安定な同一性、body内での重い処理、レイアウトスラッシュ、画像の非効率な処理、過剰なアニメーションといった典型的なアンチパターンを検出し、具体的な修正案を提示します。さらに、パフォーマンス改善後には、ユーザーに同じ計測を再実行させ、ベースラインと比較することで、改善効果を定量的に検証するためのプロセスも含まれています。このスキルはClaude CodeのようなAIエージェントとの連携を想定して設計されており、開発者がSwiftUIアプリのパフォーマンスを効率的に最適化するための強力な支援を提供します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/dimillian/swiftui-performance-audit

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

SwiftUI パフォーマンス監査

概要

SwiftUIビューのパフォーマンスをエンドツーエンドで監査します。計装とベースライン設定から根本原因分析、具体的な改善手順までをカバーします。

ワークフロー判断ツリー

  • ユーザーがコードを提供した場合は、「コードファーストレビュー」から開始します。
  • ユーザーが症状のみを説明する場合は、最小限のコード/コンテキストを求め、その後「コードファーストレビュー」を実施します。
  • コードレビューで結論が出ない場合は、「ユーザーにプロファイリングをガイド」に進み、トレースまたはスクリーンショットを依頼します。

1. コードファーストレビュー

収集するもの:

  • 対象のビュー/機能のコード。
  • データフロー: state、environment、observableモデル。
  • 症状と再現手順。

重点的に確認する点:

  • 広範な状態変更によるビューの無効化ストーム。
  • リスト内の不安定な同一性(idの変動、描画ごとのUUID()生成)。
  • body内の重い処理(フォーマット、ソート、画像デコード)。
  • レイアウトスラッシュ(深いスタック、GeometryReader、preferenceチェーン)。
  • ダウンサンプリングやリサイズを行わない大きな画像。
  • 過剰なアニメーションハイラルキー(大きなツリーへの暗黙的アニメーション)。

提供するもの:

  • コード参照を含む可能性の高い根本原因。
  • 提案された修正とリファクタリング。
  • 必要に応じて、最小限の再現コードや計装の提案。

2. ユーザーにプロファイリングをガイド

Instrumentsでデータを収集する方法を説明します:

  • InstrumentsのSwiftUIテンプレートを使用します(Releaseビルド)。
  • 問題の操作(スクロール、ナビゲーション、アニメーション)を正確に再現します。
  • SwiftUIタイムラインとTime Profilerをキャプチャします。
  • 該当するレーンとコールツリーをエクスポートまたはスクリーンショットします。

依頼するもの:

  • トレースのエクスポート、またはSwiftUIレーンとTime Profilerのコールツリーのスクリーンショット。
  • デバイス/OS/ビルド設定。

3. 分析と診断

可能性の高いSwiftUIの原因を優先順位付けします:

  • 広範な状態変更によるビューの無効化ストーム。
  • リスト内の不安定な同一性(idの変動、描画ごとのUUID()生成)。
  • body内の重い処理(フォーマット、ソート、画像デコード)。
  • レイアウトスラッシュ(深いスタック、GeometryReader、preferenceチェーン)。
  • ダウンサンプリングやリサイズを行わない大きな画像。
  • 過剰なアニメーションハイラルキー(大きなツリーへの暗黙的アニメーション)。

トレース/ログからの証拠を基に、調査結果を要約します。

4. 修正

的を絞った修正を適用します:

  • 状態のスコープを狭くする(@State/@Observableをリーフビューの近くに配置)。
  • ForEachやリストの同一性を安定化させる。
  • 重い処理をbodyの外に移動する(事前計算、キャッシュ、@State)。
  • 高コストなサブツリーにはequatable()や値ラッパーを使用する。
  • レンダリング前に画像をダウンサンプリングする。
  • レイアウトの複雑さを減らす、または可能な場合は固定サイズを使用する。

よくあるコードの悪臭(と修正方法)

コードレビュー時にこれらのパターンに注目してください。

body内での高コストなフォーマッター

var body: some View {
    let number = NumberFormatter() // 遅いアロケーション
    let measure = MeasurementFormatter() // 遅いアロケーション
    Text(measure.string(from: .init(value: meters, unit: .meters)))
}

モデルまたは専用ヘルパーにキャッシュされたフォーマッターを優先します:

final class DistanceFormatter {
    static let shared = DistanceFormatter()
    let number = NumberFormatter()
    let measure = MeasurementFormatter()
}

重い処理を行うcomputedプロパティ

var filtered: [Item] {
    items.filter { $0.isEnabled } // bodyの評価ごとに実行される
}

変更時に事前計算またはキャッシュします:

@State private var filtered: [Item] = []
// 入力が変更されたときにfilteredを更新

bodyまたはForEach内でのソート/フィルタリング

List {
    ForEach(items.sorted(by: sortRule)) { item in
        Row(item)
    }
}

ビュー更新の前に一度だけソートします:

let sortedItems = items.sorted(by: sortRule)

ForEach内でのインラインフィルタリング

ForEach(items.filter { $0.isEnabled }) { item in
    Row(item)
}

安定した同一性を持つ事前フィルタリングされたコレクションを優先します。

不安定な同一性

ForEach(items, id: \.self) { item in
    Row(item)
}

安定しない値に対してid: \.selfの使用を避け、安定したIDを使用します。

メインスレッドでの画像デコード

Image(uiImage: UIImage(data: data)!)

メインスレッド以外でデコード/ダウンサンプリングを行い、結果を保存します。

Observableモデル内での広範な依存関係

@Observable class Model {
    var items: [Item] = []
}

var body: some View {
    Row(isFavorite: model.items.contains(item))
}

更新のファンアウトを減らすために、粒度の細かいビューモデルまたはアイテムごとの状態を優先します。

5. 検証

ユーザーに同じキャプチャを再実行し、ベースライン指標と比較するよう依頼します。 提供された場合、差分(CPU、フレームドロップ、メモリピーク)を要約します。

出力

以下を提供します:

  • 短いメトリクス表(可能であれば改善前/改善後)。
  • 優先順位の高い問題(影響度順)。
  • 見積もり工数付きの修正案。

参考文献

AppleのドキュメントおよびWWDCのリソースは、references/以下にユーザーから提供された場合に追加します。

  • InstrumentsでSwiftUIパフォーマンスを最適化する: references/optimizing-swiftui-performance-instruments.md
  • SwiftUIパフォーマンスを理解し改善する: references/understanding-improving-swiftui-performance.md
  • アプリのハングを理解する: references/understanding-hangs-in-your-app.md
  • SwiftUIパフォーマンスを解明する(WWDC23): references/demystify-swiftui-performance-wwdc23.md

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル