본문으로 건너뛰기
cccskills
무료GitHub에 공개

view-refactor

Refactor large macOS SwiftUI views into focused files and components. Clarify window state, selection, commands, and AppKit integration while preserving existing behavior and keeping the main layout stable as users change selections.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Refactor macOS SwiftUI views and scenes into stable structure. Use when splitting large views, tightening scene state, or narrowing AppKit escapes.

설치 방법 보기

이럴 때 유용합니다

  • Split oversized SwiftUI views
  • Organize state for each window
  • Extract toolbar and command logic
  • Isolate AppKit integration

포함된 파일(2)

  • SKILL.md5.4 KB
  • agents/openai.yaml328 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

View Refactor

Overview

Refactor macOS views toward small, explicit, stable scene and view types. Default to native SwiftUI for layout, selection, commands, and settings. Reach for AppKit only at the narrow edges where desktop behavior truly requires it.

Core Guidelines

1) Model scenes explicitly

  • Break the app into meaningful scene roots: main window, settings, utility windows, inspectors, or menu bar extras.
  • Do not let one giant root view silently own every desktop surface.

2) Keep a predictable file shape

  • Follow this ordering unless the file already has a stronger local convention:
  • Environment
  • private/public let
  • @State / other stored properties
  • computed var (non-view)
  • init
  • body
  • computed view builders / other view helpers
  • helper / async functions

2b) Split files by responsibility

  • For non-trivial apps, do not keep the full app, all views, models, stores, networking clients, process clients, and helpers in one Swift file.
  • Accept a single Swift file only for tiny throwaway examples or snippets: roughly under 50 lines, one screen, no persistence, no networking/process client, and no reusable models.
  • Use App/<AppName>App.swift for the @main app and AppDelegate only.
  • Keep Views/ContentView.swift focused on root layout and composition; move feature UI into files such as Views/SidebarView.swift, Views/DetailView.swift, and Views/ComposerView.swift.
  • Move value types and selection enums into Models/*.swift, stores into Stores/*.swift, app-server/network/process clients into Services/*.swift, and small formatters/resolvers/extensions into Support/*.swift.
  • Keep files small and named after the primary type they contain.

3) Prefer dedicated subview types over many computed some View fragments

  • Extract meaningful desktop sections like sidebar rows, detail panels, inspectors, or toolbar content into focused subviews.
  • Keep computed some View helpers small and rare.
  • Pass explicit data, bindings, and actions into subviews instead of handing down the whole scene model.

4) Keep selection and layout stable

  • Prefer one stable split or window layout with local conditionals inside it.
  • Avoid top-level branch swapping between radically different roots when selection changes.
  • Let the layout be constant; let state drive the content inside it.

5) Extract commands, toolbars, and actions out of body

  • Do not bury non-trivial button logic inline.
  • Do not mix command routing, menu state, and layout in the same block if they can be named clearly.
  • Keep body readable as UI, not as a desktop view controller.

6) Use scene and app storage intentionally

  • Use @SceneStorage for per-window ephemeral state when it truly helps restore the scene.
  • Use @AppStorage for durable preferences, not transient UI toggles that only matter in one window.
  • Keep scene-owned state close to the scene root.

7) Keep AppKit escape hatches narrow

  • If a representable or NSWindow bridge exists, isolate it behind a small wrapper or helper.
  • Do not let AppKit references spread through unrelated SwiftUI views.
  • If the bridge starts owning the feature, re-evaluate the architecture.

8) Observation usage

  • For @Observable reference types on modern macOS targets, store them as @State in the owning view.
  • Pass observables explicitly to children.
  • On older deployment targets, fall back to @StateObject and @ObservedObject where needed.

Workflow

  1. Identify the current scene boundary and whether the file is trying to do too much.
  2. Reorder the file into a predictable top-to-bottom structure.
  3. Extract desktop-specific sections into dedicated subview types.
  4. Stabilize the root layout around selection, scenes, and commands rather than top-level branching.
  5. Move action logic, command routing, and toolbar behavior into named helpers or separate types.
  6. Tighten any AppKit bridge so the imperative edge is small and explicit.
  7. Keep behavior intact unless the request explicitly asks for structural and behavioral changes together.

Refactor Checklist

  • Split oversized view files before adding more UI.
  • Move pure models, identifiers, and selection enums out of view files.
  • Move Process, URLSession, app-server, and platform client code out of SwiftUI views into Services/.
  • Keep AppDelegate and the @main app entrypoint minimal.
  • Build after each major split so compile errors stay local.

Common Smells

  • A root view that mixes window scaffolding, settings, toolbar code, command handling, and detail layout.
  • A single app file that mixes app entrypoint, root layout, feature views, models, stores, service clients, and support extensions.
  • iOS-style push navigation forced into a Mac sidebar-detail problem.
  • Several booleans for mutually exclusive inspectors, sheets, or utility windows.
  • AppKit objects passed through many SwiftUI layers without a clear ownership reason.
  • Large computed view fragments standing in for real subviews.

Notes

  • A good macOS refactor should make scene structure, selection flow, and command ownership obvious.
  • When the problem is fundamentally a missing desktop pattern, use swiftui-patterns.
  • When the problem is fundamentally a boundary with AppKit, use appkit-interop.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Review charts, diagrams, and dashboards for accessibility, including color contrast, keyboard access, and text alternatives. Get specific guidance for preserving key findings in screen readers, static exports, and reduced-motion views.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Reviewing dashboard colors and keyboard access
  • Writing chart alt text and long descriptions
  • Preparing accessible figures for PDF reports
openai/plugins7.5천2026년 10월 8일 업데이트

Give a photo collection a consistent look using Adobe tools to adjust color, tone, presets, and optional crops. Review a before-and-after sample before processing the full set, then receive links to the edited images.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Giving travel photos a consistent look
  • Unifying photos taken in mixed lighting
  • Applying a warm or cinematic style across a photo set
openai/plugins7.5천2026년 10월 8일 업데이트

Visualize a logo, sketch, or design on products such as mugs, shirts, and business cards. Review a pilot image, generate a visually consistent set, and collect the results on a shareable Firefly Board.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Preview a logo on mugs and shirts
  • Turn a hand-drawn sketch into product mockups
  • Create consistent brand presentation images
openai/plugins7.5천2026년 10월 8일 업데이트

Prepare images and videos for social platforms using Adobe tools. Create image crops that keep the subject in view, expand backgrounds when available, preview a full-set sample, and resize videos while preserving their aspect ratio.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating image variants for multiple social platforms
  • Cropping photos for Instagram Stories
  • Preparing LinkedIn images and YouTube thumbnails
openai/plugins7.5천2026년 10월 8일 업데이트

Create flyers, social posts, business cards, and other visuals from Adobe Express templates. Choose a template, customize its text and background color, and receive a design link, with additional editing and export options depending on the available tools.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating an event flyer
  • Designing an Instagram post
  • Customizing business card text and colors
openai/plugins7.5천2026년 10월 8일 업데이트

Turn an uploaded video into three highlight edits with Adobe Quick Cut. Choose a target length and style, then compare versions that feature different moments and download the ones you prefer.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating a short highlight video for social media
  • Condensing interview footage into a highlight reel
  • Comparing three edits with different moment selections
openai/plugins7.5천2026년 10월 8일 업데이트

openai의 스킬 모두 보기

이 스킬의 문제 신고