# focus-engine

An AI-coding skill for focus handling in SwiftUI and UIKit: keyboard and directional movement, scene values, restoration after presentation changes. Useful when Siri Remote or Tab navigation lands on the wrong control.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2600 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/focus-engine/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/focus-engine

## What it does

The skill covers focus in SwiftUI and UIKit apps built for iOS 26+, iPadOS, macOS, tvOS and visionOS with connected input. It walks through `@FocusState`, `.defaultFocus`, focused values and scene values, plus `.focusable(_:interactions:)`. Each topic comes with code and a list of common mistakes, and there is a review checklist at the end.

Dedicated parts deal with getting focus back after a sheet, popover or overlay closes, and with `UIFocusGuide` in UIKit when the layout has gaps and arrows travel off course. tvOS gets geometric focus and Siri Remote navigation, watchOS gets Digital Crown input, macOS gets the key view loop and Full Keyboard Access. Note that `focusSection()` targets macOS 13+ and tvOS 15+, so older deployment targets matter here.

The boundaries are spelled out. On visionOS, gaze and pointer targeting count as input affordances rather than focus. VoiceOver, Switch Control and accessibility element ordering belong to the `ios-accessibility` skill. Without that split a prompt easily sends the agent down the wrong path, so decide first which kind of focus you actually need.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill focus-engine -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/focus-engine/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/focus-engine/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill focus-engine -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/focus-engine/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill focus-engine -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/focus-engine/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills focus-engine
```

2. **Manually: put the files in place**
- File: `.github/skills/focus-engine/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill focus-engine -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/focus-engine
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/focus-engine/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill focus-engine -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/focus-engine/SKILL.md

## When to use it
- move focus to the next field after submit
- fix arrow-key traversal on tvOS
- bring focus back to a trigger button after a sheet closes
- route focus across empty space in a UIKit layout
- debug a focus chain with `UIFocusDebugger`

## Example prompts
- After the form submits, focus should jump from email to password — build it with `@FocusState`.
- On tvOS the down arrow skips the middle column; wrap each group in `focusSection()`.
- Focus disappears when the sheet closes — put it back on the button that opened it.

## Similar
- [vercel-react-native-skills](https://affpapa.org/en/nevibecode/skills/vercel-react-native-skills.md) — skill · 255200 installs
- [animate-expo](https://affpapa.org/en/nevibecode/skills/animate-expo.md) — skill · 137900 installs
- [mobile-native](https://affpapa.org/en/nevibecode/skills/mobile-native.md) — skill · 86600 installs
- [aso](https://affpapa.org/en/nevibecode/skills/aso.md) — skill · 75400 installs
- [swiftui-pro](https://affpapa.org/en/nevibecode/skills/swiftui-pro.md) — skill · 35200 installs
- [orca-emulator](https://affpapa.org/en/nevibecode/skills/orca-emulator.md) — skill · 5800 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
