/duology-ship:duo-performancefrom duology-ship
Diagnoses and fixes performance issues in iPhone Duo apps when the device folds or unfolds. Measures main-thread costs per fold using Instruments and os_signpost, identifies causes like redundant body evaluations, and provides fixes to prevent stutter and frame drops.
Ships in duology-ship. 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; scripts run unread.
Make opening and closing iPhone Duo cheap for your app, prove it with numbers, and keep it that way.
Load other skills for the work around it: duo-transitions (the motion itself, the 120 Hz frame budget, CADisplayLink, the hinge stream), duo-layout and duo-continuity (one layout that changes shape, state that survives the fold), duo-pose-matrix (duo-pose, which this skill's script uses), duo-testing (launch switches and sample data).
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1) on 6 November 2026; details in references/evidence.md. Unverified means we could not confirm it. Nothing here has run on a real iPhone Duo; references/device-checks.md lists what to check there.
Several resizes, not one. While the window grows from 466 to 951 pt (duo-transitions), a full-width view went through three widths in about 100 ms (measured): 382 → 466 → 951 → 867 pt, as the safe area insets changed. UIKit updates the scene metrics (Window / UpdateSceneMetrics signposts, three in that open), and SwiftUI reruns body for every view that reads the size, lays out again and commits a frame. Closing changed that view's width once, to 382 pt.
The budget. Both displays run up to 120 Hz; a frame lasts 8.3 ms (Understanding hitches). While the main thread runs without going back to its run loop, the app can't commit a new frame; only animations already handed to the render server keep moving.
What an app pays (measured, Release builds, median of 3 folds):
| App | Open: longest stretch / busy | Close: longest / busy |
|---|---|---|
| A grid of 3,000 cells, work done once | 29 ms / 71 ms | 14 ms / 45 ms |
The same, with a sort and a date formatter in body | 486 ms / 517 ms | 137 ms / 154 ms |
Ledger eval fixture: 2,000 rows, all the mistakes below | 2,913 ms / 4,370 ms | 1,645 ms / 1,683 ms |
Ledger fixed by hand with the steps below | 86 ms / 115 ms | 15 ms / 45 ms |
The first fold after launch costs the most (measured: 71 and 43 ms longest on the fast grid, then 15 to 30 ms; 269 ms on the fixed Ledger, then 86 and 14 ms). Caches, first layouts of the wide variant and first appearances happen then.
These are simulator numbers: it runs on the Mac's CPU and draws at 60 Hz (maximumFramesPerSecond = 60, measured in Duology's device facts). Use them to compare and to find causes. They are not device timings.
body only describes views. No sorting, filtering, grouping, summing, formatter creation, date or number formatting of many items, image decoding or I/O in it. Do that once, when the data changes.GeometryReader per row.AnyLayout, a custom Layout), never an if that builds the same content twice, never .id(size).List, LazyVStack, LazyVGrid.scripts/duo-fold-cost folds the phone with duo-pose while Instruments records the app's main thread, then reports each fold. The app needs no changes.
Needs: Xcode 27.1, the iPhone Duo simulator booted and shown in Device Hub, the app installed, and duo-pose status saying "Ready" (it presses Device Hub's pose buttons through the Accessibility permission; see duo-pose-matrix). It uses an existing simulator and never creates one.
DD=/tmp/myapp-dd; UDID=<the iPhone Duo UDID>
DEVELOPER_DIR=/Applications/Xcode-27.1.app/Contents/Developer xcodebuild -project MyApp.xcodeproj \
-scheme MyApp -configuration Release -destination "id=$UDID" -derivedDataPath "$DD" build
xcrun simctl install "$UDID" "$DD/Build/Products/Release-iphonesimulator/MyApp.app"
scripts/duo-fold-cost run com.example.myapp --save before.json
Fold (median) longest busy >8.3ms stalls hangs
closed -> open 2913 ms 4370 ms 3 3 2 (3 runs)
open -> closed 1645 ms 1683 ms 3 3 1 (3 runs)
| Column | What it is |
|---|---|
| longest | The longest time the main thread ran without going back to its run loop: the app can't commit a frame before it ends. Watch this one first. |
| busy | The main thread's total running time during the fold. |
| >8.3ms | Stretches longer than one 120 Hz frame. |
| stalls | UIKit's own count of update cycles that stalled (UpdateCycle.Stalls). |
| hangs | What Instruments' Hangs instrument reported (its threshold: 100 ms). |
--poses open,book,tabletop,closed, the count with --cycles 5, and pass launch arguments after -- (-- -sampleData). Launch the app on the screen you want to measure (duo-testing, launch switches).scripts/duo-fold-cost run com.example.myapp --compare before.json. It prints what got slower or faster, and exits 1 when a median grew by at least 25 % and 20 ms.--time-profiler adds the Time Profiler instrument and names the code the main thread was in during each fold's longest stretch (measured on the slow grid: closure #1 in slowSorted(_:) 79 %). It keeps the trace for Instruments.How it works, every column and exit code, and recording a trace by hand: references/measure.md.
--time-profiler. Mostly your code in the longest stretch: move that work out of body. Mostly "(system)": SwiftUI and UIKit are laying out or rebuilding too many views (measured on Ledger: 81 to 83 % system, the rest in EntryRow.body). For more, open the trace in Instruments at the fold's time.body runs on a fold: add let _ = Self._printChanges() as its first line for a run, fold, and read the console (WWDC23 Demystify SwiftUI performance). Remove it after.OSSignposter interval: it shows next to the fold in the os_signpost instrument.body properties: each fold runs them several times.On the simulator, Instruments' SwiftUI template doesn't record (measured: "Hitches is not supported on this platform."), the SwiftUI instrument added to a recording gets no data, and XCTHitchMetric returns no values. Use them on a device.
| What the trace shows | Cause | Fix |
|---|---|---|
One long stretch per resize step, in your body | Sorting, grouping, summing or formatting in body | Do it once in a model when the data changes; body reads finished values |
| Long stretches in layout, many rows | A non-lazy stack of every row | List, LazyVStack or LazyVGrid |
| Rows re-laid out at every step | A GeometryReader in each row | Read the size once, high up; pass a value |
| The whole screen rebuilt, scroll and selection lost | if wide { … } else { … } building the same views twice, or .id(width) | AnyLayout or a custom Layout; no .id tied to the size |
| The same action runs several times per fold | onGeometryChange returning the raw size | Return the small value the layout needs: it runs only when that changes |
| Work right after the fold | A reload or prefetch on each resize step | .task(id:) on the small value, with a short wait, off the main thread |
| Images decode again at each size (unverified on Duo) | Decoding at the view's current size | Decode once, sized for the largest display, off the main thread |
Code for each fix, all typechecked: references/fixes.md.
--save main.json on the main branch) and run --compare main.json before merging work that touches a screen people fold on. Numbers from different Macs don't compare.body in plain functions or a model, and test them on the Mac with XCTClockMetric or a logic test (duo-testing). They are where a regression comes back.duo-fold-cost before each release, next to /duo-ship.MetricKit can split its daily report by a state the app reports, with the StateReporting framework (MetricManager, StateReporter). State entries carry hang time, hitch time, terminations and signpost intervals (MetricReport). Report the pose, and you get hitches and hangs per pose from real phones.
closed, open, book or tabletop from the fold geometry, once the pose has held for half a second: one fold passes through several sizes, and Apple warns that reporting faster than "user interaction timescales" can be rate-limited.mxSignpostAnimationIntervalBegin, so the report counts hitches during folds.The code, which also builds for iOS 26 and does nothing there: references/field.md.
The simulator can't tell you whether folds are smooth at 120 Hz. On an iPhone Duo, profile Open and Close with the Animation Hitches template, run your UI tests with XCTHitchMetric, and watch the Hitches metric in Xcode Organizer. The list, with what we expect and what would change this skill: references/device-checks.md.
duo-fold-cost run from before the change, and a --compare after itbodyif that builds the same content twice; no .id tied to the sizeList, LazyVStack or LazyVGrid.task(id:) after the fold settles, off the main threadreferences/device-checks.md (opens in a new tab)references/evidence.md (opens in a new tab)references/field.md (opens in a new tab)references/fixes.md (opens in a new tab)references/measure.md (opens in a new tab)scripts/duo-fold-cost (opens in a new tab)scripts/duo_fold_cost.py (opens in a new tab)tests/test_duo_fold_cost.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kimeur/duology --plugin duology-ship6 skills in this plugin
/duo-app-storePrepares an app's App Store submission for iPhone Duo, Apple's foldable with a 1398 x 2034 outer display and a 2007 x 2853 inner display: App Store screenshots of both displays at the exact sizes App Store Connect lists, flattened without alpha, captured from the iPhone Duo simulator in each pose with a clean status bar; app previews (886 x 1920); uploading them in App Store Connect or with the App Store Connect API (screenshot display type APP_IPHONE_DUO, not in Apple's API reference yet); the 'optimized for iPhone Duo' product page badge; promotional text and the App Store Connect preview tool; App Review notes for the poses; the privacy manifest; and the April 2027 rules (Duo screenshots required, iOS 27 SDK or later, iOS 15 or later). Use when someone asks for Duo screenshots, store assets, a submission checklist or review notes for iPhone Duo./duo-lintThe fold linter for iPhone Duo, Apple's foldable with an outer display and an inner display. Run it to find code Apple says to remove before an app runs on the foldable; it reports each finding with the fix for its rule. Catches UIScreen.main and UIScreen.screens, UIDevice.current.orientation, statusBarOrientation, the deprecated interfaceOrientation properties and effectiveGeometry.interfaceOrientation, userInterfaceIdiom == .pad, horizontalSizeClass == .regular treated as iPad, hard-coded screen sizes (bounds.height == 844), GeometryReader sizes matched to devices, .frame(width: 390) and fixed width constraints, and UIRequiresFullScreen. Use it before a review or release, in CI (GitHub annotations), after editing SwiftUI or UIKit layout code, or when a screen breaks when the phone folds, unfolds or resizes. It reads code only; for a full iPhone Duo audit that also checks screenshots, use /duo-audit or the duo-design-review checklist./duo-migrateMoves an existing iOS app that already ships onto iPhone Duo, Apple's foldable, step by step: from an app built with Xcode 26 (iOS 26 SDK) or Xcode 27.0 to a build with Xcode 27.1 and the iOS 27.1 SDK. Use when an app shows up centred with empty space around it on the open iPhone Duo, when a UIKit app built with the new SDK crashes at launch because it has no scene life cycle (no UIApplicationSceneManifest, no configurationForConnecting, UIWindow(frame:) in didFinishLaunching), when replacing UIScreen.main, device orientation, userInterfaceIdiom, regular width treated as iPad, hard-coded device sizes or UIRequiresFullScreen, when toolbars and tab bars turn vertical after the rebuild, when moving CI off an older Xcode, or when planning for the April 2027 App Store rules (iOS 27 SDK or later, iOS 15 or later)./duo-pose-matrixScreenshots an iPhone Duo app in every pose (closed, open, book, tabletop) on the iPhone Duo simulator by pressing Device Hub's pose buttons through the macOS Accessibility API, then writes summary.md and summary.json to review with the duo-design-review checklist. Use when asked to check, test or screenshot an app in each pose, fold or hinge state, to capture outer and inner display frames for a design review or the App Store, to change the simulator's pose from the command line or a script (simctl and devicectl have no pose command), to run /duo-poses, or when a review is missing book or tabletop frames. Ships duo-pose (status, list, set) and duo-pose-matrix, with a manual fallback when the user has not given Accessibility permission, and checks that no UI tests share the simulator before it changes the pose./duo-testingWrites and runs tests for iPhone Duo apps, Apple's foldable with an outer display and an inner display, on the Mac and on the iPhone Duo simulator in Xcode 27.1. Use when adding logic tests (swiftc script, or Swift Testing with @Test and #expect), UI tests with XCTest and XCUIAutomation, launch arguments such as -uiTesting, -resetState and jump-to-screen switches with a TestSupport type, test markers with accessibilityIdentifier and accessibilityValue, when a tap or drag in a UI test doesn't reach a SwiftUI gesture (coordinate(withNormalizedOffset:), press(forDuration:thenDragTo:)), when XCUIDevice rotation or a fold can't be scripted, or when running xcodebuild test on the existing iPhone Duo simulator with -destination id=<UDID>, -parallel-testing-enabled NO, -only-testing, -resultBundlePath, -collect-test-diagnostics and xcresulttool.Other plugins' skills for the same job