Back to Skills

focus-engine

Implements keyboard, directional, and scene-level focus behavior across SwiftUI and UIKit. Use when managing @FocusState, defaultFocus, focused values, focusable interactions, focus sections, tvOS geometric focus and Siri Remote navigation, watchOS Digital Crown input, visionOS connected-device focus versus gaze hover/input targets, macOS key view loop and Full Keyboard Access, focus restoration after presentation changes, custom focus routing with UIFocusGuide, or debugging focus with UIFocusDe

961stars48forksUpdated 8/4/2026

Security Assessment

Safe(97/100)
Security Score97/100

About focus-engine

This skill is a reference and implementation guide for focus behavior in SwiftUI and UIKit apps across Apple platforms (iOS 26+, iPadOS, macOS, tvOS, and visionOS connected-input paths). It addresses the tricky, platform-specific work of managing keyboard, directional, remote, game-controller, and scene-level focus, including @FocusState, defaultFocus, focused values, focusable interactions, focus sections, focus restoration after presentation changes, and custom routing with UIFocusGuide. It also draws an explicit boundary: gaze-driven hover on visionOS is treated as an input affordance rather than focus, and VoiceOver/Switch Control accessibility focus is handed off to a separate accessibility skill.

The skill supplies concrete SwiftUI and UIKit patterns, such as using an optional Hashable enum with @FocusState to move focus between fields, exposing focused scene values to command menus and toolbars, and building focusable custom controls that prefer semantic controls like Button before adding .focusable. It documents platform availability details (for example focusSection on macOS 13+ and tvOS 15+) and includes reference files for focus patterns, multi-platform focus, and debugging focus (including UIFocusDebugger), plus an evals file for validating the guidance.

It is aimed at Swift/iOS developers building multi-platform apps that must handle keyboard, remote, and directional navigation correctly, especially for tvOS geometric focus, watchOS Digital Crown input, and macOS Full Keyboard Access. It is documentation and code guidance with no execution or system side effects.

FAQ

Which platforms does the focus engine cover?

SwiftUI and UIKit apps on iOS 26+, iPadOS, macOS, tvOS, and visionOS connected-input paths, including keyboard, remote, game-controller, and scene focus.

How does it handle visionOS gaze and accessibility focus?

It treats visionOS gaze-driven hover as an input affordance, not focus, and hands off VoiceOver/Switch Control accessibility focus to a separate ios-accessibility skill.

How should I move focus between fields in SwiftUI?

Use @FocusState with a Bool for a single target or an optional Hashable enum for multiple targets, binding fields with .focused($focusedField, equals:).

When should I use .focusable on a custom view?

Prefer semantic controls like Button first; add .focusable(interactions:) only when a custom control genuinely needs explicit focus participation.

What reference material is included?

Reference files for focus patterns, multi-platform focus, and focus debugging (including UIFocusDebugger), plus an evals file.

All Files

5 files
references/focus-debugging.md3.2 KB
View
references/focus-patterns.md5.9 KB
View
SKILL.md9.5 KB
View
evals/evals.json3.9 KB
View
references/multi-platform-focus.md5.6 KB
View

Install focus-engine

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill