ShopifyThiago MagalhaesExplainer
Reflex: an architecture for building mobile apps with agents (2026) - Shopify
Summary
Shopify’s Reflex architecture enables mobile app development where agents write most of the code. It separates core logic from UI into a headless module that runs on macOS or JVM without a simulator, using four pillars: a core module with no UI imports, a strict ViewModel contract, ViewModel introspection via JSON, and a platform-agnostic CLI. Agents explore and test the app via commands like ls and do without rendering any UI, achieving feedback loops where a test case runs in a couple hundred milliseconds without a device. The same test file runs against both iOS and Android, enforcing parity without shared code; 1,700+ behavior tests finish in about four minutes on CI. Reflex uses grey box testing where tests see ViewModel state and actions but not internals or pixels, with fixtures swapped at network and device boundaries.
Context
Shopify rebuilt their mobile apps natively in Swift and Kotlin and needed an architecture that allowed AI agents to write code efficiently with fast feedback loops. They developed Reflex to enable headless execution and cross-platform test parity.
Approach / What changed
Reflex is an MVVM-based architecture with four pillars: a core module with no UI imports, a strict ViewModel contract (Elm-style: actions in, state out), ViewModel introspection via JSON contract, and a platform-agnostic CLI. The app’s logic runs headlessly on macOS or JVM, and the CLI drives the ViewModel contract without a simulator. Tests are grey box, sharing one test file across platforms, with fixtures for network and device boundaries.
Takeaways
Reflex separates core logic from UI into a headless module that runs on macOS or JVM, enabling fast feedback loops without a simulator.
The same test file runs against both iOS and Android, enforcing parity without shared code; 1,700+ behavior tests finish in about four minutes on CI.
Agents interact with the app via a CLI using commands like ls and do, reading ViewModel state and actions as JSON, without rendering any UI.
FAQ
How valuable are these tests if you're not testing the UI?
Most bugs are in the logic, not the UI wiring. These tests cover that logic. UI verification happens through visual review at Helix checkpoints and screenshot tests for pixel-critical components, plus daily organic testing by the team.
Why not unit tests plus UI tests with XCUITest and Espresso?
Unit tests and native UI tests are written once per platform and say nothing about parity. They also don't give an agent a way to explore the app outside a pre-written test, which Reflex's CLI provides for debugging and feature building.
What about Appium or agent-driven device automation?
Reflex offers a grey box interface where agents read state directly instead of inferring from accessibility trees or screenshots, saving round trips. More importantly, headless execution lets thousands of tests finish in minutes on CI, whereas end-to-end tests at that scale would take hours.
Source and freshness
- Source
- shopify.engineering
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.