swiftui-api-patterns

Official

Ensure correct SwiftUI patterns in Harness

Authorsmykla-skalski
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Provides a comprehensive, enforceable set of SwiftUI API usage rules to prevent subtle UI bugs, identity-loss during diffing, stale selection states, and inconsistent UX in the Harness Monitor macOS app.

Core Features & Use Cases

  • State management rules: guidance on when to use @State, @Binding, @Observable, @Bindable, @FocusState, @AppStorage and where state should live to avoid stale updates and unnecessary view recomputation.
  • View composition & identity: prescriptions to prefer struct views over free functions, extract subviews, avoid closure properties on view structs, and avoid identity-breaking modifier branches.
  • Selection and Picker safety: rules to always render matching tags, clamp selections before render, and provide regression test recommendations to prevent invalid selection warnings.
  • Button styling and accessibility: enforced use of native glass styles, prohibition of .plain, and requirement that custom behaviors conform to ButtonStyle.
  • Drag-and-drop best practices: unconditional .draggable installation, explicit drop rejection feedback, exhaustive DragSession.Phase handling, single-phase drag state, and macOS-only API guidance.
  • Navigation, lists, animation, layout, keyboard, window, and commands: targeted recommendations for NavigationStack, List usage, explicit animations, layout primitives, focus management, and macOS window/command patterns.
  • Anti-patterns and tests: lists of forbidden patterns (AnyView, work in initializers, index-based ForEach) and expectations for regression and store-level tests.

Quick Start

Ask the assistant to review a SwiftUI view file in apps/harness-monitor-macos/Sources and list any violations of the Harness Monitor SwiftUI API patterns, explaining why each issue breaks identity, state, or UX and suggesting a fix.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: swiftui-api-patterns
Download link: https://github.com/smykla-skalski/harness/archive/main.zip#swiftui-api-patterns

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.