Marketplace

swiftui-coding-guidelines

Core coding guidelines for iOS, iPadOS, macOS, watchOS, tvOS, and visionOS app development using SwiftUI and Swift. Use when implementing Views, working with @State/@Binding/@Observable/@StateObject, using NavigationStack/List/LazyVStack, designing components, or asking about SwiftUI patterns (infinite scroll, pull-to-refresh, search). Covers best practices, implementation patterns, and anti-patterns to avoid.

$ 安裝

git clone https://github.com/xtone/ai_development_tools /tmp/ai_development_tools && cp -r /tmp/ai_development_tools/ios_development/skills/swiftui-coding-guidelines ~/.claude/skills/ai_development_tools

// tip: Run this command in your terminal to install the skill


name: swiftui-coding-guidelines description: Core coding guidelines for iOS, iPadOS, macOS, watchOS, tvOS, and visionOS app development using SwiftUI and Swift. Use when implementing Views, working with @State/@Binding/@Observable/@StateObject, using NavigationStack/List/LazyVStack, designing components, or asking about SwiftUI patterns (infinite scroll, pull-to-refresh, search). Covers best practices, implementation patterns, and anti-patterns to avoid.

SwiftUI Coding Guidelines

SwiftUIの日常的な開発で参照するコアガイドライン。

ディレクトリ構成

swiftui-coding-guidelines/
├── SKILL.md (このファイル)
└── references/
    ├── best-practices.md      # ベストプラクティス
    ├── patterns-list.md       # 1-x: リスト・データ表示系
    ├── patterns-navigation.md # 2-x: ナビゲーション・画面遷移系
    ├── patterns-forms.md      # 3-x: フォーム・入力系
    ├── patterns-views.md      # 4-x: View構築・レイアウト系
    └── anti-patterns.md       # アンチパターン

リファレンスファイル

references/best-practices.md

SwiftUIのベストプラクティス集:

  • 状態管理: プロパティラッパー(@State、@Binding、@StateObject等)
  • パフォーマンス最適化: View構造、LazyスタックとGrid、Equatable
  • コンポーネント設計: 責務分離、Root Views vs Content Views、ViewModifier
  • 非同期処理: .taskモディファイア、async/await、@MainActor
  • ナビゲーション: NavigationStack(iOS 16+)、型安全ルーティング
  • Layoutプロトコル: GeometryReaderの代替(iOS 16+)
  • Preview駆動開発: 複数状態プレビュー

references/patterns-list.md(1-x: リスト・データ表示系)

番号パターン
1-1無限スクロール(Pagination)
1-2プルトゥリフレッシュ
1-3フィルタリング・ソート
1-4スワイプアクション
1-5コンテキストメニュー

references/patterns-navigation.md(2-x: ナビゲーション・画面遷移系)

番号パターン
2-1タブビュー
2-2ナビゲーション(NavigationStack)
2-3モーダル表示(Sheet / FullScreenCover)
2-4アラート・ダイアログ

references/patterns-forms.md(3-x: フォーム・入力系)

番号パターン
3-1検索機能(デバウンス付き)
3-2フォーム入力(バリデーション付き)
3-3認証画面(ログイン / 新規登録 / OTP)

references/patterns-views.md(4-x: View構築・レイアウト系)

番号パターン
4-1AsyncImage(キャッシュ付き)
4-2空状態・エラー状態
4-3アニメーション
4-4View重なり(ZStack / overlay / background)
4-5ContentUnavailableView(iOS 17+)

references/anti-patterns.md

アンチパターンと解決策:

  • 状態管理、パフォーマンス、ビジネスロジック
  • 非同期処理、ナビゲーション、メモリ管理
  • ViewのIdentity: 不安定なID、ForEachでのインデックス使用
  • AnyView: 型消去によるパフォーマンス低下
  • コンポーネント設計: スペーシング管理、opacity vs if文

使用方法

新規実装時

  1. 該当するpatterns-*.mdで実装パターン確認
  2. best-practices.mdで関連ベストプラクティス確認
  3. anti-patterns.mdで避けるべきパターン確認

問題解決時

  1. anti-patterns.mdで該当パターン検索
  2. best-practices.mdで推奨実装確認

重要な原則

  1. 状態の最小化: 導出可能な状態は持たない
  2. 責務の分離: Root Views(ロジック)とContent Views(UI)を分離
  3. パフォーマンス: Lazy、Equatable、非同期処理の適切な使用
  4. ViewのIdentity: 安定したIDを使用、ForEachでインデックス禁止
  5. スペーシングは親が管理: 子コンポーネントはpaddingでスペースを作らない

関連スキル

  • swiftui-ssot: 状態管理(SSOT)の詳細設計
  • swiftui-code-review-checklist: PRレビュー用チェックリスト
  • swift-ios-migration: iOS 17/18、Swift 6移行
  • swiftui-accessibility: アクセシビリティ対応

Repository

xtone
xtone
Author
xtone/ai_development_tools/ios_development/skills/swiftui-coding-guidelines
3
Stars
0
Forks
Updated5d ago
Added1w ago