Vibeleaderboard
← All Intel
Intel / article

Reflex

Source
shopify.engineering
Author
Shopify Engineering
Date

Context

Shopify is rebuilding its mobile apps in native Swift and Kotlin with agents writing most of the code, and its engineering team found that the slow part was not writing a screen but proving it worked, which took an emulator, a build, a tap script and a lot of waiting. Reflex is the architecture it built to remove that step. The app's logic runs without any interface, every screen exposes its state and the actions it accepts through one small contract, and a command-line tool drives that contract on iOS and Android from the same test file.

The split starts with a Core module that holds everything except the views (screen logic, services, navigation, the GraphQL client, persistence) and imports nothing from the phone's UI frameworks, so it builds and runs on a Mac or a plain Java virtual machine. Each screen's ViewModel, the object that holds what the screen shows, follows the same strict shape: actions come in, state goes out, and one function is the only place state changes. A small extension describes each ViewModel as a node with a name, its state as JSON and its list of actions. The CLI's ls command prints the current screen's node, and do invokes one of its actions exactly as a user tap would. Because moving to a new screen is also just a state change, the CLI can walk the entire app without a single view being created.

Shopify's rule for keeping two codebases equivalent is to share the test, not the code. No code is shared between the Swift and Kotlin apps, but every behavior test runs against both, and a pull request cannot merge if it passes on only one. The tests see what the interface would see, with real reducers, services, GraphQL client and navigation underneath, and fixtures swapped in wherever the app would reach the network or the device; a guard fails any test that attempts an HTTP request. Shopify reports that its more than 1,700 behavior tests finish in about four minutes on CI on both platforms, and that one example test runs in a couple hundred milliseconds without a device against around two seconds on an iOS simulator. The same tests form the behavior gate in Helix, the tool Shopify uses to have agents rebuild screens through small checkpoints.

These tests do not look at pixels. Shopify covers that with a visual review of every Helix checkpoint against the reference app and screenshot tests for the few components where appearance matters, and it argues that most screen bugs live in logic, which the behavior tests reach. The cost is large fixtures, since one user journey can carry a dozen GraphQL responses, which Shopify calls tedious for a human to maintain but fine for an . It is not releasing a library either: its introspection code is tied to Shopify's own session model, navigators and fixture formats, so the post describes the architecture and says a capable coding agent can implement it for another app from the description.

Key takeaways · AI-distilled
  • Shopify's Reflex keeps all app logic in a Core module with no UI or device imports, so ViewModels, navigation and GraphQL run headlessly on macOS or the JVM. Shopify says its 1,700+ behavior tests finish in about four minutes on CI on both platforms.
  • Each screen exposes a JSON introspection node: a stable name, its state, and every action it accepts. A CLI reads it with ls and invokes actions with do, so an agent drives the app through ViewModels without a simulator or the rendered UI.
  • Shopify writes iOS (Swift) and Android (Kotlin) code separately with no shared layer, and enforces parity through one behavior test file that runs on both platforms. A PR cannot merge if it passes on only one.
  • The behavior suite blocks every HTTP request and fails a test if one is attempted, even when the app recovers. Every external dependency needs a fixture passed through the constructor, which keeps the suite deterministic at the cost of large fixtures.
  • Shopify publishes no library: it says Introspection Kit is tied to its session model and fixtures, and that the architecture itself is what transfers. The same state-and-actions surface also lets its in-app assistant, Sidekick, take actions.
Terms in this piece · Glossary
  • AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
Read the source shopify.engineering
More from Shopify Engineering
Recommended reads
Comments

Checking sign-in…

Loading comments…