<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Blink22 LLC</title>
    <description>The latest articles on DEV Community by Blink22 LLC (blink22).</description>
    <link>https://dev.to/blink22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F14111%2F1ad38db4-bda8-4037-ab17-03dd2bb7985d.png</url>
      <title>DEV Community: Blink22 LLC</title>
      <link>https://dev.to/blink22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/blink22"/>
    <language>en</language>
    <item>
      <title>When Two Claude Agents Reach for the Same Emulator</title>
      <dc:creator>Michael Magdy</dc:creator>
      <pubDate>Tue, 04 Aug 2026 10:52:53 +0000</pubDate>
      <link>https://dev.to/blink22/when-two-claude-agents-reach-for-the-same-emulator-1jfl</link>
      <guid>https://dev.to/blink22/when-two-claude-agents-reach-for-the-same-emulator-1jfl</guid>
      <description>&lt;p&gt;&lt;em&gt;Fixing AI agent test collisions with mic-lock&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Coding agents can now test on real devices. Run a few of them at once, though, and they'll collide. Here's the small open-source tool that makes them take turns.  &lt;/p&gt;




&lt;p&gt;Claude can now handle the whole testing loop on a mobile app itself: write the code, build it, install it on an emulator or a physical device, launch it, and drive the UI to check its own work. Testing is no longer the part you have to come back and finish by hand.&lt;/p&gt;

&lt;p&gt;And once an agent can test itself, you stop running just one at a time. You hand Claude a ticket in one Git worktree, another ticket in a second worktree, and a third in a third, and now you've got several agents working on different tasks &lt;strong&gt;in parallel on the same laptop&lt;/strong&gt;. That's the fast way to work now, and it's great, right up until two of them want the same device.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem: Why Parallel Claude Agents Collide on Shared Emulators
&lt;/h2&gt;

&lt;p&gt;Your machine can only run a couple of emulators. So picture this:&lt;/p&gt;

&lt;p&gt;Agent A finishes its feature, installs its build on emulator-5554, launches the app, and starts tapping through the flow to verify it. &lt;/p&gt;

&lt;p&gt;Mid-test, Agent B, heads-down on a completely different ticket, installs its own build onto that same emulator and starts driving the UI too.&lt;/p&gt;

&lt;p&gt;Now Agent A is stuck in a hall of mirrors. Its changes have vanished from the running app, so it starts chasing a regression that doesn't exist. The screen jumps and taps fire that it never issued (that's Agent B's automation), so it starts investigating phantom navigation and "flaky" behavior. &lt;/p&gt;

&lt;p&gt;Both test runs are corrupted, and neither agent actually did anything wrong. They just can't see each other, and nothing on the machine is telling them to wait their turn.&lt;/p&gt;

&lt;p&gt;You find out about all of this when you sit down to review two confused transcripts and a pile of wasted tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix Is a Lock
&lt;/h2&gt;

&lt;p&gt;This is an old, solved problem wearing a new costume: two things want one shared resource, so you put a lock on it. &lt;strong&gt;Mic-lock&lt;/strong&gt; turns each device into a lock that an agent has to hold before it installs anything or runs a test.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the device is free, the agent takes it and gets to work.
&lt;/li&gt;
&lt;li&gt; If it's busy, the agent doesn't clobber anything. It joins a &lt;strong&gt;fair, first-come queue&lt;/strong&gt; and gets handed the device the moment it frees up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A bit of what's happening underneath, because it's what makes it worth trusting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two layers.&lt;/strong&gt; A tiny gate, held for microseconds, serializes every decision so two agents can never both "win" a free device. The actual hold on the device is a &lt;strong&gt;lease&lt;/strong&gt; with a heartbeat.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crash-safe.&lt;/strong&gt; Since the lease is heartbeated, an agent that dies mid-test doesn't wedge the emulator forever. Its hold simply expires, and the next agent in line reclaims the device.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No zombies.&lt;/strong&gt; Every hold carries &lt;strong&gt;a fencing token&lt;/strong&gt;, so an agent that was slow or got bumped can't come back later and release or stomp on a device that's already moved on to someone else.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No infrastructure.&lt;/strong&gt; It's all atomic filesystem operations under &lt;code&gt;~/.mic-lock&lt;/code&gt;. No server, no daemon, no Redis. It works on a plane.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of that is theoretical. The core safety property, never more holders than the device has slots and no silent double-install, holds up structurally, and the stress tests back it up: ten contending processes, a killed holder getting reclaimed, capacity never exceeded.&lt;/p&gt;

&lt;h2&gt;
  
  
  You Set It Up Once; The Agents Do the Rest
&lt;/h2&gt;

&lt;p&gt;The point is that &lt;strong&gt;nobody runs these commands by hand.&lt;/strong&gt; You run a single command once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mic-lock setup            &lt;span class="c"&gt;# this machine  &lt;/span&gt;

&lt;span class="c"&gt;# or: mic-lock setup --project   # committed to the repo, travels with it&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That installs three things into your Claude setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A skill&lt;/strong&gt; that teaches agents to take a device once and hold it for the whole task, then release it.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A guard hook&lt;/strong&gt; that blocks any device command an agent tries to run without holding the lock and tells it exactly how to fix that. This part is deterministic, so it doesn't depend on the model remembering to be polite.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A naming rule&lt;/strong&gt; so every agent locks the same device by the same ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After that, your agents coordinate themselves. Under the hood, they're just running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mic-lock acquire emulator-5554 &lt;span class="nt"&gt;--owner&lt;/span&gt; &lt;span class="s2"&gt;"checkout smoke"&lt;/span&gt; &lt;span class="nt"&gt;--wait&lt;/span&gt;   &lt;span class="c"&gt;# waits its turn  &lt;/span&gt;

&lt;span class="c"&gt;# …install, launch, test…  &lt;/span&gt;

mic-lock release emulator-5554

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or wrapping a one-off command so it auto-releases even if it crashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mic-lock with emulator-5554 &lt;span class="nt"&gt;--&lt;/span&gt; &amp;lt;build-install-test &lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="se"&gt;\&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And when you're curious what the swarm is up to, mic-lock status shows who holds what and who's waiting in line. One glance instead of reading three separate transcripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; mic-lock  

mic-lock setup  

&lt;span class="c"&gt;# restart your Claude sessions, then let your agents loose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Needs Node 18+. Android discovery uses adb; iOS uses xcrun simctl, and the lock itself needs neither. MIT-licensed and open source.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Michael23Magdy/mic-lock" rel="noopener noreferrer"&gt;github.com/Michael23Magdy/mic-lock&lt;/a&gt; · &lt;strong&gt;npm:&lt;/strong&gt; &lt;code&gt;mic-lock&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you've started running Claude agents in parallel on one machine, this is the piece that keeps them from clobbering each other's device. Set it up once and forget it's there.&lt;/em&gt;  &lt;/p&gt;

</description>
      <category>ai</category>
      <category>mobile</category>
      <category>agents</category>
      <category>agentskills</category>
    </item>
  </channel>
</rss>
