<?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: Myles Ngicu</title>
    <description>The latest articles on DEV Community by Myles Ngicu (@myl3s).</description>
    <link>https://dev.to/myl3s</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%2Fuser%2Fprofile_image%2F3267913%2F530819c3-08ee-47e7-8f17-b0d57dbf1cd4.jpg</url>
      <title>DEV Community: Myles Ngicu</title>
      <link>https://dev.to/myl3s</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/myl3s"/>
    <language>en</language>
    <item>
      <title>Proving Your Self-Hosted LLM Never Phones Home</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Wed, 25 Nov 2026 06:33:31 +0000</pubDate>
      <link>https://dev.to/aws-builders/proving-your-self-hosted-llm-never-phones-home-1dgk</link>
      <guid>https://dev.to/aws-builders/proving-your-self-hosted-llm-never-phones-home-1dgk</guid>
      <description>&lt;h2&gt;
  
  
  Private Is a Claim
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Part 1 of a series on building Ndani, an open-source framework for running a private LLM on any server and proving that nothing leaves it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;"We self-host the model, so our data is private." I hear this a lot, and I used to say it myself. It sounds right: the weights sit on your server, inference runs on your GPU, no API key to a third party. But running the model yourself only answers one question, which is &lt;em&gt;who computes the answer&lt;/em&gt;. It says nothing about &lt;em&gt;what else your server talks to&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;When I tested my own setup, the container that faced users could open a TCP connection to any public IP, get answers from Google's public DNS, and reach the cloud metadata service that hands out the instance's credentials. None of that showed up in normal use. The app worked fine. That's the problem: a leaky private LLM and a sealed one look identical until you try to get out.&lt;/p&gt;

&lt;p&gt;So in this series I treat "private" as a claim that needs evidence. This first post covers the threat model, when you don't need any of this, the design I landed on, and a test suite that tries every way out and writes down what happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Every way data leaves a "private" LLM server
&lt;/h2&gt;

&lt;p&gt;There are at least seven exits, and most self-hosting guides close one or two of them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Exit&lt;/th&gt;
&lt;th&gt;What it looks like in practice&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Runtime phone-home&lt;/td&gt;
&lt;td&gt;The model server downloads weights or config from Hugging Face at start-up, or sends usage stats&lt;/td&gt;
&lt;td&gt;Your server makes outbound calls you never asked for, and a compromised dependency has a path out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Open container egress&lt;/td&gt;
&lt;td&gt;The API container can open a TCP connection to any public IP&lt;/td&gt;
&lt;td&gt;Anything that runs in it, including a poisoned package, can send data anywhere&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS tunnelling&lt;/td&gt;
&lt;td&gt;A query for &lt;code&gt;&amp;lt;encoded-secret&amp;gt;.attacker.com&lt;/code&gt; reaches the attacker's name server&lt;/td&gt;
&lt;td&gt;Works even with no internet route, because the resolver does the travelling for you&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloud metadata service&lt;/td&gt;
&lt;td&gt;A container reaches &lt;code&gt;169.254.169.254&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;It can read the instance role's credentials and act as your server against your cloud account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tool calling&lt;/td&gt;
&lt;td&gt;The model is given an &lt;code&gt;http_get&lt;/code&gt; tool and a document says "fetch this URL with the data"&lt;/td&gt;
&lt;td&gt;Prompt injection turns your model into the exfiltration client&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logs&lt;/td&gt;
&lt;td&gt;Prompts stored in plain text in app or audit logs, then shipped to a logging service&lt;/td&gt;
&lt;td&gt;The sensitive part leaks through the observability stack, not the model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The supply chain&lt;/td&gt;
&lt;td&gt;Weights or images swapped before they reach the server&lt;/td&gt;
&lt;td&gt;You verify nothing, so you run whatever arrives&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The first five are network problems. The last two are about what you write down and what you trust coming in. A private setup has to answer all seven, and it has to answer them with something you can check.&lt;/p&gt;

&lt;h2&gt;
  
  
  First: you might not need any of this
&lt;/h2&gt;

&lt;p&gt;If you're on AWS and privacy is your main worry, start with Amazon Bedrock. Its &lt;a href="https://docs.aws.amazon.com/bedrock/latest/userguide/data-protection.html" rel="noopener noreferrer"&gt;data protection docs&lt;/a&gt; say it doesn't store or log your prompts and completions, doesn't use them to train models, and doesn't share them with third parties. Model providers have no access to the accounts where their models run. With an interface endpoint (PrivateLink), traffic from your VPC never touches the public internet.&lt;/p&gt;

&lt;p&gt;That covers most teams. Self-hosting is worth the extra work when one of these is true:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You need a model you control completely&lt;/strong&gt;: a fine-tune you own, an open model Bedrock doesn't offer, or a pinned version that never changes under you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A rule says no managed AI service may process the data&lt;/strong&gt;, whatever its terms say. Some regulators and clients write contracts this way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You run a steady, high volume of requests&lt;/strong&gt;, so a GPU you pay for by the hour beats paying per token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You have to run where the cloud isn't&lt;/strong&gt;: on-prem, in a country without the region you need, or on a box with bad connectivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If none of those apply, close this tab and use Bedrock. If one does, read on, because self-hosting done casually is &lt;em&gt;less&lt;/em&gt; private than a managed service with good defaults.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design
&lt;/h2&gt;

&lt;p&gt;I wanted this to work on any Linux server: EC2, a VPS, an old office PC. So the main guarantee lives in Docker and the host firewall, and the cloud network is an extra layer on top, not the foundation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnhxljhu9baz0lgi6ral.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnhxljhu9baz0lgi6ral.png" alt="Ndani architecture: one edge container, everything else sealed" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The sealed network.&lt;/strong&gt; The model server, the embeddings server and the vector database sit on a Docker network marked &lt;code&gt;internal: true&lt;/code&gt;. Docker gives that network no route to anything outside the host. That's one line of YAML, and it closes the biggest exit for the parts that touch your data most.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One edge container.&lt;/strong&gt; Only the gateway joins a second, normal network, because users have to reach it. It's an OpenAI-compatible API, so any existing SDK works by changing the base URL. It checks API keys, rate-limits, refuses tool calls by default, and writes an audit log that stores a SHA-256 hash of each prompt instead of the prompt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The egress guard.&lt;/strong&gt; The gateway can still reach the internet, so the host gets two default-deny rules. An nftables table drops anything the host itself sends out, except loopback, replies and an explicit allowlist. A chain hooked into Docker's &lt;code&gt;DOCKER-USER&lt;/code&gt; drops any &lt;em&gt;new&lt;/em&gt; connection that starts on an Ndani bridge. Replies to users still flow; the gateway just can't start a conversation with the outside world. Both layers count and log what they drop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline bundles.&lt;/strong&gt; Weights arrive as a bundle built on a connected machine: the model files, an embedding model, optional &lt;code&gt;docker save&lt;/code&gt; image tarballs, and a manifest with every file's SHA-256 hash and size. The server refuses to start if any hash is wrong, any file is missing, or there's a file the manifest doesn't list. You can sign the manifest with &lt;code&gt;ssh-keygen&lt;/code&gt;, which is on every Linux box already. At runtime, &lt;code&gt;HF_HUB_OFFLINE=1&lt;/code&gt; means nothing even tries to download.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving it
&lt;/h2&gt;

&lt;p&gt;A design diagram proves nothing, so &lt;code&gt;ndani verify&lt;/code&gt; attacks the setup and writes a report. With the guard on, the test run passed 47 of 47 checks, and the firewall counters showed 56 packets dropped during the run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Probing from inside each container.&lt;/strong&gt; The probe is one standard-library Python script. The trick is running it &lt;em&gt;inside another container's network namespace&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run --rm --network container:ndani-inference-cpu \
  ndani/gateway:0.1.0 python probe.py --json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The probe sees exactly the network the model server sees, without installing anything into the model's image. It tries seven exits: system DNS, a raw DNS query to 8.8.8.8, TCP to public IPs on 443 and 80, HTTPS to huggingface.co, the metadata service, and IPv6. It runs in every container and on the host.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Control probes.&lt;/strong&gt; A test that only checks for failure can pass because the network is simply broken. So each probe also has to &lt;em&gt;reach&lt;/em&gt; what it should: the gateway must reach the model, the model must reach the database, the host must reach the gateway. If those succeed and the escapes fail, the guard is doing the blocking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Counters, not just logs.&lt;/strong&gt; Kernel log lines are often hidden inside containers or rate-limited. nftables and iptables drop counters are always readable, so the report records how many packets each layer dropped during the run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before and after
&lt;/h3&gt;

&lt;p&gt;I ran the suite on real Docker networks and the real firewall rules, with small stand-in services in place of the model containers (the isolation is what's under test here; running the real models is part 2).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Exit tried from the gateway container&lt;/th&gt;
&lt;th&gt;Guard off&lt;/th&gt;
&lt;th&gt;Guard on&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Raw DNS query to 8.8.8.8&lt;/td&gt;
&lt;td&gt;Got an answer&lt;/td&gt;
&lt;td&gt;Dropped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TCP to 1.1.1.1:443&lt;/td&gt;
&lt;td&gt;Connected&lt;/td&gt;
&lt;td&gt;Dropped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TCP to a public IP on 80&lt;/td&gt;
&lt;td&gt;Connected&lt;/td&gt;
&lt;td&gt;Dropped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Metadata service, 169.254.169.254&lt;/td&gt;
&lt;td&gt;Connected&lt;/td&gt;
&lt;td&gt;Dropped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gateway reaches the model and the database&lt;/td&gt;
&lt;td&gt;Connected&lt;/td&gt;
&lt;td&gt;Connected&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With the guard off, the run failed 11 checks: the gateway and the host could both get out. The containers on the sealed network were already blocked before the guard went on, which shows the &lt;code&gt;internal: true&lt;/code&gt; network holds up on its own. With the guard on: 47 passed, 0 failed, 4 skipped (the checks that need a real model and an API key). The host dropped 46 packets and the container layer 10.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't solve
&lt;/h2&gt;

&lt;p&gt;Being honest about limits is part of the claim.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your cloud provider is still inside the trust boundary.&lt;/strong&gt; On EC2 you rely on AWS's isolation and your own KMS keys. If the requirement is "nobody but us, ever", run it on hardware you own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Getting things in is the weak point.&lt;/strong&gt; Hashes prove the bundle wasn't changed after you built it, not that the machine you built it on was clean. Sign bundles, and build them somewhere you trust.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools change the threat model.&lt;/strong&gt; Ndani refuses tool calls by default. Turn them on and every tool runs inside the sealed network, so it's only as safe as what you let it reach.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No model is "safe" here, only contained.&lt;/strong&gt; The guard stops data leaving. It doesn't stop a model giving a wrong or harmful answer to the people who can reach it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next in the series
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Running it for real&lt;/strong&gt;: a CPU model on a small EC2 instance, the full verify report with zero skips, and what broke on the way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The zero-egress VPC on AWS&lt;/strong&gt;: Terraform for a VPC with no internet gateway, VPC endpoints, and Route 53 DNS Firewall, which closes the DNS exit most guides miss.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost&lt;/strong&gt;: self-hosted on a GPU instance against Bedrock, per 1,000 requests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The code is on GitHub at &lt;a href="https://github.com/MylesMburu/ndani" rel="noopener noreferrer"&gt;https://github.com/MylesMburu/ndani&lt;/a&gt;. Run &lt;code&gt;ndani verify&lt;/code&gt; against your own setup and tell me what got out.&lt;/p&gt;

</description>
      <category>privacy</category>
      <category>ai</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Sporty AI - The Agentic Football Cup</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Thu, 24 Sep 2026 19:06:20 +0000</pubDate>
      <link>https://dev.to/myl3s/sporty-ai-the-agentic-football-cup-1e6i</link>
      <guid>https://dev.to/myl3s/sporty-ai-the-agentic-football-cup-1e6i</guid>
      <description>&lt;p&gt;Football and AI agents, what a match!(pun intended).&lt;br&gt;
I am trying out the Agentic Football Cup 2026 and would love to share my experience so you could do so too. The AWS Agentic Football Cup is a hands-on technical workshop and tournament by AWS where participants build and coach a team of five autonomous AI agents to play a 5-a-side football match.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuiwbrrrmr71t6bj4fyjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuiwbrrrmr71t6bj4fyjk.png" alt="Goalkeeper Agent instructions" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4wv4r5z1l7bf82171ryq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4wv4r5z1l7bf82171ryq.png" alt="Deploy your football agents" width="799" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbvkpsd1vjk0vc9qw9zq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbvkpsd1vjk0vc9qw9zq1.png" alt="Deployed agents" width="799" height="316"&gt;&lt;/a&gt;&lt;br&gt;
The yellow hearts mean that you need to check the pre-match fitness of your players. For our agents it means that they can all connect successfully&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw829c8pkadmtgmbkbunz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw829c8pkadmtgmbkbunz.png" alt="Practice match launch" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After all agents pass the test you can test them out by playing a practice match. No points are awarded for this. There are three teams to practice against, a balanced one, an attack focused one and a defensive one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhf013ikjrp0ftrvz112c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhf013ikjrp0ftrvz112c.png" alt="Match results" width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
My first match ended in a defeat😂. The all out attack team was quite ferocious. Good thing there's a match report and coach recommendations I can use to update my agent instructions. &lt;/p&gt;

&lt;p&gt;Head to &lt;a href="https://agenticfootballcup.ai/" rel="noopener noreferrer"&gt;https://agenticfootballcup.ai/&lt;/a&gt; to create your team and probably challenge mine :b&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>aws</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React Ref Problem: Ref Pointing to Multiple DOM Elements with CSS Media Query Hiding</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Tue, 09 Sep 2025 14:25:20 +0000</pubDate>
      <link>https://dev.to/myl3s/react-ref-problem-ref-pointing-to-multiple-dom-elements-with-css-media-query-hiding-168h</link>
      <guid>https://dev.to/myl3s/react-ref-problem-ref-pointing-to-multiple-dom-elements-with-css-media-query-hiding-168h</guid>
      <description>&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;br&gt;
In React, a single ref object can only hold a reference to one DOM element at a time via its .current property. Assigning the same ref to multiple elements causes the ref to point to the last rendered element. This can cause issues in event handling logic when multiple elements are rendered but some are hidden using CSS media queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Description&lt;/strong&gt;&lt;br&gt;
I had a bug where the same React ref (locationRef) was assigned to two  components that render differently for desktop and mobile views. This resulted in clicks inside the desktop view not working while clicks in the mobile view worked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
  function handleClickOutside(event) {
    if (
      locationRef.current &amp;amp;&amp;amp;
      !locationRef.current.contains(event.target)
    ) {
      setIsLocationOpen(false);
    }
  }

  document.addEventListener("mousedown", handleClickOutside);
  return () =&amp;gt; {
    document.removeEventListener("mousedown", handleClickOutside);
  };
}, [locationRef]);

// JSX structure
&amp;lt;DesktopOnly&amp;gt;
  &amp;lt;LocationContainer ref={locationRef}&amp;gt;
    {/* Desktop location toggle and menu */}
  &amp;lt;/LocationContainer&amp;gt;
&amp;lt;/DesktopOnly&amp;gt;

&amp;lt;MobileOnly&amp;gt;
  &amp;lt;LocationContainer ref={locationRef}&amp;gt;
    {/* Mobile location toggle and menu */}
  &amp;lt;/LocationContainer&amp;gt;
&amp;lt;/MobileOnly&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;In this setup:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The same locationRef is used on both desktop and mobile .&lt;/p&gt;

&lt;p&gt;The mobile container is hidden via CSS media queries, e.g., display: none when on desktop screen sizes.&lt;/p&gt;

&lt;p&gt;What Happens Internally?&lt;br&gt;
Both desktop and mobile  are present in the DOM; only one is visually hidden.&lt;/p&gt;

&lt;p&gt;React assigns locationRef.current to the last rendered , typically the mobile one.&lt;/p&gt;

&lt;p&gt;Even though the mobile container is hidden by CSS, locationRef.current points to its hidden DOM element.&lt;/p&gt;

&lt;p&gt;The click outside handler checks events against the hidden element, causing flawed logic:&lt;/p&gt;

&lt;p&gt;Clicks inside the visible desktop container may appear outside the referenced element.&lt;/p&gt;

&lt;p&gt;Resulting in setIsLocationOpen(false) triggering unexpectedly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example Situation&lt;/strong&gt;&lt;br&gt;
If locationRef.current points to the mobile container which is hidden (but still in DOM due to CSS):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (locationRef.current &amp;amp;&amp;amp; !locationRef.current.contains(event.target)) {
  // This may trigger even if the click is inside the visible desktop container,
  // because locationRef.current points to the hidden mobile container node.
  setIsLocationOpen(false);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Recommended Solutions&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;&lt;em&gt;1. Use Separate Refs for Desktop and Mobile&lt;/em&gt;&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const desktopLocationRef = useRef(null);
const mobileLocationRef = useRef(null);

useEffect(() =&amp;gt; {
  function handleClickOutside(event) {
    const activeRef = window.innerWidth &amp;gt;= 768 ? desktopLocationRef : mobileLocationRef;

    if (
      activeRef.current &amp;amp;&amp;amp;
      !activeRef.current.contains(event.target)
    ) {
      setIsLocationOpen(false);
    }
  }

  document.addEventListener("mousedown", handleClickOutside);
  return () =&amp;gt; {
    document.removeEventListener("mousedown", handleClickOutside);
  };
}, []);

&amp;lt;DesktopOnly&amp;gt;
  &amp;lt;LocationContainer ref={desktopLocationRef}&amp;gt;{/* desktop content */}&amp;lt;/LocationContainer&amp;gt;
&amp;lt;/DesktopOnly&amp;gt;

&amp;lt;MobileOnly&amp;gt;
  &amp;lt;LocationContainer ref={mobileLocationRef}&amp;gt;{/* mobile content */}&amp;lt;/LocationContainer&amp;gt;
&amp;lt;/MobileOnly&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;em&gt;2. Conditionally Render Only One DOM Tree&lt;/em&gt;&lt;/u&gt;&lt;br&gt;
Instead of hiding via CSS, conditionally render only the applicable container per screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return (
  &amp;lt;&amp;gt;
    {isDesktop ? (
      &amp;lt;LocationContainer ref={locationRefDesktop}&amp;gt;{/* desktop */}&amp;lt;/LocationContainer&amp;gt;
    ) : (
      &amp;lt;LocationContainer ref={locationRefMobile}&amp;gt;{/* mobile */}&amp;lt;/LocationContainer&amp;gt;
    )}
  &amp;lt;/&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents multiple refs assigned to DOM elements simultaneously.&lt;/p&gt;

</description>
      <category>react</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Vibe coding clarity with Kiro specs</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Tue, 22 Jul 2025 14:50:01 +0000</pubDate>
      <link>https://dev.to/myl3s/vibe-coding-clarity-with-kiro-specs-5e56</link>
      <guid>https://dev.to/myl3s/vibe-coding-clarity-with-kiro-specs-5e56</guid>
      <description>&lt;p&gt;When AWS made the Kiro announcement, I was more than excited to try it out. As I write this blog, it is still in it's preview stage. I was able to download it before its access was limited for fine-tuning. I would love to share my experience so far.&lt;/p&gt;

&lt;p&gt;We are in the awesome age(some would think scary😅), of code-native AI agents. Think of it as a coding partner that is integrated to your coding environment such as your terminal or IDE. It has a codebase-wide understanding of your project which means it understands your project structure and gets the context across multiple files.&lt;/p&gt;

&lt;p&gt;Kiro is one of these cool tools. When I downloaded it, I signed in using my AWS Builder ID. There are other sign-in options including Google and Github. I loved this option that allowed me to import my configs from VScode&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqru4vlgfliou0f62c7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqru4vlgfliou0f62c7f.png" alt="Import VSCode configs" width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you finish setting up and open a project folder, you get to choose what mode you want to build in.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7g32viotbcp9ftdxs57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7g32viotbcp9ftdxs57.png" alt="Kiro build modes" width="799" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the &lt;strong&gt;Vibe&lt;/strong&gt; mode you chat with Kiro and tell it what you need it to do. It gets right into the implementation. Most code-native AI agents do something similar. This is an example of a prompt I wrote to test the 'vibe mode'. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1zgjt1uitxyc9sja1clf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1zgjt1uitxyc9sja1clf.png" alt="Kiro vibe mode" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For me, the real 'magic' happens in the &lt;strong&gt;Spec&lt;/strong&gt; mode. Kiro specs introduces clarity to vibe coding! It starts by generating &lt;strong&gt;user stories&lt;/strong&gt;, just as you would do in the requirement gathering stage of s/w development. You can tell it to edit and update the requirements until you are satisfied. When it's all good you proceed to design.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqle40qgonpndh3vpjf5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqle40qgonpndh3vpjf5.png" alt="Kiro requirement generation" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kiro designs the &lt;strong&gt;system architecture for you&lt;/strong&gt;! From architecture diagrams to Typescript interfaces, it knows what is needed based on the requirements. Once again, you can tell Kiro to update it until it fits your preference, then you proceed to generating the task list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv53f387ux1rq3ixw5iv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdv53f387ux1rq3ixw5iv.png" alt="Kiro architecture diagram generation" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcl8tozalnq8km3xc0rvr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcl8tozalnq8km3xc0rvr.png" alt="Kiro TS interfaces generation" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now this is my favourite part. Unlike your usual vibe coding sessions, this one is well guided. Kiro generates an &lt;strong&gt;implementation plan&lt;/strong&gt; which is a sequence of tasks to execute. The tasks are modular and include test generation. Just click 'Start task' and let Kiro execute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopt84b5i0h3wn6uomytp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopt84b5i0h3wn6uomytp.png" alt="Kiro executing tasks" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you see where the clarity in vibe coding comes in, right? As you vibe code, Kiro allows you to be very organised. You know exactly what tasks are done and which ones are remaining. One can almost visualise their project, end-to-end.&lt;/p&gt;

&lt;p&gt;I'm excited to try out more of their features such as the &lt;strong&gt;Agent hooks&lt;/strong&gt; which allows you to automate repetitive tasks. I highly recommend that you &lt;a href="https://kiro.dev/downloads/" rel="noopener noreferrer"&gt;join the waitlist&lt;/a&gt; to get this AWSome experience with Kiro!&lt;/p&gt;

</description>
      <category>kiro</category>
      <category>aws</category>
      <category>ai</category>
      <category>vibecoding</category>
    </item>
    <item>
      <title>Building a game using Amazon Q CLI</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Mon, 16 Jun 2025 10:08:46 +0000</pubDate>
      <link>https://dev.to/myl3s/building-a-game-using-amazon-q-cli-2h7a</link>
      <guid>https://dev.to/myl3s/building-a-game-using-amazon-q-cli-2h7a</guid>
      <description>&lt;h2&gt;
  
  
  Creating a Space Invaders Game with Amazon Q CLI
&lt;/h2&gt;

&lt;p&gt;If you think Amazon Q is cool, make a game with it on the CLI and experience the AWSomeness! That's exactly what I did and I marvelled at how easy it is.&lt;br&gt;
Amazon Q as a generative AI for developers. On the CLI, it doesn't have native support for Windows. I hadd a little trouble with that but I found out that I can install it using &lt;a href="https://learn.microsoft.com/en-us/windows/wsl/install" rel="noopener noreferrer"&gt;WSL&lt;/a&gt;. After that, just type 'q' and voila, you're in!😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcm5mr1ysazj1gwaotso.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcm5mr1ysazj1gwaotso.png" alt="Launching Amazon Q on WSL" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wanted to create the retro game called "Space Invaders" where a space ship shoots down alien invaders. All I needed to do was give Amazon Q this detailed prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a complete "Space Invaders"-style game using vanilla HTML, CSS, and JavaScript. The game should have a player ship at the bottom that moves left and right with arrow keys and shoots bullets upward with spacebar. Rows of aliens move side to side at the top and shoot bullets downward toward the player. Players score points by destroying aliens, the score should be displayed and updated in real time, and the game should show "GAME OVER" if an alien bullet hits the ship. Provide a directory structure with index.html, style.css, and script.js files, well-commented and functional by opening index.html in a modern browser.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vqxys52pabpfoi11a6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vqxys52pabpfoi11a6y.png" alt="Prompting Amazon Q CLI" width="800" height="469"&gt;&lt;/a&gt;&lt;br&gt;
It requested for permission to run a shell command and I did so by typing 't'(always allow such actions for this session).&lt;/p&gt;
&lt;h2&gt;
  
  
  Amazon Q's Response
&lt;/h2&gt;

&lt;p&gt;Amazon Q created a folder with the following files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;space-invaders/
├── index.html    # Main HTML structure
├── style.css     # Game styling
└── script.js     # Game logic and functionality
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response included instructions on how to run the game.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthv4027ewv000vpvbns5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthv4027ewv000vpvbns5.png" alt="Amazon Q CLI response" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Playing the game
&lt;/h2&gt;

&lt;p&gt;I navigated to the folder containing the game files and ran the index.html on my browser&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66rk9rx7ricxnuszx8in.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F66rk9rx7ricxnuszx8in.png" alt="File Explorer" width="800" height="604"&gt;&lt;/a&gt;&lt;br&gt;
As requested in the prompt, the game includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Player ship that moves left and right with arrow keys&lt;/li&gt;
&lt;li&gt;Shooting functionality with the spacebar&lt;/li&gt;
&lt;li&gt;Rows of aliens that move side to side and gradually descend&lt;/li&gt;
&lt;li&gt;Aliens that randomly shoot bullets downward&lt;/li&gt;
&lt;li&gt;Score tracking that updates in real-time&lt;/li&gt;
&lt;li&gt;"GAME OVER" display when hit by an alien bullet&lt;/li&gt;
&lt;li&gt;Different coloured aliens worth different point values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqmn0bwudjw4a0s1a62o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqmn0bwudjw4a0s1a62o.png" alt="Playing Space Invaders" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzkqtc5pfa6bziuvccdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzkqtc5pfa6bziuvccdo.png" alt="Space Invaders game lost" width="799" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, I haven't won a game yet(the aliens keep getting me). I enjoyed how easy it is to create the Space Invaders game using Amazon Q CLI in a single prompt-response interaction. It shows just one of the many capabilities of Amazon Q on the CLI.&lt;br&gt;
I hope y'all create cool games and join the &lt;a href="https://community.aws/content/2y6egGcPAGQs8EwtQUM9KAONojz/build-games-challenge-build-classics-with-amazon-q-developer-cli" rel="noopener noreferrer"&gt;challenge&lt;/a&gt; which ends on June 30th 2025.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>amazonqdevcli</category>
      <category>buildgameschallenge</category>
      <category>amazonqcli</category>
    </item>
    <item>
      <title>Debut!</title>
      <dc:creator>Myles Ngicu</dc:creator>
      <pubDate>Mon, 16 Jun 2025 06:37:08 +0000</pubDate>
      <link>https://dev.to/myl3s/debut-3772</link>
      <guid>https://dev.to/myl3s/debut-3772</guid>
      <description>&lt;p&gt;Hi there! This is my first day here(I feel like an intern😅). I'll use this space mostly to blog about cloud related projects I do on AWS. See you around! &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
