К основному содержанию
скилл CX Codex

swift-ui-architect — скилл для Claude Code: правила и установка

Скилл swift-ui-architect контролирует модульную архитектуру MVVM-C на SwiftUI, Swift 6.2 и локальных SPM-пакетах. Защищает границы слоёв Domain, Data и Feature при генерации и рефакторинге кода.

MIT 283 установок ★ 227 обновлён 2026-08-15

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add pproenca/dot-skills --skill swift-ui-architect -a claude-code
Открыть на GitHub

Что делает swift-ui-architect

Скилл следит за чистотой модульной архитектуры MVVM-C в проектах на SwiftUI и Swift 6.2. Код делится между локальными SPM-пакетами с жёсткими границами. Модули Feature подключают только Domain и DesignSystem. Доступ к пакету Data или соседним фичам запрещён. Точкой сборки остаётся App-таргет. Именно там инициализируется DependencyContainer, живут конкретные координаторы с NavigationPath и настраивается маршрутизация Route Shell.

Скилл запрещает ObservableObject и @Published, требуя макрос @Observable. Промежуточный слой interactor или use-case не предусмотрен: вьюмодели обращаются напрямую к протоколам репозиториев из Domain. Всю работу с сетью, SwiftData и фоновой синхронизацией берёт на себя пакет Data. Чтение строится по схеме stale-while-revalidate, а запись уходит в оптимистичную очередь.

В проектах на старых версиях Swift со связкой @Published эти правила сразу сломают сборку.

Какие задачи решает

  • разграничить зависимости между SPM-пакетами Feature, Data и Domain
  • перевести состояние вьюмоделей с ObservableObject на макрос @Observable
  • вынести координацию экранов и NavigationPath в App-таргет
  • настроить чтение stale-while-revalidate и очереди синхронизации

Примеры запросов агенту

  • Проверь модуль ProfileFeature: не протекли ли импорты Data в представления?
  • Сделай рефакторинг CartViewModel под Swift 6.2 с макросом @Observable и прямым вызовом Domain-репозитория.
  • Настрой координатор и route shell для экрана оформления заказа через NavigationPath.

Как установить swift-ui-architect

1Через Skills CLI (Vercel)

npx skills add pproenca/dot-skills --skill swift-ui-architect -a claude-code

2Вручную: положить файлы

~/.claude/skills/swift-ui-architect/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/swift-ui-architect/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о swift-ui-architect

Как установить swift-ui-architect в Claude Code?

Выполните в терминале команду npx skills add pproenca/dot-skills --skill swift-ui-architect -a claude-code. Конфигурация запишется в ~/.claude/skills/swift-ui-architect/SKILL.md.

Какие зависимости разрешено подключать модулям Feature?

Пакеты фичей могут импортировать только Domain и DesignSystem. Импорт пакета Data или вызовы соседних фичей напрямую запрещены правилами архитектуры.

Почему в архитектуре нет слоя Use Case?

По правилам скилла вьюмодели вызывают протоколы репозиториев напрямую из Domain. Отказ от промежуточных интеракторов сокращает лишний шаблонный код в Swift 6.2.

Исходный текст

SKILL.md · MIT
---
name: swift-ui-architect
description: Opinionated SwiftUI architecture enforcement for iOS 26 / Swift 6.2 clinic modular MVVM-C apps using local SPM package boundaries. Enforces App-target `DependencyContainer` + route shells, @Observable ViewModels/coordinators, Domain repository/coordinator/error-routing protocols, Data-owned I/O, stale-while-revalidate reads, and optimistic queued sync. Use when writing, reviewing, or refactoring SwiftUI architecture, navigation, dependency wiring, or repository boundaries.
---

# SwiftUI Modular MVVM-C Architecture

Opinionated architecture enforcement for SwiftUI clinic-style apps. This skill aligns to the iOS 26 / Swift 6.2 clinic architecture: modular MVVM-C in local SPM packages, concrete coordinators and route shells in the App target, pure Domain protocols, and Data as the only I/O layer.

## Mandated Architecture Stack

```
┌───────────────────────────────────────────────────────────────┐
│ App target: DependencyContainer, Coordinators, Route Shells   │
├───────────────┬───────────────┬───────────────┬──────────────┤
│ Feature* SPM  │ Feature* SPM  │ Feature* SPM  │ Feature* SPM │
│ View + VM     │ View + VM     │ View + VM     │ View + VM    │
├───────────────────────────────────────────────────────────────┤
│ Data SPM: repository impls, remote/local, retry, sync queue   │
├───────────────────────────────────────────────────────────────┤
│ Domain SPM: models, repository protocols, coordinator protocols│
│ and ErrorRouting/AppError                                      │
├───────────────────────────────────────────────────────────────┤
│ Shared SPMs: DesignSystem, SharedKit                           │
└───────────────────────────────────────────────────────────────┘
```

**Dependency Rule**: Feature modules import `Domain` + `DesignSystem` only. Features never import `Data` or other features. App target is the only convergence point.


## Clinic Architecture Contract (iOS 26 / Swift 6.2)

All guidance in this skill assumes the clinic modular MVVM-C architecture:

- Feature modules import `Domain` + `DesignSystem` only (never `Data`, never sibling features)
- App target is the convergence point and owns `DependencyContainer`, concrete coordinators, and Route Shell wiring
- `Domain` stays pure Swift and defines models plus repository, `*Coordinating`, `ErrorRouting`, and `AppError` contracts
- `Data` owns SwiftData/network/sync/retry/background I/O and implements Domain protocols
- Read/write flow defaults to stale-while-revalidate reads and optimistic queued writes
- ViewModels call repository protocols directly (no default use-case/interactor layer)

## When to Apply

Reference these guidelines when:
- Building or refactoring feature modules under local SPM packages
- Wiring coordinators, route shells, and dependency container factories
- Defining Domain protocols for repositories, coordinators, and error routing
- Enforcing Data-only ownership of networking, persistence, and sync
- Reviewing stale-while-revalidate reads and optimistic queued writes

## Non-Negotiable Constraints (iOS 26 / Swift 6.2)

- `@Observable` for ViewModels/coordinators, `ObservableObject` / `@Published` never
- No dedicated use-case/interactor layer: ViewModels call Domain repository protocols directly
- Coordinator protocols live in Domain; concrete coordinators own `NavigationPath` in App target
- Route shells live in App target and own `.navigationDestination` mapping
- `AppError` + `ErrorRouting` drive presentation policy; ViewModels do not hardcode global error UI
- SwiftData / URLSession / retry / sync queue logic stays in Data package only

## Rule Categories by Priority

| Priority | Category | Impact | Prefix | Rules |
|----------|----------|--------|--------|-------|
| 1 | View Identity & Diffing | CRITICAL | `diff-` | 6 |
| 2 | State Architecture | CRITICAL | `state-` | 7 |
| 3 | View Composition | HIGH | `view-` | 6 |
| 4 | Navigation & Coordination | HIGH | `nav-` | 5 |
| 5 | Layer Architecture | HIGH | `layer-` | 6 |
| 6 | Dependency Injection | MEDIUM-HIGH | `di-` | 4 |
| 7 | List & Collection Performance | MEDIUM | `list-` | 4 |
| 8 | Async & Data Flow | MEDIUM | `data-` | 5 |

## Quick Reference

### 1. View Identity & Diffing (CRITICAL)

- [`diff-equatable-views`](references/diff-equatable-views.md) - Apply @Equatable macro to every SwiftUI view
- [`diff-closure-skip`](references/diff-closure-skip.md) - Use @SkipEquatable for closure/handler properties
- [`diff-reference-types`](references/diff-reference-types.md) - Never store reference types without Equatable conformance
- [`diff-identity-stability`](references/diff-identity-stability.md) - Use stable O(1) identifiers in ForEach
- [`diff-avoid-anyview`](references/diff-avoid-anyview.md) - Never use AnyView — use @ViewBuilder or generics
- [`diff-printchanges-debug`](references/diff-printchanges-debug.md) - Use _printChanges() to diagnose unnecessary re-renders

### 2. State Architecture (CRITICAL)

- [`state-observable-class`](references/state-observable-class.md) - Use @Observable classes for all ViewModels
- [`state-ownership`](references/state-ownership.md) - @State for owned data, plain property for injected data
- [`state-single-source`](references/state-single-source.md) - One source of truth per piece of state
- [`state-scoped-observation`](references/state-scoped-observation.md) - Leverage @Observable property-level tracking
- [`state-binding-minimal`](references/state-binding-minimal.md) - Pass @Binding only for two-way data flow
- [`state-environment-global`](references/state-environment-global.md) - Use @Environment for app-wide shared dependencies
- [`state-no-published`](references/state-no-published.md) - Never use @Published or ObservableObject

### 3. View Composition (HIGH)

- [`view-body-complexity`](references/view-body-complexity.md) - Maximum 10 nodes in view body
- [`view-extract-subviews`](references/view-extract-subviews.md) - Extract computed properties/helpers into separate View structs
- [`view-no-logic-in-body`](references/view-no-logic-in-body.md) - Zero business logic in body
- [`view-minimal-dependencies`](references/view-minimal-dependencies.md) - Pass only needed properties, not entire models
- [`view-viewbuilder-composition`](references/view-viewbuilder-composition.md) - Use @ViewBuilder for conditional composition
- [`view-no-init-sideeffects`](references/view-no-init-sideeffects.md) - Never perform work in View init

### 4. Navigation & Coordination (HIGH)

- [`nav-coordinator-pattern`](references/nav-coordinator-pattern.md) - Every feature has a coordinator owning NavigationStack
- [`nav-routes-enum`](references/nav-routes-enum.md) - Define all routes as a Hashable enum
- [`nav-deeplink-support`](references/nav-deeplink-support.md) - Coordinators must support URL-based deep linking
- [`nav-modal-sheets`](references/nav-modal-sheets.md) - Present modals via coordinator, not inline
- [`nav-no-navigationlink`](references/nav-no-navigationlink.md) - Never use NavigationLink(destination:) — use navigationDestination(for:)

### 5. Layer Architecture (HIGH)

- [`layer-dependency-rule`](references/layer-dependency-rule.md) - Domain layer has zero framework imports
- [`layer-usecase-protocol`](references/layer-usecase-protocol.md) - Do not add a use-case layer; keep orchestration in ViewModel + repository protocols
- [`layer-repository-protocol`](references/layer-repository-protocol.md) - Repository protocols in Domain, implementations in Data
- [`layer-model-value-types`](references/layer-model-value-types.md) - Domain models are structs, never classes
- [`layer-no-view-repository`](references/layer-no-view-repository.md) - Views never access repositories directly; ViewModel calls repository protocols
- [`layer-viewmodel-boundary`](references/layer-viewmodel-boundary.md) - ViewModels expose display-ready state only

### 6. Dependency Injection (MEDIUM-HIGH)

- [`di-environment-injection`](references/di-environment-injection.md) - Inject container-managed protocol dependencies via @Environment
- [`di-protocol-abstraction`](references/di-protocol-abstraction.md) - All injected dependencies are protocol types
- [`di-container-composition`](references/di-container-composition.md) - Compose `DependencyContainer` in App target and expose VM factories
- [`di-mock-testing`](references/di-mock-testing.md) - Every protocol dependency has a mock for testing

### 7. List & Collection Performance (MEDIUM)

- [`list-constant-viewcount`](references/list-constant-viewcount.md) - ForEach must produce constant view count per element
- [`list-filter-in-model`](references/list-filter-in-model.md) - Filter/sort in ViewModel, never inside ForEach
- [`list-lazy-stacks`](references/list-lazy-stacks.md) - Use LazyVStack/LazyHStack for unbounded content
- [`list-id-keypath`](references/list-id-keypath.md) - Provide explicit id keyPath — never rely on implicit identity

### 8. Async & Data Flow (MEDIUM)

- [`data-task-modifier`](references/data-task-modifier.md) - Use `.task(id:)` as the primary feature data-loading trigger
- [`data-async-init`](references/data-async-init.md) - Never perform async work in init
- [`data-error-loadable`](references/data-error-loadable.md) - Model loading states as enum, not booleans
- [`data-combine-avoid`](references/data-combine-avoid.md) - Prefer async/await over Combine for new code
- [`data-cancellation`](references/data-cancellation.md) - Use .task automatic cancellation — never manage Tasks manually

## How to Use

Read individual reference files for detailed explanations and code examples:

- [Section definitions](references/_sections.md) - Category structure and impact levels
- [Rule template](assets/templates/_template.md) - Template for adding new rules

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions and ordering |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |
| [metadata.json](metadata.json) | Version and reference information |

© pproenca · MIT · pproenca/dot-skills

Похожие скиллы

Все скиллы по теме «Мобильная разработка» →
clerk-swift clerk Скилл clerk-swift для Claude Code настраивает UI аутентификации Clerk в нативных приложениях Swift на iOS и macOS. Помогает внедрить готовые экраны ClerkKitUI или собрать собственный флоу через ClerkKit. CX Codex +1 15 200установок swift-formatstyle dpearson2699 Скилл swift-formatstyle помогает переводить код iOS на FormatStyle и ParseableFormatStyle вместо старых Formatter. Пригодится при настройке вывода валют, дат и чисел в SwiftUI с учётом локалей. CX Codex +1 3 000установок swift-architecture-skill efremidze Скилл swift-architecture-skill для Claude Code помогает выбрать и применить архитектуру для SwiftUI- или UIKit-кода. Он включается при проектировании, рефакторинге и ревью функций и модулей. CX Codex +1 2 100установок swift-expert personamanagmentlayer Скилл swift-expert для Claude Code помогает писать и разбирать код на Swift для iOS и macOS. Охватывает задачи со SwiftUI, Combine и современным синтаксисом Swift. CX Codex +1 163установок swift-modernizer John Rogers (@johnrogers) Субагент swift-modernizer находит устаревшие конструкции Swift и переносит их на async/await, современные API и SwiftUI. Он пригодится при поэтапной модернизации старого кода. CX Codex ★ 233звёзд репо swift-code-reviewer John Rogers (@johnrogers) Субагент swift-code-reviewer проверяет код на Swift и iOS на безопасность, строгую конкурентность, производительность и соответствие HIG перед тестированием. CX Codex ★ 233звёзд репо

Из того же набора139

Весь набор →
ruby-optimise Скилл ruby-optimise для Claude Code подсказывает, как писать и проверять Ruby-код с учётом производительности. Разбирает работу с коллекциями, ActiveRecord и выделением памяти. CX Codex +1 292установок swift-refactor Скилл swift-refactor для Claude Code помогает перестроить существующий код SwiftUI под модульную MVVM-C-архитектуру. Он подключается к задачам по навигации, состоянию и разделению приложения на слои. CX Codex +1 289установок ios-testing Скилл ios-testing для Claude Code собирает практики тестирования модульных приложений на iOS 26 и Swift 6.2. Описывает юнит-, UI- и снэпшот-тесты с учётом изоляции акторов и протокольных моков. CX Codex +1 288установок dev-rfc Скилл dev-rfc помогает писать технические предложения, проектные документы и архитектурные описания кодовой базы по готовым шаблонам. CX Codex +1 286установок ios-taste Скилл ios-taste проектирует интерфейсы SwiftUI для iOS 18+ с упором на задачи пользователя, исключая шаблонный код. CX Codex +1 280установок ios-storyboard Скилл ios-storyboard для Claude Code помогает поддерживать и рефакторить экраны Storyboard в проектах на Swift 6.2, править Auto Layout, разрешать конфликты слияния и готовить миграцию на SwiftUI. CX Codex +1 277установок rails-design-system Скилл rails-design-system с 51 правилом построения дизайн-системы в Rails. Когда создавать партиалы, компоненты, хелперы, Turbo Frames и Stimulus-контроллеры. CX Codex +1 276установок ios-navigation Скилл ios-navigation задаёт строгие правила навигации SwiftUI для модульной архитектуры MVVM-C на Swift 6.2. Помогает проектировать переходы, диплинки и модальные экраны. CX Codex +1 275установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой