Communitygithub.com

ComeOnOliver/skillshub

適用於將邏輯從 SwiftUI 視圖中分離、選擇架構模式、重構視圖檔案,或當你問「這段程式碼該放哪裡」、「如何組織我的 SwiftUI App」、「MVVM vs TCA vs 純 SwiftUI」、「如何讓 SwiftUI 可測試」時 — 為 iOS 26+ 提供全面的架構模式與重構工作流程。

skillshub 是什麼?

這個技能提供了一個完整的 SwiftUI 架構決策框架,涵蓋 Apple 原生模式、MVVM、TCA 和協調器模式,專為 iOS 26+ 設計。它透過屬性包裝器決策樹、狀態即橋接模式,以及清晰的關注點分離原則,幫助開發者將邏輯從視圖中提取出來,提升程式碼的可測試性與可維護性。技能內含多種重構工作流程,能引導你根據 App 複雜度、團隊規模和測試需求,選擇最合適的架構模式。 此技能支援 Claude Code、Cursor 和 Codex 等 AI 代理平台,並以詳細的 SKILL.md 文件呈現。文件內容包含架構決策樹、程式碼範例(如 @Observable 模型、State-as-Bridge 模式)、常見反模式(如 God ViewModel、將商業邏輯放在 ViewModel 中)的警示,以及 MVVM 和 TCA 的實作指南。開發者可以透過問題如「這段程式碼該放哪裡」或「如何讓 SwiftUI 可測試」來觸發此技能,以獲得即時的架構建議。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/CharlesWiltgen/Axiom/axiom-swiftui-architecture

在你喜歡的 AI 中提問

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

說明文件

SwiftUI 架構

何時使用此技能

當您遇到以下情況時,請使用此技能:

  • 您在 SwiftUI 視圖檔案中有邏輯,並希望將其提取出來
  • 在 MVVM、TCA、純 SwiftUI 模式或協調器之間做選擇
  • 重構視圖以分離關注點
  • 讓 SwiftUI 程式碼可測試
  • 詢問「這段程式碼該放哪裡?」
  • 決定要使用哪個屬性包裝器(@State、@Environment、@Bindable)
  • 為團隊開發組織 SwiftUI 程式碼庫

範例提示

您可能提出的問題此技能的幫助
「我的模型視圖檔案中有不少關於邏輯的程式碼。我該如何提取?」提供包含決策樹的重構工作流程,引導邏輯該歸屬何處
「我應該使用 MVVM、TCA,還是 Apple 的純模式?」基於 App 複雜度、團隊規模和測試需求的決策標準
「如何讓我的 SwiftUI 程式碼可測試?」展示可實現無需 SwiftUI 匯入即可測試的分離模式
「格式化器和計算應該放在哪裡?」反模式章節防止邏輯出現在視圖主體中
「我該使用哪個屬性包裝器?」@State、@Environment、@Bindable 或純屬性的決策樹

快速架構決策樹

驅動您架構選擇的是什麼?
│
├─ 剛開始建立小型/中型 App,想要 Apple 模式?
│  └─ 使用 Apple 原生模式(第 1 部分)
│     - 使用 @Observable 模型處理商業邏輯
│     - 將狀態作為非同步邊界的橋樑
│     - 屬性包裝器決策樹
│
├─ 熟悉 UIKit 中的 MVVM?
│  └─ 使用 MVVM 模式(第 2 部分)
│     - 將 ViewModel 作為呈現適配器
│     - 清晰的視圖/ViewModel/模型分離
│     - 與 @Observable 配合良好
│
├─ 複雜的 App,需要嚴謹的可測試性和團隊一致性?
│  └─ 考慮 TCA(第 3 部分)
│     - State/Action/Reducer/Store 架構
│     - 出色的測試故事
│     - 學習曲線與樣板程式碼的取捨
│
└─ 複雜的導航、深度連結、多個進入點?
   └─ 加入協調器模式(第 4 部分)
      - 可與上述任何模式結合
      - 從視圖中提取導航邏輯
      - 使用 NavigationPath 和協調器物件

第 1 部分:Apple 原生模式(iOS 26+)

核心原則

「資料模型提供了資料與與資料互動的視圖之間的分離。這種分離促進模組化,改善可測試性,並有助於更容易理解 App 的運作方式。」 — Apple 開發者文件

Apple 現代的 SwiftUI 模式(WWDC 2023-2025)圍繞以下幾點:

  1. @Observable 用於資料模型(取代 ObservableObject)
  2. 狀態作為橋樑 用於非同步邊界(WWDC 2025)
  3. 三個屬性包裝器:@State、@Environment、@Bindable
  4. 同步 UI 更新 以支援動畫

狀態即橋接模式

問題

非同步函式會建立可能中斷動畫的暫停點:

// ❌ 有問題:動畫可能錯過影格截止時間
struct ColorExtractorView: View {
    @State private var isLoading = false

    var body: some View {
        Button(

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

相關技能