DEV Community

skywalker
skywalker

Posted on

Using Kiro Specs, Hooks & Custom MCP to Build a Zero-X11 Android PC-Game Engine

Written for Kiroween 2026 (Frankenstein category): how we used Kiro IDE, kiro-cli, EARS Specs, PostFileSave Hooks, and a custom Python MCP server to build Amphora — a lightweight Android PC-game app and parallel embeddable SDK powered by Valve's Proton 11, FEX-Emu, DXVK, vkd3d-proton, and Mesa Turnip.*


Running real Windows PC games locally on Android is no longer a niche party trick. Community launchers like Winlator, GameNative, and DroidDeck have surged in popularity, and hardware makers are investing too — from Xiaomi's WinPlay Engine on the Pad 6S Pro and RedMagic's 10S Pro Game Space to Valve's Snapdragon-powered Steam Frame ARM64 headset.

Yet today's options sit at two extremes: vendor engines locked to a single device, or monolithic community launchers that usually eat 3.6–7.0 GB of storage, bounce frames through an X11 or Wayland desktop server, duplicate hundreds of megabytes per game, and cannot be reused by other apps.

When we built Amphora, we built two things in parallel on one native Bionic core: a ready-to-play Android app (3.5 MB APK) for players, and a standalone Apache-2.0 Android SDK (1.1 MB AAR) so any launcher, handheld shell, or game client can embed the exact same Windows runtime in four lines of Kotlin:

val sdk = AmphoraSdk.get(applicationContext)
sdk.runtime.install() // async download & verify; await Ready
val game = sdk.library.games.value?.firstOrNull() ?: return
sdk.sessions.launch(LaunchTarget.Play(game))
Enter fullscreen mode Exit fullscreen mode

Both share an 82 MB reproducible CI runtime (0.59 GB total on disk, ~5 MB per isolated game) — no root, no proot, no X11, and no PulseAudio.

Pulling that off in four weeks meant juggling four repositories and four languages — Kotlin/Compose (amphora), C/Wine/NDK (proton-wine), BuildStream (amphora-engine), and TypeScript/Cloudflare Workers (amphora-cache). Here is how Kiro kept that multi-repo architecture from falling apart, the three real blind spots it caught, and the Android engine we shipped underneath those guardrails.


1. Why Four Repos Need More Than Unit Tests — And How We Wired Kiro

Late one night while testing a 32-bit Windows installer on our tablet, a dialog popped up:

Expected:  File not found
Actual:    Hile not fpund
Enter fullscreen mode Exit fullscreen mode

Two letters off. FEX's reduced-precision x87 mode was subtly corrupting Delphi/Inno Setup string copies. Worse, our FEX Config.json already had a per-app override disabling that mode for setup*.exe — but our own Kotlin settings builder was emitting an environment variable that silently outranked it.

That is the real danger of shipping a systems project across four repos at hackathon speed: every repo passes its own build, while a tiny cross-layer mismatch silently breaks user behavior.

To keep those boundaries intact, we wired Kiro IDE and kiro-cli into a four-layer automated safety net plus a read-only audit pass:

How Amphora uses Kiro: 4 layers of automated guardrails — Steering & Skills, EARS Specs & PBT, PostFileSave Hooks, and Custom Agents + Python MCP

  • Steering & Skills (Rules + Domain Playbooks): Three scoped Steering files automatically inject our architecture red lines whenever we touch code (no X11, no DXVK_ASYNC, no libandroid.so inside Wine). Three Skills act as on-demand engineering playbooks — covering Android Bionic porting, SurfaceFlinger debugging, and BuildStream releases — loaded only when a task hits that domain.
  • Specs (Spec-Driven Development for Two Core Modules): Instead of jumping straight into code, we wrote formal requirements, design, and task lists in Kiro for two areas where subtle bugs hide:
    • settings-pbt: Defined the exact rules for how settings override each other (recipe default → global → per-game fix → user per-game) and how paths/args parse, driving 33 randomized property tests (0.86s) to catch edge-case conflicts.
    • bilingual-i18n: Defined English + Simplified Chinese support across the whole app — so switching languages updates both the main UI and the in-game overlay/notifications running in the game process, with automated checks ensuring none of our 800+ strings or format placeholders go missing.
  • PostFileSave Hooks (Automatic Save-Time Checks): Three hooks trigger the moment we save a file in Kiro IDE: saving .kt code runs Spotless formatting and SDK unit tests, saving shell scripts runs shellcheck, and editing recipe.json or the settings catalog wakes up a Kiro review — directly inspired by that Hile not fpund bug — to verify every toggle and FEX default rule stays intact.
  • Custom Python MCP Server (amphora-inspector) + Two Read-Only Agents (Zero-Guesswork Audits): We built a zero-dependency Python MCP toolbox called amphora-inspector (amphora_mcp.py, 6/6 tests) and attached it to two specialized kiro-cli agents:
    • recipe-auditor scans recipe.json, all 53 settings, all 800+ EN/ZH strings, and our docs to catch config mismatches or version drift.
    • device-diagnostician reads real Windows .exe binaries to inspect their architecture and required DLLs, and parses frame-pacing, GPU, audio-underrun, and thermal logs captured from physical phones — diagnosing from real data instead of guessing.

2. Three Real Blind Spots Kiro Caught — And What We Learned About Using Kiro

Independent kiro-cli and MCP audits caught three concrete blind spots before release:

Three real issues caught by Kiro audits: Gradle PBT seed forwarding, stale skill doc facts, and 104.6 °C CPU thermal spike

The one that surprised us most was the Gradle bug. All 325 tests at the time were green, so we thought settings-pbt was done. When we ran kiro-cli to check the spec, it refused to tick Task 4.3: sdk/build.gradle.kts had never forwarded -Damphora.pbt.seed to the forked test JVM, so seed replay from the command line had been silently ignored the whole time. One line in Gradle fixed it. On the MCP side, recipe-auditor caught two stale facts in our own BuildStream skill doc, and device-diagnostician spotted a 104.6 °C CPU spike in a 120 FPS capture our own script had labeled healthy, so we added an automatic >= 95 °C check to amphora_mcp.py.

In practice, Kiro worked best when we split it in two. In the IDE, Steering files and PostFileSave hooks caught formatting and catalog mistakes as we edited. Outside the IDE, running kiro-cli in read-only mode against amphora-inspector gave us a separate pass that didn't trust our assumptions. It still can't look at a phone screen — debugging GPU visual glitches (like the Galaxy S23 black-tile bug below) or reading a SurfaceFlinger dump is still hands-on work — but once we found a fix, writing it into .kiro/ stopped us from breaking it again two days later.


3. What We Built Under Those Guardrails: Amphora's Native Android Stack

Valve, CodeWeavers, FEX-Emu, DXVK, vkd3d-proton, and Mesa already solved the core translation problem — turning x86 instructions and Direct3D calls into ARM64 and Vulkan — and Twaik Yont laid the 35-commit process-split foundation for wineandroid.drv. We did not reinvent any of that.

Yet bringing that desktop stack onto phones still leaves a massive engineering gap. Getting the full toolchain to cross-compile reproducibly against Android's Bionic libc and stay in step with upstream takes real build infrastructure. More importantly, Android is not a Linux desktop — out of the box, Wine on Android hits four immediate walls:

  • Graphics: Once Wine runs in a separate process from the Android UI, its built-in display path stops working.
  • Thread sync: Android's app security sandbox blocks the Linux kernel calls that Proton relies on for fast synchronization.
  • Storage: Android's /data partition forbids hard links and overlayfs, so isolating each game normally duplicates hundreds of megabytes.
  • Hardware I/O: Gamepads, low-latency audio, and DNS have no native Android backends unless you pull in desktop daemons or LD_PRELOAD hacks.

Over four weeks, we wrote roughly 9,600 lines of native Android platform drivers inside Wine, 11 patches across Mesa, FEX, and Fossilize, a Jetpack Compose Android app alongside its embeddable SDK, and a small open-source cloud shader cache — all guided by one rule codified into our .kiro/steering/architecture-decisions.md:

Remove layers and fix root causes instead of stacking workarounds.

Amphora 3-layer architecture: Upstream open source, Amphora native Android SDK & drivers, Android OS primitives

Zero-X11 Direct Scanout (+54–62% Faster)

Most Android PC game launchers pretend your phone is a Linux desktop, rendering into an X11 server or Wayland compositor and copying frames into an Android view. Amphora skips the desktop compositor altogether. We wrote a cross-process Vulkan display path inside Wine's Android driver that renders straight into hardware-compressed Android GPU buffers (AHardwareBuffer) and hands them to Android's hardware display compositor (SurfaceControl). SurfaceFlinger confirms zero GPU compositing overhead (an invariant we encoded into our android-wine-debugging Kiro skill and amphora-inspector MCP parser).

Typical 5-hop X11/Wayland desktop detour vs Amphora 2-hop direct hardware scanout

On the exact same Lenovo Legion Y700 tablet running Unigine Heaven 4.0 (720p DX11 High, full 260-second benchmark, shipped defaults):

4-stack Unigine Heaven 4.0 head-to-head on Y700: Amphora 72.0 FPS warm / 75.6 FPS cold peak vs DroidDeck 56.5, WinNative 45.6, GameNative 44.5

Amphora runs 54–62% faster than X11-based stacks and 25–28% faster than DroidDeck — and even when forced onto GameNative's driver flags, it still holds 68.0 vs 44.5 FPS. On the same tablet, it also runs Unreal Engine 5.7 (DX12 + Lumen), Unity 6 (116 FPS), Godot 4.7 + .NET 8 (72 FPS), SuperTuxKart (locked 120 FPS with zero drops while recording), and Factorio (locked 60 FPS).

Fast Thread Sync Inside Android's Security Sandbox (+104.5% Score)

Modern Windows games synchronize dozens of threads thousands of times per second. On desktop Linux, Proton accelerates this with fsync, but Android's seccomp security sandbox kills futex_waitv on sight and blocks robust cross-process mutexes too. Without fast sync, every thread wait queues through single-threaded wineserver, which climbed to 42.8% CPU in FFXIV: Dawntrail.

We kept Proton's fsync, moved shared memory onto Android's memfd, and replaced the blocked kernel wait with a 640 KB lock-free shared-memory wait table (fsync_wtab.h). Because no lock is ever held across processes, a crashed game thread can never freeze the app (and our proton-bionic-porting Kiro skill permanently documents Android's seccomp syscall rules so regressions can't sneak back in).

Android fsync architecture: seccomp SIGSYS block on futex_waitv vs Amphora 640 KB lock-free memfd wait table

After passing Wine's kernel32:sync suite (344,774 checks) and a 64-thread crash-stress test, WaitForSingleObject(0) dropped from 30.8 µs to 0.10 µs (~296× faster), 4-thread mutexes ran 31× faster, and in FFXIV: Dawntrail, wineserver CPU fell from 42.8% to 0–3.8% while the benchmark score more than doubled (+104.5%):

Measured Android fsync result: wineserver CPU drops from 42.8% to 0-3.8% and 120s DX11 score rises +104.5%

5 MB Per-Game Sandboxes & Lossless Slimming (0.59 GB Total)

Android PC-game apps typically eat 3.6 to 7.0 GB before you install a single game, plus ~400 MB per isolated prefix thanks to that /data deduplication restriction. Amphora builds one template per runtime, symlinks 1,699 identical files into the read-only runtime, and adds copy-on-write directly inside wineserver so every game gets its own clean sandbox for about 5 MB while saves stay separate in userdata/.

Storage comparison: 399 MB standard isolated Proton prefix vs 4.3-6.7 MB Amphora thin COW prefix

We also audited both the runtime and the Android SDK megabyte by megabyte without removing a single Windows DLL: 16 KB alignment, symbol stripping, unused software-renderer removal, and .tar.xz cut the runtime download by 61% (212 MB → 82.3 MB) and unpacked size by 43% (1.0 GB → 576 MB). On Android, replacing a 34 MB icon pack with the five icons our overlay uses and trimming 83 unused locales brought the release APK to 3.5 MB and :sdk AAR to 1.1 MB.

Same-tablet 4-app disk footprint comparison: Amphora 0.59 GB vs WinNative 3.6 GB, GameNative 4.1 GB, DroidDeck 7.0 GB

On the same Y700 tablet (clean install plus one isolated prefix, excluding games), Amphora's 0.59 GB footprint is 6.1× to 11.9× smaller than existing stacks, with an ≈86 MB first-time download.

Cross-GPU Shader Pre-Warming with Fossilize

Anyone who has run PC games on mobile knows the first-run stutter: every new area or visual effect pauses the frame while the phone compiles shaders on the fly. Sharing raw compiled Mesa shader caches only gets you partway — in our tests, a raw cache transferred cleanly between identical GPUs (100% hit), but dropped straight to 0% on a different GPU generation, and invalidated again the moment Mesa Turnip updated. Maintaining separate binaries for every GPU generation times every driver release does not scale.

That is why Valve open-sourced Fossilize for Steam Deck: instead of sharing GPU-specific binaries, one device records a small hardware-neutral .foz pipeline archive that any other device compiles locally before launch. We brought that two-part workflow to Android — wiring Fossilize directly into Amphora's Turnip driver path for local recording and automatic re-warming on driver updates (0.8s), and building a lightweight, opt-in open cloud cache (amphora-cache) to merge and serve archives across devices.

The cross-generation payoff is immediate: a single 1.1 MB archive recorded on an Adreno 830 (Lenovo Y700) pre-warmed all 315/315 pipelines in 1–1.5 seconds on cold Adreno 750 (Galaxy S24) and Adreno 730 (Tab S8 Ultra) devices, with 0 bytes of new shader compilation during play.

Cross-generation Fossilize pre-warming and open Cloudflare R2 shader pool: Adreno 830 to Adreno 750 and 730 with 100% cache hit

Open Reproducible Builds, 9 Physical Devices & Root-Cause Fixes

Most community runtimes ship as opaque .wcp tarballs built on one laptop and tested on one phone. Every Amphora runtime in amphora-engine is built in public GitHub Actions via BuildStream, pinned by SHA-256, audited by our Kiro recipe-auditor agent and buildstream-runtime-release skill, and verified across three automated gates: 351+ JVM and property tests plus a 31/31 public cloud Arm Android 15 CI suite, a 41-probe headless smoke suite on our local Lenovo Y700 tablet (zero sleep timers), and automated Firebase Test Lab runs across 8 cloud physical devices — 9 physical devices across 5 OEMs (Lenovo, Samsung, Xiaomi, Motorola, and Google) spanning five Snapdragon GPU generations (A730–A830).

Amphora 4-stage open BuildStream CI and 3-gate automated verification architecture

Testing across real brands paid off immediately. On a physical Galaxy S23 (Adreno 740, Android 15 / One UI 7), Heaven rendered with flickering black tiles because Qualcomm's system UI driver and Mesa Turnip were fighting over the same GPU compression (UBWC) flag bit. The usual workaround is disabling UBWC compression (TU_DEBUG=noubwc), which clears the artifacts at the cost of roughly a third of your frame rate, or maintaining per-device overrides. Instead, we wrote a 4-line hardware read-modify-write patch in Turnip that preserves whatever flag the phone's firmware sets. Black tiles vanished, and in the same airship scene the S23 jumped from 27.8 FPS (noubwc) to 41.9 FPS (+50.7%) — with zero regressions on older Android 13 phones.

Real Galaxy S23 before and after: Turnip CP_REG_RMW eliminates black-tile UBWC corruption at 41.9 FPS (+50.7% in same scene)

That same root-cause mindset carries through the rest of the stack: native HID gamepads (winebus) with zero LD_PRELOAD tricks, native AAudio with zero underruns, and native Android DNS + Conscrypt HTTPS.


Try Amphora, Inspect .kiro/, or Embed the SDK

Whether you want to inspect our .kiro/ harness and MCP server offline (python3 -m unittest discover -s tools/mcp and kiro-cli agent validate run in under a second with no Android device), try the Android app on an Adreno 7xx/8xx device, or embed :sdk into your own launcher, everything is open source and reproducible:

Top comments (0)