⏳ This skill is pending AI review.

Scores will appear once the review pipeline completes.

v1.0.0

swift-patterns

efremidze@efremidze⭐ 12 stars· last commit 8mo ago· 1 open issues

Review, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, navigation patterns, performance optimization, and testing best practices.

Choose how to use this skill

You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.

1. Native installer

This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.

Do not guess an installer command or replace an existing version without reviewing the diff.

2. Complete package recommended

Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.

No complete ProSkills package is published for this listing yet.

3. Prompt-only

Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.

Need only the instruction file?

Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.

No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.

—/10

// RATINGS

⭐GitHub Stars
⭐⭐ 12 on GitHubGitHub ↗

Growing

🟢ProSkills Score
—
📍

Not yet listed on ClawHub or SkillsMP

// README

Swift Patterns Skill

Validate Skill Agent Skills Release

A comprehensive Swift/SwiftUI knowledge base for AI coding tools, following the Agent Skills standard.

Provides expert guidance on state management, navigation, view composition, performance optimization, and modern SwiftUI API usage to help AI assistants generate better SwiftUI code.

What This Skill Provides

Comprehensive SwiftUI expertise across:

Core Topics

  • State Management – Property wrapper selection (@State, @Binding, @Observable), ownership rules, data flow patterns
  • Modern APIs – iOS 17/18/26 replacements for deprecated APIs, complete migration guides
  • View Composition – Extraction patterns, parent/child data flow, view identity and performance
  • Navigation – NavigationStack, sheets, deep linking, type-safe routing patterns

Advanced Areas

  • Lists & Collections – Stable identity with ForEach, pagination, lazy containers
  • Performance Optimization – View optimization strategies, avoiding recomputation, memory management
  • Testing & Dependency Injection – Protocol-based patterns, test doubles, testable architecture
  • Code Quality – Refactoring playbooks, code smell detection, anti-pattern identification

All guidance is based on Apple's official documentation and focuses on facts over opinions – no architectural mandates.

Quick Start

Install with a single command:

npx skills add https://github.com/efremidze/swift-patterns-skill --skill swift-patterns

Then use it in your AI assistant:

Review my SwiftUI view for state management issues

View on skills.sh →

Installation

Recommended: Using skills.sh CLI

The easiest way to install:

npx skills add https://github.com/efremidze/swift-patterns-skill --skill swift-patterns

This installs the skill and makes it available to your AI assistant.

Alternative: Claude Code Plugin

For Claude Code users, add via the marketplace:

  1. Add the marketplace:

    /plugin marketplace add efremidze/swift-patterns-skill
    
  2. Install the skill:

    /plugin install swift-patterns@swift-patterns-skill
    

Or configure for your team in .claude/settings.json:

{
  "enabledPlugins": {
    "swift-patterns@swift-patterns-skill": true
  },
  "extraKnownMarketplaces": {
    "swift-patterns-skill": {
      "source": {
        "source": "github",
        "repo": "efremidze/swift-patterns-skill"
      }
    }
  }
}

Manual Installation

If you prefer manual setup:

  1. Clone this repository
  2. Install or symlink swift-patterns/ to your tool's skills directory
  3. Configure your AI tool to use swift-patterns

Skill Structure

The skill follows a progressive disclosure model—core workflows in SKILL.md, detailed guidance in references/:

swift-patterns/
  SKILL.md                          # Entry point: workflow routing, quick refs, review checklist
  references/
    state.md                        # Property wrappers, ownership, @Observable patterns
    navigation.md                   # NavigationStack, sheets, deep linking
    view-composition.md             # View extraction, data flow patterns
    lists-collections.md            # ForEach identity, List vs LazyVStack
    scrolling.md                    # Pagination, scroll position management
    concurrency.md                  # .task modifier, async lifecycle
    performance.md                  # View optimization, lazy loading strategies
    testing-di.md                   # Dependency injection, test doubles
    patterns.md                     # Container views, ViewModifiers, PreferenceKeys
    modern-swiftui-apis.md          # iOS 17/18/26 API replacements and migration
    refactor-playbooks.md           # Step-by-step refactoring guides
    workflows-review.md             # Review methodology and standards
    workflows-refactor.md           # Refactoring methodology, invariants
    code-review-refactoring.md      # Code smells, anti-patterns, quality checks

Related Projects

Other Skills

  • swift-architecture-skill – Architectural patterns and project structure guidance (complements this skill's focus on SwiftUI patterns)

Dynamic Runtime Tools

  • swift-patterns-mcp – MCP server with intelligent search, retrieval, and persistent memory

Key difference:

  • swift-patterns-skill (this repo) = Static guidance, portable, no runtime dependencies
  • swift-patterns-mcp = Dynamic tooling with search, retrieval, and premium integrations

Contributing

Contributions are welcome! This repository follows the Agent Skills open format.

See CONTRIBUTING.md for guidelines on improving the skill content and reference files.

License

MIT License. See LICENSE for details.

// HOW IT'S BUILT

// FILES

2 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.

  • swift-patterns/SKILL.md7.8 KBupstream ↗
    ---
    name: swift-patterns
    description: Review, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, navigation patterns, performance optimization, and testing best practices.
    ---
    
    # swift-patterns
    
    Review, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, and performance-conscious patterns. Prioritize native APIs, Apple design guidance, and testable code structure. This skill focuses on facts and best practices without enforcing specific architectural patterns.
    
    ## Workflow Decision Tree
    
    ### 1) Review existing SwiftUI code
    → Read `references/workflows-review.md` for review methodology
    - Check state management against property wrapper selection (see `references/state.md`)
    - Verify view composition and extraction patterns (see `references/view-composition.md`)
    - Audit list performance and identity stability (see `references/lists-collections.md`)
    - Validate modern API usage (see `references/modern-swiftui-apis.md`)
    - Check async work patterns with .task (see `references/concurrency.md`)
    - Verify navigation implementation (see `references/navigation.md`)
    - Use Review Response Template (below)
    
    ### 2) Refactor existing SwiftUI code
    → Read `references/workflows-refactor.md` for refactor methodology
    - Extract complex views using playbooks (see `references/refactor-playbooks.md`)
    - Migrate deprecated APIs to modern equivalents (see `references/modern-swiftui-apis.md`)
    - Optimize performance hot paths (see `references/performance.md`)
    - Restructure state ownership (see `references/state.md`)
    - Apply common patterns (see `references/patterns.md`)
    - Use Refactor Response Template (below)
    
    ### 3) Implement new SwiftUI features
    - Design data flow first: identify owned vs injected state (see `references/state.md`)
    - Structure views for optimal composition (see `references/view-composition.md`)
    - Use modern APIs only (see `references/modern-swiftui-apis.md`)
    - Handle async work with .task modifier (see `references/concurrency.md`)
    - Apply performance patterns early (see `references/performance.md`)
    - Implement navigation flows (see `references/navigation.md`)
    
    ### 4) Answer best practice questions
    - Load relevant reference file(s) based on topic (see Reference Files below)
    - Provide direct guidance with examples
    
    **If intent unclear, ask:** "Do you want findings only (review), or should I change the code (refactor)?"
    
    ## Response Templates
    
    **Review Response:**
    1. **Scope** - What was reviewed
    2. **Findings** - Grouped by severity with actionable statements
    3. **Evidence** - File paths or code locations
    4. **Risks and tradeoffs** - What could break or needs attention
    5. **Next steps** - What to fix first or verify
    
    **Refactor Response:**
    1. **Intent + scope** - What is being changed and why
    2. **Changes** - Bulleted list with file paths
    3. **Behavior preservation** - What should remain unchanged
    4. **Next steps** - Tests or verification needed
    
    ## Quick Reference: Property Wrapper Selection
    
    | Wrapper | Use When | Ownership |
    |---------|----------|-----------|
    | `@State` | Internal view state (value type or `@Observable` class) | View owns |
    | `@Binding` | Child needs to modify parent's state | Parent owns |
    | `@Bindable` | Injected `@Observable` object needing bindings | Injected |
    | `let` | Read-only value from parent | Injected |
    | `var` + `.onChange()` | Read-only value needing reactive updates | Injected |
    
    **Key rules:**
    - Always mark `@State` as `private` (makes ownership explicit)
    - Never use `@State` for passed values (accepts initial value only)
    - Use `@State` with `@Observable` classes (not `@StateObject`)
    
    See `references/state.md` for detailed guidance and tradeoffs.
    
    ## Quick Reference: Modern API Replacements
    
    | Deprecated | Modern Alternative | Notes |
    |------------|-------------------|-------|
    | `foregroundColor()` | `foregroundStyle()` | Supports dynamic type |
    | `cornerRadius()` | `.clipShape(.rect(cornerRadius:))` | More flexible |
    | `NavigationView` | `NavigationStack` | Type-safe navigation |
    | `tabItem()` | `Tab` API | iOS 18+ |
    | `onTapGesture()` | `Button` | Unless need location/count |
    | `onChange(of:) { value in }` | `onChange(of:) { old, new in }` or `onChange(of:) { }` | Two or zero parameters |
    | `UIScreen.main.bounds` | `GeometryReader` or layout APIs | Avoid hard-coded sizes |
    
    See `references/modern-swiftui-apis.md` for complete migration guide.
    
    ## Review Checklist
    
    Use this when reviewing SwiftUI code:
    
    ### State Management
    - [ ] `@State` properties marked `private`
    - [ ] Passed values NOT declared as `@State` or `@StateObject`
    - [ ] `@Binding` only where child modifies parent state
    - [ ] Property wrapper selection follows ownership rules
    - [ ] State ownership clear and intentional
    
    ### Modern APIs
    - [ ] No deprecated modifiers (foregroundColor, cornerRadius, etc.)
    - [ ] Using `NavigationStack` instead of `NavigationView`
    - [ ] Using `Button` instead of `onTapGesture` when appropriate
    - [ ] Using two-parameter or no-parameter `onChange()`
    
    ### View Composition
    - [ ] Using modifiers over conditionals for state changes (maintains identity)
    - [ ] Complex views extracted to separate subviews
    - [ ] Views kept small and focused
    - [ ] View `body` simple and pure (no side effects)
    
    ### Navigation & Sheets
    - [ ] Using `navigationDestination(for:)` for type-safe navigation
    - [ ] Using `.sheet(item:)` for model-based sheets
    - [ ] Sheets own their dismiss actions
    
    ### Lists & Collections
    - [ ] `ForEach` uses stable identity (never `.indices` for dynamic data)
    - [ ] Constant number of views per `ForEach` element
    - [ ] No inline filtering in `ForEach` (prefilter and cache)
    - [ ] No `AnyView` in list rows
    
    ### Performance
    - [ ] Passing only needed values to views (not large config objects)
    - [ ] Eliminating unnecessary dependencies
    - [ ] Checking value changes before state assignment in hot paths
    - [ ] Using `LazyVStack`/`LazyHStack` for large lists
    - [ ] No object creation in view `body`
    
    ### Async Work
    - [ ] Using `.task` for automatic cancellation
    - [ ] Using `.task(id:)` for value-dependent tasks
    - [ ] Not mixing `.onAppear` with async work
    
    See reference files for detailed explanations of each item.
    
    ## Constraints
    
    - **Swift/SwiftUI focus only** - Exclude server-side Swift and UIKit unless bridging required
    - **No Swift concurrency patterns** - Use `.task` for SwiftUI async work
    - **No architecture mandates** - Don't require MVVM/MVC/VIPER or specific structures
    - **No formatting/linting rules** - Focus on correctness and patterns
    - **No tool-specific guidance** - No Xcode, Instruments, or IDE instructions
    - **Citations allowed:** `developer.apple.com/documentation/swiftui/`, `developer.apple.com/documentation/swift/`
    
    All workflows must follow these constraints.
    
    ## Philosophy
    
    This skill focuses on **facts and best practices** from Apple's documentation:
    - Modern APIs over deprecated ones
    - Clear state ownership patterns
    - Performance-conscious view composition
    - Testable code structure
    - No architectural mandates (MVVM/VIPER not required)
    - Apple Human Interface Guidelines adherence
    
    ## Reference Files
    
    All references in `references/`:
    - `workflows-review.md` - Review methodology and findings taxonomy
    - `workflows-refactor.md` - Refactor methodology and invariants
    - `refactor-playbooks.md` - Step-by-step refactor guides
    - `state.md` - Property wrappers and ownership patterns
    - `navigation.md` - Navigation implementation patterns
    - `view-composition.md` - View structure and extraction
    - `lists-collections.md` - Identity and ForEach patterns
    - `scrolling.md` - Scroll handling and pagination
    - `concurrency.md` - Async work with .task
    - `performance.md` - Optimization strategies
    - `testing-di.md` - Testing and dependency injection
    - `patterns.md` - Common SwiftUI patterns
    - `modern-swiftui-apis.md` - Legacy API migration
    - `code-review-refactoring.md` - Code quality checks
    
  • README.mdupstream ↗

    Contents are not inlined in the catalog. Open the upstream file.

Plain-text copy, no login: /skill-bundles/efremidze-swift-patterns-skill-swift-patterns.md

// REPO STATS

12 stars
1 open issues
Last commit: 8mo ago