/duology-features:duo-gamesfrom duology-features
Builds SpriteKit, Metal, or SwiftUI games for iPhone Duo that survive folds, fill every pose without letterboxing, keep touch controls off the fold, and support tabletop mode with controls below the display. Use when a game restarts, letterboxes, or loses input on fold/unfold.
Ships in duology-features. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A game on iPhone Duo resizes every time someone opens, closes, rotates or folds the phone, often in the middle of play. This skill keeps the game running through all of it, fills every pose, keeps thumbs off the fold, and turns the bottom half into a controller when the phone sits on a table.
Load neighbours when the task needs them: duo-shared-screen and recipe-two-player-game (two people on one phone), duo-postures (every pose, and hinge effects), duo-layout (reserved regions in depth), duo-continuity (state through a fold), duo-ergonomics (thumb reach).
"Book" and "tabletop" are Duology's words for Apple's "partially folded, like a book" and "seated on a table like a laptop". No API reports them. Labels: measured means we ran it in a probe app on the iPhone Duo simulator (Xcode 27.1, iOS 27.1, 20 Oct 2026); logs in references/measurements.md. Unverified means we could not confirm it. Everything else links to Apple.
.division frame, margins included, belongs to neither, flat or folded (talk 111466).isPaused: SpriteView(isPaused:) didn't resume the game (measured).duo-postures).Measured with the code below: the world ignores the safe area, the controls stay inside it.
| Pose | Window | Scene (world) | Touch controls | .division seen by the controls |
|---|---|---|---|---|
| Closed | 466 × 678 pt | 466 × 678 pt | 382 × 644 pt (84 pt trailing and 34 pt bottom inset) | none |
| Open, flat, held wide | 951 × 669 pt | 951 × 669 pt | 951 × 635 pt | inactive, 40 × 669 pt at x = 455.5 |
| Book | 951 × 669 pt | 951 × 669 pt | 951 × 635 pt | active, same frame |
| Tabletop | 669 × 951 pt | 669 × 455.7 pt, above the fold | 669 × 421.5 pt, below the fold | none: the fold lies outside the controls |
duo-reading). Split at the fold frame, never at width / 2..resizeFill makes the scene exactly the size of its view (resizeFill). A camera then scales so the play area always fits; spare room shows more world. Every pose we measured is less wide than the 16:10 play area below, so it fills the width and the spare room shows above and below it: a lot on the closed phone held upright, little in book and tabletop (derived from the measured sizes).
import SpriteKit
/// What the touch controls and a game controller write, and the scene reads every frame.
@MainActor
final class GameInput {
var move = CGVector.zero // -1...1 on each axis
var isFiring = false
}
/// The game world. `.resizeFill` makes the scene exactly the size of its view, so a
/// fold, a rotation or Split View changes the aspect ratio instead of letterboxing.
/// The camera keeps the whole play area in view; spare room shows more world.
final class ArenaScene: SKScene {
/// The part of the world every size must show, in world points.
let playArea = CGSize(width: 640, height: 400)
let input: GameInput
private let eye = SKCameraNode()
init(input: GameInput) {
self.input = input
super.init(size: playArea)
scaleMode = .resizeFill
}
required init?(coder: NSCoder) { nil }
override func didMove(to view: SKView) {
guard camera == nil else { return } // can run again; build the world once
addChild(eye)
camera = eye
// Add the world's nodes here, around (0, 0).
}
/// Runs on every fold, unfold, rotation and Split View change. Never rebuild the world here.
override func didChangeSize(_ oldSize: CGSize) {
super.didChangeSize(oldSize)
guard size.width > 0, size.height > 0 else { return }
// Scale so the play area fits on both axes. Never crop it.
eye.setScale(max(playArea.width / size.width, playArea.height / size.height))
}
override func update(_ currentTime: TimeInterval) {
// Read `input` here: it keeps its values through a resize.
}
}
didChangeSize(_:) cheap and safe to repeat. Measured: it ran twice for every size change, and once with a passing size (466 × 455.7 pt) when the phone closed from tabletop.Create the session once per window, above every layout switch. The same SpriteView and scene stay on screen in every pose; only their size changes.
import Observation
import SpriteKit
import SwiftUI
// requires: FoldGeometry (references/fold-geometry.md)
// requires: GameInput, ArenaScene (SKILL.md)
// requires: GameLayout (references/tabletop-controller.md), TouchControls (references/touch-controls.md)
// requires: ControllerAware (references/controllers.md)
/// One game per window. Create it in the window's root view, above every layout
/// switch, so a fold never makes a new scene.
@MainActor @Observable
final class GameSession {
let input = GameInput()
let scene: ArenaScene
var isPaused = false
init() { scene = ArenaScene(input: input) }
}
@available(iOS 27.1, *)
struct GameScreen: View {
let session: GameSession
@State private var fold = FoldGeometry()
@Environment(\.scenePhase) private var phase
var body: some View {
GameLayout(fold: fold) {
// The same SpriteView and scene in every pose: only its size changes.
SpriteView(scene: session.scene, preferredFramesPerSecond: 120)
.ignoresSafeArea()
ControllerAware(input: session.input) {
TouchControls(input: session.input) // hidden while a controller is in use
}
}
.onFoldChange { fold = $0 }
// Pause the scene itself. SpriteView's isPaused argument paused the scene
// but didn't resume it when it turned false again (measured).
.onChange(of: session.isPaused || phase != .active, initial: true) { _, paused in
session.scene.isPaused = paused
}
.background(.black)
.toolbarVisibility(.hidden, for: .statusBar)
.persistentSystemOverlays(.hidden)
}
}
didMove(to:) ran once, and the frame counter kept counting through every change.scenePhase leaves .active. Opening or closing the phone kept the app active (measured: frames kept counting), so a fold never pauses the game.SpriteView. Measured: with SpriteView(isPaused:) bound to the phase, a game launched while the app was still inactive stayed frozen once it became active (0 frames in 4 s), and so did a pause button turned off again: the argument set the scene's isPaused but didn't clear it. Setting scene.isPaused in onChange ran in every case, and again after a trip to the Home Screen..ignoresSafeArea() on the world only. Controls, score and menus stay in the safe area, clear of the outer camera and the Home indicator (HIG: Game controls).persistentSystemOverlays(.hidden) and toolbarVisibility(.hidden, for: .statusBar) during play only. Show them again on menus (persistentSystemOverlays(_:), toolbarVisibility(_:for:)). The .statusBar placement is new in iOS 27.0; the iOS 27.1 SDK marks statusBarHidden(_:) to be deprecated in its favour. Deploying below iOS 27 (the recipes target iOS 26.0), .statusBar doesn't build without a check (measured), so keep the old call for older versions:import SwiftUI
extension View {
/// Hides the status bar: the `.statusBar` placement on iOS 27, statusBarHidden() before.
@ViewBuilder func playStatusBarHidden() -> some View {
if #available(iOS 27.0, *) {
toolbarVisibility(.hidden, for: .statusBar)
} else {
statusBarHidden()
}
}
}
Movement goes on the leading side and actions on the trailing side, as players expect (HIG: Game controls). On the inner display held wide, that line is the fold. TouchZones puts the fold's whole frame between the zones, flat or folded, so folding moves nothing.
import SwiftUI
// requires: FoldGeometry (references/fold-geometry.md)
/// Movement on the leading side of the fold, actions on the trailing side.
/// Without a top-to-bottom fold the line is the middle. The fold's frame, margins
/// included, belongs to neither zone, flat or folded, so folding moves nothing.
@available(iOS 27.1, *)
nonisolated struct TouchZones: Equatable, Sendable {
var move: CGRect
var act: CGRect
init(size: CGSize, fold: FoldGeometry) {
let gap = fold.isVertical ? fold.frame : nil
let lead = gap?.minX ?? size.width / 2
let trail = gap?.maxX ?? size.width / 2
move = CGRect(x: 0, y: 0, width: lead, height: size.height)
act = CGRect(x: trail, y: 0, width: size.width - trail, height: size.height)
}
}
ReservedRegion).TouchControls (stick and fire button) and PressButton, plus Apple's GCVirtualController and Touch Controller on iPhone Duo: references/touch-controls.md.
Propped on a table, the phone becomes a small console: the world in the top region, every control in the bottom region. In every other pose the controls lie over the world. One Layout does both, so neither view is rebuilt (talk 111463).
GCVirtualController over a full-window scene).duo-postures). It is inactive unless your game runs it. Keep the fire button clear of it anyway.GameLayout and its variants: references/tabletop-controller.md.
MTKView resizes its drawable with the view by default (autoResizeDrawable). Rebuild the projection in mtkView(_:drawableSizeWillChange:). Keep the device, queue, pipelines and game state.UIWindowScene.displayLink(target:selector:) (iOS 27). Apple's doc says it follows the scene when the scene moves to another display, as it does when the phone opens or closes (doc). UIScreen's display link is deprecated in iOS 27.Code for MTKView, a CAMetalLayer view controller and Touch Controller: references/scene-and-renderer.md.
ControllerAware shows the touch controls until the player uses a controller, then hides them, and brings them back on the next touch. Code: references/controllers.md.
GCVirtualController drew its stick bottom left and its buttons bottom right in book, clear of the fold. In tabletop its buttons sat below the fold. It doesn't know about the fold; check it in every pose.TCTouchController.isSupported was false on the simulator. Test Apple's Touch Controller on a device.The outer display honours your supported orientations; the inner display doesn't (talk 111461). Apple lets games lock to portrait or landscape, as long as they fill the screen as the pose changes (HIG: iPhone Duo).
GameLayout above already do.UIDevice.orientation or the interface orientation to choose a layout. Use the view's size.What a landscape-only build got in each pose: references/measurements.md.
Use the two-player frame, not this skill's controls:
recipe-two-player-game creates a new project: one half per player in every pose, an engine tested on the Mac, and UI tests for the Duo simulator.duo-shared-screen adds the same to an existing game: SharedSplit, face-to-face seating, input gated per seat.ArrangementView: closed and held sideways it shows only its first view (measured in duo-layout).playerIndex, and keep touch for both. references/controllers.md.preferredFramesPerSecond), and add CADisableMinimumFrameDurationOnPhone to Info.plist, or iPhone stays at 60 (ProMotion guide). The simulator ran at 60 (measured: 300 frames every 5 s). Check 120 Hz on a device.defersSystemGestures(on:) during play, so a swipe that starts at that edge reaches the game before the system (doc).In Device Hub, under the bezel: Closed, Open, Partially Open, and Rotate Right for tabletop (Device Hub).
xcrun simctl io <UDID> screenshot --display=primary outer.png (closed) and --display=primary-1 inner.png (open)..resizeFill (or the renderer follows the drawable size); nothing letterboxes without artwork..division frame read with .includeInactive; no control inside it, flat or folded.scenePhase by setting the scene's isPaused, never on a fold.recipe-two-player-game or duo-shared-screen, not ArrangementView.@available or if #available when the game deploys lower.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
iphone-duo, foldable-games, spritekit, metal, swiftui, game-controller
8 skills in this plugin
/duo-app-intentsApp Intents on iPhone Duo: AppIntent, AppEntity with EntityStringQuery, OpenIntent with TargetContentProvidingIntent and onAppIntentExecution (UISceneAppIntent and AppIntentSceneDelegate in UIKit) to show the right item in the right pane or window, handlesExternalEvents to pick the window, intents that work with the phone closed (supportedModes .background, IntentDialog, ProvidesDialog, isVoiceOnly), onscreen awareness when two panes are visible (appEntityIdentifier, appEntityIdentifier(forSelectionType:), NSUserActivity), App Shortcuts (AppShortcutsProvider) and AppIntentsTesting runs on the Duo simulator in each pose. Use when an app adds Siri, Shortcuts, Spotlight or Apple Intelligence actions, when an intent opens the wrong pane or an extra window, or when an intent must work while the phone is closed./duo-cameraCamera capture on iPhone Duo, Apple's foldable. Use when an app takes photos or video, runs a video call or shows a camera preview, and must work closed (outer display), open (inner display), partly folded (book, tabletop), open and turned around (flipped) and through fold and unfold. Covers the virtual front camera (.builtInWideAngleCamera or .builtInUltraWideCamera at .front; shared features only, up to 1080p at 60 fps, no depth), the physical front cameras (.builtInOuterUltraWideCamera, .builtInInnerUltraWideCamera), choosing a camera by the way it faces with AVCaptureDeviceDirectionCoordinator (AVKit) and AVCaptureDeviceDescriptor, mirroring a rear-camera selfie, AVCaptureDevice.RotationCoordinator across displays, the square front sensor and dynamicAspectRatio, a subject preview on the outer display with CameraCaptureAccessory, tabletop hands-free capture, and Split View interruptions. The simulator has no camera: the code typechecks; capture is unverified on a device./duo-intelligenceAdds Foundation Models to an iPhone Duo app: the on-device model (SystemLanguageModel) and the Private Cloud Compute server model (PrivateCloudComputeLanguageModel) behind one LanguageModelSession API, an AI side pane beside the content when the phone is open or in book pose (split ArrangementView) and a one-line summary when it is closed or in tabletop, streaming (streamResponse with @Generable partial snapshots) into a pane that keeps going through fold and unfold, availability checks and non-AI fallbacks, quota and error handling (LanguageModelError), tool calling, image prompts (Attachment), reasoning levels (ContextOptions) and privacy. Use when someone adds summaries, an assistant, chat, tagging or image understanding to an app that runs on iPhone Duo, or when an AI feature restarts on a fold, sits in the fold or doesn't fit the outer display./duo-mediaVideo and audio playback on iPhone Duo, Apple's foldable. Use when an app plays video or audio and must keep playing through fold, unfold and rotation, when you build a tabletop player (video above the fold, the same controls below) or a book-pose player, an up next queue, Picture in Picture, Now Playing or background audio. Covers one AVPlayer owned above the layout switch (VideoPlayer, AVPlayerViewController, AVPlayerLayer), ArrangementView with .overlay and overlayArrangementZIndex for up next (measured on the simulator in every pose), when to pick .split instead, toolbarVerticalBehavior(.disabled) for a full-screen player, AVPictureInPictureController and canStartPictureInPictureAutomaticallyFromInline, the pinned Picture in Picture video that takes half the screen when folded, MPNowPlayingSession and remote commands, the .playback audio session, and what to test in Device Hub and on a device./duo-readingBuilds reading and document screens for iPhone Duo, Apple's foldable: one page on the closed outer display, two facing pages split at the fold when the phone is open and held wide or folded like a book, and in tabletop the page above the fold with page turns below it. Use when you build an e-reader, a long-form or PDF viewer, notes beside a document, or when a reader loses its place on fold, unfold, rotation or a Dynamic Type change. Covers TextKit 1 pagination (NSLayoutManager, NSTextContainer) that keeps the place as a character offset, PagedReader with FoldGeometry and reservedRegions(kind: .division, options: .includeInactive), notes that move between the trailing region and a sheet, Dynamic Type reflow, text selection that stays inside one page (iOS 27 Text range selection, a UITextView edit menu Add to Notes action, drag), PDFKit two-up centred on the fold, and Apple Pencil, which Apple says comes later in 2026 (what it will support is unverified)./duo-swiftui-27The iOS 27 SwiftUI changes that matter on iPhone Duo, Apple's foldable, where every fold, unfold and rotation resizes the app. Use it when building with Xcode 27.1 breaks a view (@State macro, ContentBuilder, TN3211), when a grid or list that reflows between the outer and inner display needs drag to reorder or swipe actions, or when you adopt the new tab, toolbar, dialog or AsyncImage APIs in a Duo app. Covers the @State macro through a fold and its source breaks, reorderable() and reorderContainer(for:isEnabled:move:) in a 2 or 4 column grid and across the fold, swipeActionsContainer() outside List, Tab(role: .prominent) at the foot of the vertical tab bar, toolbarMinimizationBehavior(_:for:) (the talk's toolbarMinimizeBehavior is not in the SDK), visibilityPriority, ToolbarOverflowMenu, topBarPinnedTrailing, alert and confirmationDialog with item:, AsyncImage HTTP caching and asyncImageURLSession(_:), and resizable iPhone apps. Points to Apple's swiftui-whats-new-27 Xcode skill for the rest.npx claudepluginhub kimeur/duology --plugin duology-featuresOther plugins' skills for the same job