Communitygithub.com

ComeOnOliver/skillshub

SwiftUI 뷰 파일을 일관된 구조, 의존성 주입, Observation 사용법에 맞게 리팩토링하고 검토합니다. SwiftUI 뷰의 레이아웃/순서를 정리하거나, 뷰 모델을 안전하게 처리(가능하면 옵셔널이 아닌 방식)하거나, 의존성 및 @Observable 상태를 초기화하고 전달하는 방식을 표준화할 때 사용하세요.

skillshub란 무엇인가요?

이 스킬은 SwiftUI 뷰 파일을 일관된 구조와 모범 사례에 따라 리팩토링하고 검토하는 데 도움을 줍니다. 주요 기능으로는 뷰 내부 속성 순서 통일(Environment, let, @State 등), Model-View 패턴 선호(복잡한 비즈니스 로직은 모델/서비스에 위임하고 뷰는 가볍게 유지), 거대한 body 분할, 기존 뷰 모델의 안전한 처리(옵셔널 제거, init에서 의존성 주입), 그리고 @Observable 및 @State의 올바른 사용법을 포함합니다. 이 스킬은 Claude Code, Cursor, Codex 등 다양한 AI 에이전트 플랫폼에서 사용할 수 있습니다. SKILL.md 문서에 정의된 규칙을 기반으로 작동하며, 개발자가 SwiftUI 뷰의 일관성과 유지보수성을 높이기 위해 명시적으로 요청할 때 적용됩니다. 특히 뷰의 구조 리팩토링, 의존성 주입 방식 표준화, Observation 매크로를 활용한 상태 관리 개선에 초점을 맞춥니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/dimillian/swiftui-view-refactor

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

SwiftUI 뷰 리팩토링

개요

SwiftUI 뷰에 일관된 구조와 의존성 패턴을 적용하며, 순서, Model-View 패턴, 신중한 뷰 모델 처리, 올바른 Observation 사용법에 초점을 맞춥니다.

핵심 가이드라인

1) 뷰 속성 순서 (위 → 아래)

  • Environment
  • private/public let
  • @State / 기타 저장 속성
  • 계산된 var (뷰 제외)
  • init
  • body
  • 계산된 뷰 빌더 / 기타 뷰 헬퍼
  • 헬퍼 / 비동기 함수

2) MV 패턴 선호

  • 기본값은 MV: 뷰는 가벼운 상태 표현이며, 모델/서비스가 비즈니스 로직을 소유합니다.
  • 오케스트레이션에는 @State, @Environment, @Query, task/onChange를 선호합니다.
  • 서비스와 공유 모델은 @Environment를 통해 주입하고, 뷰는 작고 합성 가능하게 유지합니다.
  • 뷰 모델을 도입하기보다는 큰 뷰를 하위 뷰로 분할합니다.

3) 큰 body 및 뷰 속성 분할

  • body가 한 화면을 넘거나 여러 논리적 섹션이 있으면 더 작은 하위 뷰로 분할합니다.
  • 큰 계산된 뷰 속성(var header: some View { ... })은 상태나 복잡한 분기가 있을 때 전용 View 타입으로 추출합니다.
  • 관련 하위 뷰를 같은 파일에 계산된 뷰 속성으로 유지해도 괜찮지만, 구조적으로 의미가 있거나 재사용이 의도될 때만 별도의 View 구조체로 추출합니다.
  • 상위 뷰 상태 전체를 재사용하기보다는 작은 입력(데이터, 바인딩, 콜백)을 전달하는 것을 선호합니다.

예시 (섹션 추출):

var body: some View {
    VStack(alignment: .leading, spacing: 16) {
        HeaderSection(title: title, isPinned: isPinned)
        DetailsSection(details: details)
        ActionsSection(onSave: onSave, onCancel: onCancel)
    }
}

예시 (긴 body → 짧은 body + 동일 파일 내 계산된 뷰):

var body: some View {
    List {
        header
        filters
        results
        footer
    }
}

private var header: some View {
    VStack(alignment: .leading, spacing: 6) {
        Text(title).font(.title2)
        Text(subtitle).font(.subheadline)
    }
}

private var filters: some View {
    ScrollView(.horizontal, showsIndicators: false) {
        HStack {
            ForEach(filterOptions, id: \.self) { option in
                FilterChip(option: option, isSelected: option == selectedFilter)
                    .onTapGesture { selectedFilter = option }
            }
        }
    }
}

예시 (복잡한 계산된 뷰 추출):

private var header: some View {
    HeaderSection(title: title, subtitle: subtitle, status: status)
}

private struct HeaderSection: View {
    let title: String
    let subtitle: String?
    let status: Status

    var body: some View {
        VStack(alignment: .leading, spacing: 4) {
            Text(title).font(.headline)
            if let subtitle { Text(subtitle).font(.subheadline) }
            StatusBadge(status: status)
        }
    }
}

4) 뷰 모델 처리 (이미 존재하는 경우에만)

  • 요청이나 기존 코드에 명확히 필요하지 않으면 뷰 모델을 도입하지 마십시오.
  • 뷰 모델이 이미 존재하면 가능한 옵셔널 대신 non-optional로 만듭니다.
  • 의존성을 init을 통해 뷰에 전달한 후, 뷰의 init에서 뷰 모델에 전달합니다.
  • bootstrapIfNeeded 패턴은 피합니다.

예시 (Observation 기반):

@State private var viewModel: SomeViewModel

init(dependency: Dependency) {
    _viewModel = State(initialValue: SomeViewModel(dependency: dependency))
}

5) Observation 사용법

  • @Observable 참조 타입은 루트 뷰에서 @State로 저장합니다.
  • 필요에 따라 observable을 명시적으로 전달하고, 필수가 아닌 이상 옵셔널 상태는 피합니다.

작업 흐름

  1. 순서 규칙에 맞게 뷰의 속성 순서를 재정렬합니다.
  2. MV를 선호: @State, @Environment, @Query, task, onChange를 사용하여 가벼운 오케스트레이션을 뷰로 이동합니다.
  3. 뷰 모델이 있으면, 옵셔널 뷰 모델을 non-optional @State 뷰 모델로 교체하고, 뷰에서 의존성을 전달하여 init에서 초기화합니다.
  4. Observation 사용법 확인: 루트 @Observable 뷰 모델에는 @State를 사용하고, 중복 래퍼는 제거합니다.
  5. 동작은 그대로 유지: 요청되지 않은 레이아웃이나 비즈니스 로직은 변경하지 않습니다.

참고 사항

  • 큰 조건부 블록보다는 작고 명시적인 헬퍼를 선호합니다.
  • 계산된 뷰 빌더는 body 아래에, 뷰가 아닌 계산된 변수는 init 위에 유지합니다.
  • MV 우선 가이드 및 근거에 대해서는 references/mv-patterns.md를 참조하세요.

큰 뷰 처리

  • SwiftUI 뷰 파일이 약 300줄을 초과하면 확장(extension)을 사용하여 관련 헬퍼를 그룹화합니다. 비동기 함수와 헬퍼 함수는 전용 private 확장으로 이동하고, 목적을 설명하는 // MARK: - 주석(예: // MARK: - Actions, // MARK: - Subviews, // MARK: - Helpers)으로 구분합니다. 기본 struct는 저장 속성, init, body에 집중하고, 뷰를 구성하는 계산된 변수도 파일이 길 때 마크를 통해 그룹화합니다.

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

관련 스킬