<?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: ArshTechPro</title>
    <description>The latest articles on DEV Community by ArshTechPro (@arshtechpro).</description>
    <link>https://dev.to/arshtechpro</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%2F3258664%2F7a2cc61a-0b4d-4cf8-884e-52f33905cac3.png</url>
      <title>DEV Community: ArshTechPro</title>
      <link>https://dev.to/arshtechpro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arshtechpro"/>
    <language>en</language>
    <item>
      <title>Firecrawl: A Practical Guide to Turning Websites into LLM-Ready Data</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Mon, 30 Nov 2026 19:23:33 +0000</pubDate>
      <link>https://dev.to/arshtechpro/firecrawl-a-practical-guide-to-turning-websites-into-llm-ready-data-3an8</link>
      <guid>https://dev.to/arshtechpro/firecrawl-a-practical-guide-to-turning-websites-into-llm-ready-data-3an8</guid>
      <description>&lt;p&gt;If you have ever tried to feed a website into an LLM, you know the pain. You write a scraper, it breaks on JavaScript-rendered pages, you add a headless browser, you fight rate limits and cookie banners, and then you still have to strip out navigation bars, footers, and ads before the content is usable.&lt;/p&gt;

&lt;p&gt;Firecrawl is an open source project that packages all of that into a single API. You give it a URL (or just a question), and you get back clean Markdown, HTML, or structured JSON that you can drop straight into a prompt, a vector database, or an agent.&lt;/p&gt;

&lt;p&gt;This guide covers what Firecrawl does, the endpoints you will actually use, working code in Python, Node.js, and cURL, and the things worth knowing before you put it into production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Firecrawl Is
&lt;/h2&gt;

&lt;p&gt;Firecrawl describes itself as knowledge infrastructure for AI agents. In practice it does three things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fetches web content reliably&lt;/strong&gt;, including JavaScript-heavy pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleans it up&lt;/strong&gt; into LLM-friendly output, with Markdown as the primary format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structures it&lt;/strong&gt; when you ask, by extracting JSON that matches a schema you define.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is one of the most popular open source projects in this space, with roughly 200k stars on GitHub at the time of writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three Ways to Run It
&lt;/h2&gt;

&lt;p&gt;This is the first decision you need to make, so it is worth getting clear on upfront.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Firecrawl Cloud&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The hosted API at firecrawl.dev&lt;/td&gt;
&lt;td&gt;Getting started fast, full feature set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Firecrawl Local&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A single binary that serves the v2 API on &lt;code&gt;localhost:3002&lt;/code&gt; and also works as an MCP server&lt;/td&gt;
&lt;td&gt;Local development, agents on your machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Self-hosted&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The full server from &lt;code&gt;apps/api&lt;/code&gt;, with its own queues, workers, and databases&lt;/td&gt;
&lt;td&gt;Teams that need to own the infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One important detail: not every feature is available everywhere. Locally, scraping returns Markdown, HTML, raw HTML, and links. Structured JSON, summaries, screenshots, and browser actions are Cloud features. Check this against your requirements before you commit to a deployment model.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Endpoints
&lt;/h2&gt;

&lt;p&gt;Here is the mental model. Each endpoint answers a different question.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Question it answers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scrape&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Give me the content of this one page."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Crawl&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Give me the content of this whole site."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Map&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"What URLs exist on this site?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Batch Scrape&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Give me the content of these 500 URLs."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Search&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Search the web and give me the full content of the results."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Interact&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Click, type, or navigate on a page I already scraped."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Agent&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Find this information. I do not know which URLs have it."&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Parse&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;"Convert this PDF, DOCX, or XLSX into Markdown or JSON."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Cloud API base URL is &lt;code&gt;https://api.firecrawl.dev/v2&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Official SDKs exist for most languages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Python&lt;/span&gt;
pip install firecrawl

&lt;span class="c"&gt;# Node.js&lt;/span&gt;
npm install firecrawl

&lt;span class="c"&gt;# Go&lt;/span&gt;
go get github.com/firecrawl/firecrawl/apps/go-sdk

&lt;span class="c"&gt;# Rust&lt;/span&gt;
cargo add firecrawl

&lt;span class="c"&gt;# Ruby&lt;/span&gt;
gem install firecrawl-sdk

&lt;span class="c"&gt;# .NET&lt;/span&gt;
dotnet add package firecrawl-sdk

&lt;span class="c"&gt;# PHP&lt;/span&gt;
composer require firecrawl/firecrawl-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also SDKs for Java (&lt;code&gt;com.firecrawl:firecrawl-java&lt;/code&gt; on Maven Central) and Elixir.&lt;/p&gt;

&lt;p&gt;You will want an API key from firecrawl.dev for real workloads. Keys start with &lt;code&gt;fc-&lt;/code&gt;. Store it in an environment variable rather than hardcoding it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;FIRECRAWL_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"fc-YOUR_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Your First Scrape
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;

&lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"fc-YOUR_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"markdown"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"html"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'firecrawl'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;FIRECRAWL_API_KEY&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://firecrawl.dev'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'markdown'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'html'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  cURL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST &lt;span class="s1"&gt;'https://api.firecrawl.dev/v2/scrape'&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $FIRECRAWL_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s1"&gt;'Content-Type: application/json'&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "url": "https://firecrawl.dev",
    "formats": ["markdown", "html"]
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every response also includes metadata such as &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;sourceURL&lt;/code&gt;, &lt;code&gt;statusCode&lt;/code&gt;, and &lt;code&gt;contentType&lt;/code&gt;, which is useful for logging and for citing sources in RAG pipelines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Output formats
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;formats&lt;/code&gt; parameter controls what you get back. The most useful ones are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;markdown&lt;/code&gt; for feeding content to an LLM&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;html&lt;/code&gt; and &lt;code&gt;rawHtml&lt;/code&gt; when you need the markup&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;links&lt;/code&gt; to get every link on the page&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;screenshot&lt;/code&gt; for a visual capture&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;summary&lt;/code&gt; for a short summary of the page&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;json&lt;/code&gt; for structured extraction (covered next)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Structured Extraction with JSON
&lt;/h2&gt;

&lt;p&gt;This is where Firecrawl saves the most code. Instead of writing CSS selectors that break the next time a site redesigns, you describe the data you want and let the model pull it out.&lt;/p&gt;

&lt;p&gt;Pass a &lt;code&gt;json&lt;/code&gt; object inside &lt;code&gt;formats&lt;/code&gt;, with a JSON Schema, a prompt, or both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;

&lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"fc-YOUR_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"company_mission"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"is_open_source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"boolean"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"company_mission"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Extract the company mission and whether the product is open source."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you skip the &lt;code&gt;schema&lt;/code&gt; and only send a &lt;code&gt;prompt&lt;/code&gt;, the model decides the output structure. That is handy for exploration, but use a schema in production so your downstream code gets a predictable shape.&lt;/p&gt;

&lt;p&gt;The raw request body looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"formats"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"company_mission"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"company_mission"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Extract the company mission from the page."&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Crawling an Entire Site
&lt;/h2&gt;

&lt;p&gt;Crawl follows links recursively and scrapes every page it finds. Always set a &lt;code&gt;limit&lt;/code&gt;, or a large site will burn through your credits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;crawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://docs.firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;poll_interval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;scrape_options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"formats"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"markdown"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;crawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://docs.firecrawl.dev'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;scrapeOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'markdown'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;crawl()&lt;/code&gt; method waits for the job to finish. For large sites, you do not want to block a request handler while that happens. Start the job and check on it separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start_crawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://docs.firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Later, from a worker, cron job, or webhook handler&lt;/span&gt;
&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_crawl_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Firecrawl also supports webhooks for asynchronous event delivery, which is the cleaner option once you are running crawls at scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mapping a Site Before You Crawl
&lt;/h2&gt;

&lt;p&gt;Map returns a list of URLs on a site without scraping them. It is fast and cheap, which makes it a good first step: map the site, filter the URLs you actually care about, then batch scrape only those.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Batch Scraping
&lt;/h2&gt;

&lt;p&gt;When you already have a list of URLs, batch scrape processes them in one job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;urls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"https://firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"https://docs.firecrawl.dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;batch_job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start_batch_scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_batch_scrape_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;batch_job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The map-then-batch pattern usually gives you more control and lower cost than a blind crawl.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search: Web Search with Full Content
&lt;/h2&gt;

&lt;p&gt;Most search APIs return titles and snippets. Firecrawl's search returns the full page content of the results, which is exactly what you need for grounding an LLM answer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"firecrawl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'firecrawl'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;scrapeOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'markdown'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Interacting with Pages
&lt;/h2&gt;

&lt;p&gt;Some content only appears after you click a button, fill in a search box, or log in. Firecrawl has two ways to handle that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Actions (run before scraping)
&lt;/h3&gt;

&lt;p&gt;Actions are a list of steps that run in the browser before the page is captured:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"markdown"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;actions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"wait"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"milliseconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"click"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"selector"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"a[href='/pricing']"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"wait"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"milliseconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"screenshot"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fullPage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Supported action types include &lt;code&gt;wait&lt;/code&gt;, &lt;code&gt;click&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt;, &lt;code&gt;press&lt;/code&gt;, and &lt;code&gt;screenshot&lt;/code&gt;. Add &lt;code&gt;wait&lt;/code&gt; steps between actions so the page has time to load.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interact (continue working on a scraped page)
&lt;/h3&gt;

&lt;p&gt;Interact is the newer approach, and the docs recommend it over actions for new work. You scrape a page, then send follow-up instructions in plain English:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://www.amazon.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"markdown"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;scrape_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scrape_id&lt;/span&gt;

&lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;interact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrape_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Search for iPhone 16 Pro Max"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;interact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;scrape_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Click on the first result and tell me the price"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stop_interaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrape_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember to call &lt;code&gt;stop_interaction&lt;/code&gt; when you are done, so the browser session is released.&lt;/p&gt;

&lt;h2&gt;
  
  
  Agent: When You Do Not Know the URL
&lt;/h2&gt;

&lt;p&gt;Every endpoint above needs you to know where the data lives. Agent does not. You describe what you want, optionally provide a schema, and it searches, navigates, and extracts on its own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Optional&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;

&lt;span class="n"&gt;firecrawl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Firecrawl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"fc-YOUR_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Founder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Full name of the founder"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Optional&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Role or position"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FoundersSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;founders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Founder&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"List of founders"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Find the founders of Firecrawl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;schema&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;FoundersSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"spark-2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;max_credits&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set &lt;code&gt;max_credits&lt;/code&gt;.&lt;/strong&gt; An autonomous agent can visit many pages. A cap keeps a vague prompt from turning into a surprise bill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;start_agent&lt;/code&gt; and &lt;code&gt;get_agent_status&lt;/code&gt;&lt;/strong&gt; for long-running jobs, the same way you would with crawls.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Parsing Documents
&lt;/h2&gt;

&lt;p&gt;Not everything is a web page. Firecrawl can convert PDFs, DOCX, XLSX, HTML, and similar files into Markdown or structured JSON. If your RAG pipeline ingests both websites and uploaded documents, this lets you use one tool for both instead of maintaining a separate PDF parser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Firecrawl with AI Agents and MCP
&lt;/h2&gt;

&lt;p&gt;If you use an AI coding assistant, you can give it web access through Firecrawl's MCP server.&lt;/p&gt;

&lt;p&gt;Run it locally with your API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;env &lt;span class="nv"&gt;FIRECRAWL_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;fc-YOUR_API_KEY npx -y firecrawl-mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or point your client at the hosted endpoint, which uses Streamable HTTP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://mcp.firecrawl.dev/v2/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is also a CLI that can install Firecrawl tools into supported agents such as Claude Code, Antigravity, and OpenCode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx -y firecrawl-cli@latest init --all --browser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are using Firecrawl Local, &lt;code&gt;firecrawl-local init&lt;/code&gt; registers it as an MCP server in Claude Code, Claude Desktop, Cursor, Windsurf, Gemini CLI, and Codex.&lt;/p&gt;

&lt;p&gt;Firecrawl also has integrations with platforms like Zapier, n8n, and Lovable if you are working in a no-code or low-code environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running It Locally
&lt;/h2&gt;

&lt;p&gt;Firecrawl Local is a single binary distributed through crates.io. You need Rust and a C compiler installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo install firecrawl-local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It serves the v2 API on port 3002, so you can point your SDK at &lt;code&gt;http://localhost:3002&lt;/code&gt; during development.&lt;/p&gt;

&lt;p&gt;By default, local scrapes that fail on your machine can fall back to Firecrawl Cloud. If you need everything to stay on your machine, for privacy or compliance reasons, turn that off:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;FIRECRAWL_CLOUD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;off
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Self-Hosting
&lt;/h2&gt;

&lt;p&gt;For full control, you can run the complete server yourself. The self-hosted setup uses Docker Compose with Redis, PostgreSQL, and a browser service. Kubernetes manifests and a Helm chart are available for larger deployments.&lt;/p&gt;

&lt;p&gt;The repository's &lt;code&gt;SELF_HOST.md&lt;/code&gt; file is the source of truth for the required services and environment variables. Read it before you start, because the setup involves more moving parts than the Cloud API.&lt;/p&gt;

&lt;p&gt;Keep in mind that some Cloud features are not part of the self-hosted server. For example, Alexandria, Firecrawl's catalog of 550+ data providers, is Cloud only.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things Worth Knowing Before Production
&lt;/h2&gt;

&lt;p&gt;These are the details that tend to catch people out.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Credits add up per feature, not per request
&lt;/h3&gt;

&lt;p&gt;A basic scrape costs 1 credit. Extras cost more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON extraction adds 4 credits per page&lt;/li&gt;
&lt;li&gt;PDF parsing costs 1 credit per PDF page&lt;/li&gt;
&lt;li&gt;Cached results still cost 1 credit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A crawl of 1,000 pages with JSON extraction is about 5,000 credits, not 1,000. Do the math before you launch a big job.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Results are cached by default
&lt;/h3&gt;

&lt;p&gt;Scrapes use a &lt;code&gt;maxAge&lt;/code&gt; cache that defaults to 2 days (172800000 ms) and caps at 7 days. That is great for speed and cost, but it means you may get a two-day-old copy of a page. If you need fresh content, for example for prices or stock levels, pass &lt;code&gt;maxAge: 0&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firecrawl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scrape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://example.com/pricing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;formats&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"markdown"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Always bound your jobs
&lt;/h3&gt;

&lt;p&gt;Set &lt;code&gt;limit&lt;/code&gt; on crawls and &lt;code&gt;max_credits&lt;/code&gt; on agents. An unbounded crawl on a large site can consume your monthly allowance in minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Prefer map plus batch over a blind crawl
&lt;/h3&gt;

&lt;p&gt;Mapping first lets you filter out tag pages, pagination, and other noise before you pay to scrape them.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Use a schema for anything downstream code depends on
&lt;/h3&gt;

&lt;p&gt;Prompt-only extraction is flexible, but the output shape can vary between pages. A JSON Schema (or a Pydantic model) gives you consistent, typed results.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Do not block on long jobs
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;start_crawl&lt;/code&gt;, &lt;code&gt;start_batch_scrape&lt;/code&gt;, and &lt;code&gt;start_agent&lt;/code&gt; with status checks or webhooks in production instead of the blocking helpers.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. There is a free tier for experimenting
&lt;/h3&gt;

&lt;p&gt;Firecrawl Keyless provides 1,000 free credits per month without an API key or signup, which is enough to prototype. An API key gives you higher rate limits.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Check the license
&lt;/h3&gt;

&lt;p&gt;The main project is licensed under &lt;strong&gt;AGPL-3.0&lt;/strong&gt;, while the SDKs and some UI components are &lt;strong&gt;MIT&lt;/strong&gt;. Using the Cloud API or the SDKs in your app is straightforward. If you plan to modify and self-host the server as part of a service you offer to others, review the AGPL obligations with your team first.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Scrape responsibly
&lt;/h3&gt;

&lt;p&gt;Firecrawl makes collecting web data easy, but the usual rules still apply. Respect each site's terms of service and robots.txt, avoid hammering small sites, and be careful with personal data.&lt;/p&gt;

&lt;p&gt;Useful links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/firecrawl/firecrawl" rel="noopener noreferrer"&gt;github.com/firecrawl/firecrawl&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Self-hosting guide: &lt;code&gt;SELF_HOST.md&lt;/code&gt; in the repository&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>[iOS] PhotoKit Mistakes That Only Show Up With a Real Photo Library</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Sat, 21 Nov 2026 22:52:28 +0000</pubDate>
      <link>https://dev.to/arshtechpro/photokit-mistakes-that-only-show-up-with-a-real-photo-library-1g09</link>
      <guid>https://dev.to/arshtechpro/photokit-mistakes-that-only-show-up-with-a-real-photo-library-1g09</guid>
      <description>&lt;p&gt;PhotoKit code that works perfectly in the simulator, with its handful of sample photos, often falls apart on a real iPhone with 30,000 photos, half of them in iCloud.&lt;/p&gt;

&lt;p&gt;Here are nine mistakes that are easy to make and hard to spot until real users hit them, and how to avoid each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Ignoring limited access
&lt;/h2&gt;

&lt;p&gt;Since iOS 14, users can grant access to &lt;strong&gt;selected photos only&lt;/strong&gt;. Many apps treat &lt;code&gt;.limited&lt;/code&gt; like &lt;code&gt;.denied&lt;/code&gt;, or like &lt;code&gt;.authorized&lt;/code&gt;. Both are wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;PHPhotoLibrary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestAuthorization&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readWrite&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;authorized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;                  &lt;span class="c1"&gt;// full library&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;limited&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="k"&gt;break&lt;/span&gt;                  &lt;span class="c1"&gt;// only the photos the user picked: say so in your UI&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;denied&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;restricted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;         &lt;span class="c1"&gt;// explain why, and link to Settings&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notDetermined&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;
&lt;span class="nd"&gt;@unknown&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With limited access, give users a way to change their selection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="nc"&gt;PHPhotoLibrary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shared&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;presentLimitedLibraryPicker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;viewController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't want iOS to prompt users to add more photos every time the app launches, add &lt;code&gt;PHPhotoLibraryPreventAutomaticLimitedAccessAlert&lt;/code&gt; = &lt;code&gt;YES&lt;/code&gt; to Info.plist and offer your own button instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Turning the fetch result into an array
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;PHFetchResult&lt;/code&gt; is lazy. It doesn't load 30,000 &lt;code&gt;PHAsset&lt;/code&gt; objects until you ask for them. This line throws that away:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="c1"&gt;//  Loads every asset into memory at once&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Index into the fetch result when you need an asset instead. A collection view only needs &lt;code&gt;result.count&lt;/code&gt; and &lt;code&gt;result.object(at: indexPath.item)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Asking for thumbnails in points instead of pixels
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;targetSize&lt;/code&gt; is in &lt;strong&gt;pixels&lt;/strong&gt;. On a 3× device, a 100-point cell needs a 300-pixel image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;UIScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scale&lt;/span&gt;   &lt;span class="c1"&gt;// or the trait collection's displayScale&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;targetSize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CGSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cellSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cellSize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Too small and the grid looks blurry. Too large (for example &lt;code&gt;PHImageManagerMaximumSize&lt;/code&gt;) and scrolling stutters and memory climbs.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Not expecting the completion handler to run twice
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;.opportunistic&lt;/code&gt; delivery (the default), PhotoKit can call your handler &lt;strong&gt;twice&lt;/strong&gt;: first with a fast, low-quality image, then with the final one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="n"&gt;manager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;asset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targetSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contentMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aspectFill&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;isDegraded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;PHImageResultIsDegradedKey&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kt"&gt;Bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="c1"&gt;// Show the image either way, but only treat it as final when isDegraded == false.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you hide a loading spinner, record analytics or save the result on the first call, you'll be working with the placeholder.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Forgetting to cancel requests on cell reuse
&lt;/h2&gt;

&lt;p&gt;Scroll quickly through a grid and every cell fires a request. Without cancelling, images arrive for cells that have already been reused, and the wrong photo flashes into place.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;override&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;prepareForReuse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepareForReuse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requestID&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;imageManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cancelImageRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;imageView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
    &lt;span class="n"&gt;representedAssetID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also check, in the completion handler, that the cell still shows the same asset (&lt;code&gt;representedAssetID == asset.localIdentifier&lt;/code&gt;) before setting the image.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Not using &lt;code&gt;PHCachingImageManager&lt;/code&gt; for grids
&lt;/h2&gt;

&lt;p&gt;For scrolling grids, &lt;code&gt;PHCachingImageManager&lt;/code&gt; can prepare thumbnails before cells appear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="n"&gt;cachingManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startCachingImages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;upcomingAssets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targetSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contentMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aspectFill&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;cachingManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stopCachingImages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;assetsThatScrolledAway&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targetSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;contentMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aspectFill&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the cached range as the user scrolls (Apple's sample code compares the old and new visible rects), and use the &lt;strong&gt;same&lt;/strong&gt; &lt;code&gt;targetSize&lt;/code&gt; and options for caching and requesting, or the cache won't be used.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Treating iCloud photos as if they're on the device
&lt;/h2&gt;

&lt;p&gt;With "Optimize iPhone Storage" turned on, many originals are only in iCloud. By default, PhotoKit &lt;strong&gt;won't&lt;/strong&gt; download them, and your request returns &lt;code&gt;nil&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PHImageRequestOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isNetworkAccessAllowed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;progressHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    &lt;span class="c1"&gt;// Runs on a background queue: dispatch to the main queue to update the UI&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Decide on purpose when downloading is worth it. Opening a photo full-screen: yes. Building a grid of thousands of thumbnails: no, because local thumbnails usually exist anyway.&lt;/p&gt;

&lt;p&gt;Two things to design for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The user can tap "Don't Allow".&lt;/strong&gt; The call then throws, so treat that as a normal outcome, not an error message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deleted photos go to Recently Deleted&lt;/strong&gt; and stay there for up to 30 days, so the storage isn't freed straight away. If your app shows "space saved", tell users to empty Recently Deleted if they need the space now.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bonus: test with a real library
&lt;/h2&gt;

&lt;p&gt;The simulator's sample photos hide almost every problem above. Test on a device with tens of thousands of photos, iCloud Photos turned on with "Optimize iPhone Storage", and limited access granted. That's where the bugs are.&lt;/p&gt;




&lt;p&gt;The app that helped learn this tips &lt;a href="https://cleankit.pages.dev/" rel="noopener noreferrer"&gt;Clean Kit&lt;/a&gt;, an iPhone photo and storage cleaner that runs entirely on-device. It's on the App Store.&lt;br&gt;
For the curious, the app has a set of &lt;a href="https://cleankit.pages.dev/guides" rel="noopener noreferrer"&gt;iPhone storage guides&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>swiftui</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Arcane: A Developer's Guide to the Open-Source Docker Management UI</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Wed, 18 Nov 2026 11:20:47 +0000</pubDate>
      <link>https://dev.to/arshtechpro/arcane-a-developers-guide-to-the-open-source-docker-management-ui-4g76</link>
      <guid>https://dev.to/arshtechpro/arcane-a-developers-guide-to-the-open-source-docker-management-ui-4g76</guid>
      <description>&lt;p&gt;If you run Docker on more than one machine, you probably know the routine: SSH into a box, &lt;code&gt;cd&lt;/code&gt; into a folder, &lt;code&gt;docker compose ps&lt;/code&gt;, tail some logs, repeat on the next server. It works, but it does not scale well once you have a handful of hosts and a few dozen stacks.&lt;/p&gt;

&lt;p&gt;Arcane is an open-source, self-hosted web UI for Docker and Docker Compose that tries to fix that without making you learn a new orchestration model. It sits on top of the Docker you already have and gives you a dashboard, a Compose editor, logs, a terminal, and multi-host management from one place.&lt;/p&gt;

&lt;p&gt;This article covers what Arcane is, how to get it running, and the details that matter when you move past "it works on my laptop."&lt;/p&gt;

&lt;h2&gt;
  
  
  What Arcane is (and is not)
&lt;/h2&gt;

&lt;p&gt;Arcane is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A web UI for Docker and Compose.&lt;/strong&gt; Containers, images, volumes, networks, and Compose "projects" (stacks) are all first-class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-hosted, single container.&lt;/strong&gt; You run it next to your workloads and talk to Docker through the socket (or a socket proxy).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open source under BSD-3-Clause.&lt;/strong&gt; No paid tiers, no feature gating.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built with Go and SvelteKit.&lt;/strong&gt; The backend is Go, the frontend is SvelteKit with TypeScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Arcane is not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;An orchestrator.&lt;/strong&gt; It does not replace Kubernetes or Swarm scheduling. It manages Docker and Compose the way you already use them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A new config format.&lt;/strong&gt; Your stacks stay as normal &lt;code&gt;compose.yaml&lt;/code&gt; files on disk. If you stop using Arcane tomorrow, &lt;code&gt;docker compose up -d&lt;/code&gt; still works.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is the main reason a lot of developers are trying it. There is no lock-in. Arcane reads and writes standard Compose files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature overview
&lt;/h2&gt;

&lt;p&gt;Here is what you get out of the box:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Containers&lt;/td&gt;
&lt;td&gt;Start, stop, restart, inspect, real-time logs, web terminal, process list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Compose projects&lt;/td&gt;
&lt;td&gt;Create and edit stacks in the browser, deploy, pull, redeploy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Images&lt;/td&gt;
&lt;td&gt;Browse, pull, prune, browse registry repos and tags, build workspace&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Networks&lt;/td&gt;
&lt;td&gt;Management plus an interactive network topology view&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-host&lt;/td&gt;
&lt;td&gt;Manage remote Docker hosts through agents (direct or edge mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitOps&lt;/td&gt;
&lt;td&gt;Point Arcane at a Git repo and sync stacks from it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Updates&lt;/td&gt;
&lt;td&gt;Tag-based auto-updates with an optional cool-down delay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security&lt;/td&gt;
&lt;td&gt;Trivy vulnerability scanning, image patching with Copacetic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;Local users, OIDC/SSO, passkeys, MFA, role mappings&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ops&lt;/td&gt;
&lt;td&gt;Scheduled volume and S3 backups, OpenTelemetry export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automation&lt;/td&gt;
&lt;td&gt;REST API and a Go-based CLI (&lt;code&gt;arcane-cli&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtimes&lt;/td&gt;
&lt;td&gt;Docker, plus Podman (rootful, rootless, and quadlets)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Quick start
&lt;/h2&gt;

&lt;p&gt;You need Docker and Docker Compose on the host.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Generate an encryption key
&lt;/h3&gt;

&lt;p&gt;Arcane requires a 32-byte &lt;code&gt;ENCRYPTION_KEY&lt;/code&gt;. Either of these works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl rand -hex 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run --rm ghcr.io/getarcaneapp/manager:v2 /app/arcane generate secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Create &lt;code&gt;compose.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;arcane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/getarcaneapp/manager:v2&lt;/span&gt;
    &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arcane&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;unless-stopped&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"3552:3552"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;APP_URL=http://localhost:3552&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ENCRYPTION_KEY=replace-with-your-generated-key&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;PROJECTS_DIRECTORY=/opt/stacks&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;TZ=UTC&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/var/run/docker.sock:/var/run/docker.sock&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;arcane-data:/app/data&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/opt/stacks:/opt/stacks&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;arcane-data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Start it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;http://&amp;lt;your-host&amp;gt;:3552&lt;/code&gt; and log in with the default credentials:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username: &lt;code&gt;arcane&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Password: &lt;code&gt;arcane-admin&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will be forced to change the password on first login.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things developers should know
&lt;/h2&gt;

&lt;p&gt;The quick start gets you running. These are the details that save you time later.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Use the current image name and pin &lt;code&gt;v2&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The image moved from &lt;code&gt;ghcr.io/getarcaneapp/arcane&lt;/code&gt; to &lt;code&gt;ghcr.io/getarcaneapp/manager&lt;/code&gt;. Many older blog posts and templates still use the old name. Official mirrors also exist on Docker Hub (&lt;code&gt;getarcaneapp/manager&lt;/code&gt;) and Quay (&lt;code&gt;quay.io/getarcaneapp/manager&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Pin the &lt;code&gt;v2&lt;/code&gt; tag for anything you care about. Avoid &lt;code&gt;latest&lt;/code&gt; and any beta tags in production.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Keep host and container paths identical for stacks
&lt;/h3&gt;

&lt;p&gt;Notice the stacks volume above: &lt;code&gt;/opt/stacks:/opt/stacks&lt;/code&gt;. Compose files often use relative paths for bind mounts (&lt;code&gt;./data:/data&lt;/code&gt;). When Arcane runs &lt;code&gt;docker compose&lt;/code&gt; from inside its container, those paths are resolved against the Docker host, not the Arcane container.&lt;/p&gt;

&lt;p&gt;Arcane can translate mismatched paths now, but mounting the same path on both sides is still the recommended setup and avoids surprises. &lt;code&gt;PROJECTS_DIRECTORY&lt;/code&gt; also accepts a &lt;code&gt;&amp;lt;containerPath&amp;gt;:&amp;lt;hostPath&amp;gt;&lt;/code&gt; form if you need them to differ.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Mounting the Docker socket is root-equivalent
&lt;/h3&gt;

&lt;p&gt;Anything with access to &lt;code&gt;/var/run/docker.sock&lt;/code&gt; can effectively control the host. That is true for Arcane and for every other Docker UI.&lt;/p&gt;

&lt;p&gt;For hardened setups, put a socket proxy in front of Docker and point Arcane at it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;DOCKER_HOST=tcp://docker-socket-proxy:2375&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then remove the socket mount from the Arcane service. Two common proxies are &lt;code&gt;wollomatic/socket-proxy&lt;/code&gt; (deny-by-default) and &lt;code&gt;Tecnativa/docker-socket-proxy&lt;/code&gt;. Take the exact allow-list from Arcane's socket proxy docs rather than guessing.&lt;/p&gt;

&lt;p&gt;One gotcha: if you use &lt;code&gt;wollomatic/socket-proxy&lt;/code&gt; with &lt;code&gt;-allowfrom&lt;/code&gt;, include &lt;code&gt;arcane-upgrader&lt;/code&gt; as well as &lt;code&gt;arcane&lt;/code&gt;. Self-upgrades run through a helper with that alias and will fail without it.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Every secret supports &lt;code&gt;_FILE&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Any sensitive variable can be read from a file by adding &lt;code&gt;_FILE&lt;/code&gt;. This plays well with Docker secrets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ENCRYPTION_KEY_FILE=/run/secrets/arcane_encryption_key&lt;/span&gt;
&lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;arcane_encryption_key&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also note that &lt;code&gt;JWT_SECRET&lt;/code&gt; from older guides is no longer used in 2.x. Arcane generates and stores its own session signing key. If you still set &lt;code&gt;JWT_SECRET&lt;/code&gt;, you just get a warning at startup, so remove it.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Behind a reverse proxy, set &lt;code&gt;TRUSTED_PROXIES&lt;/code&gt; and &lt;code&gt;APP_URL&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;If Arcane sits behind Nginx, Traefik, Caddy, or a Cloudflare Tunnel:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set &lt;code&gt;APP_URL&lt;/code&gt; to the public URL (for example &lt;code&gt;https://arcane.example.com&lt;/code&gt;, no port).&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;TRUSTED_PROXIES&lt;/code&gt; to the CIDR of your proxy. Without it, client IPs in logs and rate limiting will be wrong.&lt;/li&gt;
&lt;li&gt;Make sure WebSockets are passed through. Logs and the terminal depend on them. In Nginx that means &lt;code&gt;proxy_http_version 1.1&lt;/code&gt; plus the &lt;code&gt;Upgrade&lt;/code&gt; and &lt;code&gt;Connection "upgrade"&lt;/code&gt; headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Minimal Nginx location block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;proxy_pass&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//127.0.0.1:3552;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_http_version&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="nc"&gt;Upgrade&lt;/span&gt; $&lt;span class="n"&gt;http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="nc"&gt;Connection&lt;/span&gt; &lt;span class="s2"&gt;"upgrade"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="nc"&gt;Host&lt;/span&gt; $&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="no"&gt;X&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Forwarded&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;For&lt;/span&gt; $&lt;span class="n"&gt;proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="no"&gt;X&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Forwarded&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Proto&lt;/span&gt; $&lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Arcane can also serve HTTPS itself with &lt;code&gt;TLS_ENABLED&lt;/code&gt;, &lt;code&gt;TLS_CERT_FILE&lt;/code&gt;, and &lt;code&gt;TLS_KEY_FILE&lt;/code&gt; if you prefer not to run a proxy.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Managing multiple hosts: direct vs edge agents
&lt;/h3&gt;

&lt;p&gt;To manage other servers, run the Arcane agent (&lt;code&gt;ghcr.io/getarcaneapp/agent&lt;/code&gt;) on each one. There are two modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Direct mode.&lt;/strong&gt; The manager connects to the agent on TCP port 3553. Simple, but the agent must be reachable from the manager.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge mode.&lt;/strong&gt; The agent dials out to the manager over mTLS. No inbound port is needed on the remote host, which makes it a good fit for machines behind NAT or a home router.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You do not need to write the agent config by hand. In the UI, go to &lt;strong&gt;Environments &amp;gt; Add Environment&lt;/strong&gt; and Arcane generates a token and a ready-to-paste Compose snippet.&lt;/p&gt;

&lt;p&gt;Edge agents support several transports through &lt;code&gt;EDGE_TRANSPORT&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;auto&lt;/code&gt; (default): gRPC tunnel with WebSocket fallback&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grpc&lt;/code&gt; or &lt;code&gt;websocket&lt;/code&gt;: force one tunnel type&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;poll&lt;/code&gt;: periodic check-in with no persistent tunnel, useful behind Cloudflare Tunnel or strict proxies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An agent in &lt;code&gt;poll&lt;/code&gt; mode shows as &lt;strong&gt;Standby&lt;/strong&gt; when idle. That is normal and means it is healthy.&lt;/p&gt;

&lt;p&gt;If you run Traefik in front of the manager with edge agents on &lt;code&gt;auto&lt;/code&gt; or &lt;code&gt;grpc&lt;/code&gt;, disable the entrypoint read timeout, otherwise tunnels drop after about 60 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. GitOps without a CI pipeline
&lt;/h3&gt;

&lt;p&gt;You can point Arcane at a Git repository that contains your Compose files and it will keep the stacks in sync. For small teams and home labs this is often enough to get a "push to deploy" flow without setting up webhooks or a CI runner. Use &lt;code&gt;SSH_KNOWN_HOSTS&lt;/code&gt; to pin host keys when cloning over SSH.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Auto-updates with a safety delay
&lt;/h3&gt;

&lt;p&gt;Arcane can update containers when a new image is published for the tag you track. To reduce the risk of pulling a compromised or broken image the minute it lands, you can set an update delay in hours.&lt;/p&gt;

&lt;p&gt;Per project, in your Compose file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;x-arcane&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;updater&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;72&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or per container, with a label:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;com.getarcaneapp.arcane.updater.delay=72&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A value of &lt;code&gt;0&lt;/code&gt; on a service opts it out of the delay.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Automate it: API and CLI
&lt;/h3&gt;

&lt;p&gt;Arcane exposes a REST API, and there is a Go CLI for scripting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go install github.com/getarcaneapp/arcane/cli/v2@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For automation, &lt;code&gt;ADMIN_STATIC_API_KEY&lt;/code&gt; lets you provision a fixed API key through the environment instead of creating one in the UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Use SSO if you share it with a team
&lt;/h3&gt;

&lt;p&gt;OIDC is configured under &lt;strong&gt;Settings &amp;gt; Authentication&lt;/strong&gt; or through environment variables (&lt;code&gt;OIDC_ENABLED&lt;/code&gt;, &lt;code&gt;OIDC_CLIENT_ID&lt;/code&gt;, &lt;code&gt;OIDC_CLIENT_SECRET&lt;/code&gt;, &lt;code&gt;OIDC_ISSUER_URL&lt;/code&gt;, &lt;code&gt;OIDC_SCOPES&lt;/code&gt;). The redirect URI is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://&amp;lt;your-arcane-url&amp;gt;/auth/oidc/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can map IdP group claims to Arcane roles with &lt;code&gt;OIDC_ROLE_MAPPINGS&lt;/code&gt;, including per-environment roles. If you ever lock yourself out, a local backup login is available at &lt;code&gt;/login/backup&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A small but common mistake: when you use the list form of &lt;code&gt;environment:&lt;/code&gt; in Compose, do not wrap OIDC values in quotes. The quotes become part of the value and discovery fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful environment variables
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ENCRYPTION_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Required 32-byte key for encrypting stored secrets&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;APP_URL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Public URL of the UI&lt;/td&gt;
&lt;td&gt;&lt;code&gt;http://localhost:3552&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PROJECTS_DIRECTORY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Where Compose projects live&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/app/data/projects&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DOCKER_HOST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Docker endpoint, use &lt;code&gt;tcp://&lt;/code&gt; for a socket proxy&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unix:///var/run/docker.sock&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;PUID&lt;/code&gt; / &lt;code&gt;PGID&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;User and group the app runs as&lt;/td&gt;
&lt;td&gt;&lt;code&gt;65532&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TRUSTED_PROXIES&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;CIDR of reverse proxies&lt;/td&gt;
&lt;td&gt;unset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DATABASE_URL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Database connection&lt;/td&gt;
&lt;td&gt;SQLite&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TLS_ENABLED&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Serve HTTPS directly&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LOG_LEVEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Log verbosity&lt;/td&gt;
&lt;td&gt;&lt;code&gt;info&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TZ&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Time zone&lt;/td&gt;
&lt;td&gt;system&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If the container cannot talk to the Docker socket because of permissions, either run it as root or add the host's &lt;code&gt;docker&lt;/code&gt; group ID with &lt;code&gt;group_add&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it compares
&lt;/h2&gt;

&lt;p&gt;Arcane overlaps with tools like Portainer, Dockge, and Komodo. A rough way to think about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Portainer&lt;/strong&gt; is the long-standing, broad option, with some features in paid editions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dockge&lt;/strong&gt; focuses narrowly on Compose stack editing on a single host.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Arcane&lt;/strong&gt; aims for a modern UI with Compose at the center, built-in multi-host agents, GitOps, security scanning, and SSO, all under a permissive open-source license with no paid tier.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best choice depends on how many hosts you run and how much you want built in. Arcane is easy to try side by side with whatever you use now, since it works on plain Compose files.&lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repository: &lt;a href="https://github.com/getarcaneapp/arcane" rel="noopener noreferrer"&gt;https://github.com/getarcaneapp/arcane&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try it, share your setup in the comments. I am curious how people are running it across multiple hosts.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
    <item>
      <title>AG-UI Explained: The Protocol That Connects AI Agents to Your Frontend</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Tue, 17 Nov 2026 09:52:04 +0000</pubDate>
      <link>https://dev.to/arshtechpro/ag-ui-explained-the-protocol-that-connects-ai-agents-to-your-frontend-2m00</link>
      <guid>https://dev.to/arshtechpro/ag-ui-explained-the-protocol-that-connects-ai-agents-to-your-frontend-2m00</guid>
      <description>&lt;p&gt;If you have built a chat UI on top of an AI agent, you have probably written the same glue code more than once: parse a custom stream format, figure out when a tool call starts and ends, keep some piece of state in sync between the backend and the browser, and then rewrite all of it when you switch agent frameworks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ag-ui-protocol/ag-ui" rel="noopener noreferrer"&gt;AG-UI&lt;/a&gt; (Agent-User Interaction Protocol) exists to remove that glue code. It is an open, MIT-licensed, event-based protocol that standardizes how an agent backend talks to a user-facing application.&lt;/p&gt;

&lt;p&gt;This article covers what you actually need to know to use it: the mental model, the request and event formats, a minimal server and client, and the gotchas that are easy to miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-paragraph summary
&lt;/h2&gt;

&lt;p&gt;Your frontend sends a single &lt;code&gt;POST&lt;/code&gt; request describing the conversation (messages, state, available frontend tools, context). Your agent responds with a stream of typed JSON events: run lifecycle, streamed text, streamed tool calls, and state updates. Any frontend that understands those events can talk to any backend that emits them. That is the whole idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where AG-UI fits next to MCP and A2A
&lt;/h2&gt;

&lt;p&gt;There are now several "agent protocols," and it helps to know which problem each one solves:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;Connects&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MCP&lt;/td&gt;
&lt;td&gt;Agent to tools and data&lt;/td&gt;
&lt;td&gt;Gives agents access to tools and resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A2A&lt;/td&gt;
&lt;td&gt;Agent to agent&lt;/td&gt;
&lt;td&gt;Lets agents communicate with each other&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AG-UI&lt;/td&gt;
&lt;td&gt;Agent to user-facing app&lt;/td&gt;
&lt;td&gt;Streams agent activity into a UI and takes user input back&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;They are complementary, not competing. A single agent might use MCP to call tools, A2A to delegate to another agent, and AG-UI to show all of that to a user.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mental model
&lt;/h2&gt;

&lt;p&gt;There are three pieces:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt; - your frontend. It uses something like &lt;code&gt;HttpAgent&lt;/code&gt; from &lt;code&gt;@ag-ui/client&lt;/code&gt;, or a higher-level library such as CopilotKit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent backend&lt;/strong&gt; - any agent framework (LangGraph, CrewAI, Mastra, Pydantic AI, Google ADK, and so on) or your own code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transport&lt;/strong&gt; - how events travel. The reference implementation uses HTTP with Server-Sent Events (SSE), but the protocol is transport-agnostic. WebSockets, webhooks, or a binary Protocol Buffers encoding also work.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each interaction is called a &lt;strong&gt;run&lt;/strong&gt;. Runs belong to a &lt;strong&gt;thread&lt;/strong&gt; (a conversation).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;threadId&lt;/code&gt; stays the same for the whole conversation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;runId&lt;/code&gt; is new for every request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The request: RunAgentInput
&lt;/h2&gt;

&lt;p&gt;Every run starts with the client sending a &lt;code&gt;RunAgentInput&lt;/code&gt; as the body of a &lt;code&gt;POST&lt;/code&gt; request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;RunAgentInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;threadId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;        &lt;span class="c1"&gt;// conversation ID, stable across runs&lt;/span&gt;
  &lt;span class="n"&gt;runId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;           &lt;span class="c1"&gt;// unique per run&lt;/span&gt;
  &lt;span class="n"&gt;parentRunId&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;    &lt;span class="c1"&gt;// optional, for branching&lt;/span&gt;
  &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;any&lt;/span&gt;              &lt;span class="c1"&gt;// shared app state the agent can read&lt;/span&gt;
  &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;     &lt;span class="c1"&gt;// conversation history&lt;/span&gt;
  &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Tool&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;           &lt;span class="c1"&gt;// tools the FRONTEND can execute&lt;/span&gt;
  &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;      &lt;span class="c1"&gt;// extra info: { description, value }&lt;/span&gt;
  &lt;span class="n"&gt;forwardedProps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;any&lt;/span&gt;     &lt;span class="c1"&gt;// anything else you want to pass through&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two fields deserve attention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tools&lt;/code&gt;&lt;/strong&gt; are tools provided by the client for this run. Backend tools (database queries, API calls) stay configured in your agent. Frontend tools are things only the UI can do: open a modal, ask the user to confirm, read the current selection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;context&lt;/code&gt;&lt;/strong&gt; is a simple way to give the agent information about what the user is looking at, without stuffing it into a message.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The response: a stream of events
&lt;/h2&gt;

&lt;p&gt;The backend replies with a stream of events. Every event has a &lt;code&gt;type&lt;/code&gt;, plus optional &lt;code&gt;timestamp&lt;/code&gt;, &lt;code&gt;rawEvent&lt;/code&gt;, and &lt;code&gt;metadata&lt;/code&gt;. The events fall into a handful of groups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lifecycle events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RUN_STARTED&lt;/code&gt;, &lt;code&gt;RUN_FINISHED&lt;/code&gt;, &lt;code&gt;RUN_ERROR&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;STEP_STARTED&lt;/code&gt;, &lt;code&gt;STEP_FINISHED&lt;/code&gt; (for multi-step agents, useful for progress indicators)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Text message events
&lt;/h3&gt;

&lt;p&gt;These follow a &lt;strong&gt;start, content, end&lt;/strong&gt; pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TEXT_MESSAGE_START&lt;/code&gt; with &lt;code&gt;messageId&lt;/code&gt; and &lt;code&gt;role: "assistant"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TEXT_MESSAGE_CONTENT&lt;/code&gt; with &lt;code&gt;messageId&lt;/code&gt; and a &lt;code&gt;delta&lt;/code&gt; (a chunk of text)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TEXT_MESSAGE_END&lt;/code&gt; with &lt;code&gt;messageId&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tool call events
&lt;/h3&gt;

&lt;p&gt;Same pattern, with arguments streamed as JSON fragments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TOOL_CALL_START&lt;/code&gt; with &lt;code&gt;toolCallId&lt;/code&gt; and &lt;code&gt;toolCallName&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TOOL_CALL_ARGS&lt;/code&gt; with &lt;code&gt;toolCallId&lt;/code&gt; and a &lt;code&gt;delta&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TOOL_CALL_END&lt;/code&gt; with &lt;code&gt;toolCallId&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TOOL_CALL_RESULT&lt;/code&gt; with &lt;code&gt;messageId&lt;/code&gt;, &lt;code&gt;toolCallId&lt;/code&gt;, and &lt;code&gt;content&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  State events
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;STATE_SNAPSHOT&lt;/code&gt; sends the full state object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;STATE_DELTA&lt;/code&gt; sends only the changes, as an array of &lt;a href="https://datatracker.ietf.org/doc/html/rfc6902" rel="noopener noreferrer"&gt;JSON Patch (RFC 6902)&lt;/a&gt; operations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MESSAGES_SNAPSHOT&lt;/code&gt; sends the full message history, useful for resyncing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Everything else
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;REASONING_*&lt;/code&gt; events for streaming model reasoning separately from the answer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ACTIVITY_SNAPSHOT&lt;/code&gt; and &lt;code&gt;ACTIVITY_DELTA&lt;/code&gt; for structured progress or activity UI.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CUSTOM&lt;/code&gt; (with &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt;) for application-specific events.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RAW&lt;/code&gt; for passing through events from an external system untouched.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You do not need all of these on day one. A working chat needs only five: &lt;code&gt;RUN_STARTED&lt;/code&gt;, &lt;code&gt;TEXT_MESSAGE_START&lt;/code&gt;, &lt;code&gt;TEXT_MESSAGE_CONTENT&lt;/code&gt;, &lt;code&gt;TEXT_MESSAGE_END&lt;/code&gt;, and &lt;code&gt;RUN_FINISHED&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like on the wire
&lt;/h2&gt;

&lt;p&gt;With SSE, a simple "Hello world" run is just this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data: {"type":"RUN_STARTED","threadId":"t1","runId":"r1"}

data: {"type":"TEXT_MESSAGE_START","messageId":"m1","role":"assistant"}

data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"m1","delta":"Hello "}

data: {"type":"TEXT_MESSAGE_CONTENT","messageId":"m1","delta":"world!"}

data: {"type":"TEXT_MESSAGE_END","messageId":"m1"}

data: {"type":"RUN_FINISHED","threadId":"t1","runId":"r1"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Readable, debuggable with &lt;code&gt;curl&lt;/code&gt;, and easy to produce from any language.&lt;/p&gt;

&lt;h2&gt;
  
  
  A minimal AG-UI server in Python
&lt;/h2&gt;

&lt;p&gt;Install the Python SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install ag-ui-protocol fastapi uvicorn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then write an endpoint that accepts &lt;code&gt;RunAgentInput&lt;/code&gt; and streams events back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responses&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;StreamingResponse&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ag_ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;RunAgentInput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RunStartedEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RunFinishedEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;RunErrorEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;TextMessageStartEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;TextMessageContentEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;TextMessageEndEvent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ag_ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encoder&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;EventEncoder&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/agent"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;RunAgentInput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# The encoder picks the output format based on the Accept header&lt;/span&gt;
    &lt;span class="n"&gt;encoder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;EventEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;accept&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"accept"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;event_stream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RunStartedEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;RUN_STARTED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;message_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TextMessageStartEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;TEXT_MESSAGE_START&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"assistant"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="c1"&gt;# Replace this loop with tokens from your LLM&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Hello "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"from "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"AG-UI!"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TextMessageContentEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;TEXT_MESSAGE_CONTENT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TextMessageEndEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;TEXT_MESSAGE_END&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RunFinishedEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;RUN_FINISHED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;input_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RunErrorEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;EventType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;RUN_ERROR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;StreamingResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;event_stream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;media_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;encoder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_content_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it with &lt;code&gt;uvicorn main:app --reload&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note that the Python SDK uses snake_case (&lt;code&gt;thread_id&lt;/code&gt;, &lt;code&gt;message_id&lt;/code&gt;) but serializes to camelCase on the wire, so a JavaScript client sees &lt;code&gt;threadId&lt;/code&gt; and &lt;code&gt;messageId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In practice, you often will not write this by hand. Many frameworks ship adapters that emit AG-UI events for you. Pydantic AI, for example, can expose an agent as an AG-UI endpoint directly, and LangGraph has the &lt;code&gt;@ag-ui/langgraph&lt;/code&gt; adapter.&lt;/p&gt;

&lt;h2&gt;
  
  
  A minimal client in TypeScript
&lt;/h2&gt;

&lt;p&gt;Install the client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install @ag-ui/client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Connect to the server and subscribe to events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;HttpAgent&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@ag-ui/client"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HttpAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:8000/agent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// headers: { Authorization: "Bearer ..." },&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Say hello"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;runAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;onTextMessageContentEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;onToolCallStartEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`\n[tool] ${event.toolCallName}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;onStateChanged&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\n[state]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;onRunFailed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Run failed:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what you did not have to do: parse SSE lines, buffer partial JSON for tool arguments, apply state patches, or track message history. &lt;code&gt;HttpAgent&lt;/code&gt; handles that and keeps &lt;code&gt;agent.messages&lt;/code&gt; and &lt;code&gt;agent.state&lt;/code&gt; up to date.&lt;/p&gt;

&lt;p&gt;The subscriber gives you hooks at two levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event-level&lt;/strong&gt;: &lt;code&gt;onTextMessageContentEvent&lt;/code&gt;, &lt;code&gt;onToolCallStartEvent&lt;/code&gt;, &lt;code&gt;onToolCallArgsEvent&lt;/code&gt;, &lt;code&gt;onToolCallEndEvent&lt;/code&gt;, &lt;code&gt;onToolCallResultEvent&lt;/code&gt;, &lt;code&gt;onStateSnapshotEvent&lt;/code&gt;, &lt;code&gt;onStateDeltaEvent&lt;/code&gt;, &lt;code&gt;onCustomEvent&lt;/code&gt;, and more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High-level&lt;/strong&gt;: &lt;code&gt;onMessagesChanged&lt;/code&gt; and &lt;code&gt;onStateChanged&lt;/code&gt;, which fire after the client has applied the changes. These are usually what you want for rendering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can attach a subscriber for a single run (as above) or permanently with &lt;code&gt;agent.subscribe(subscriber)&lt;/code&gt;, which returns an object with &lt;code&gt;unsubscribe()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared state: the feature that makes agents feel native
&lt;/h2&gt;

&lt;p&gt;Chat is only part of an agent UI. Often the agent is editing something the user can see: a document, a form, a trip itinerary, a list of search results. AG-UI handles this with bi-directional shared state.&lt;/p&gt;

&lt;p&gt;The client sends the current &lt;code&gt;state&lt;/code&gt; in &lt;code&gt;RunAgentInput&lt;/code&gt;. The agent sends updates back. For large state, sending the whole object on every change is wasteful, so you send a snapshot once and then deltas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"STATE_SNAPSHOT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"snapshot"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"itinerary"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Lisbon"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"days"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"STATE_DELTA"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"op"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"add"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/itinerary/days/-"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Old town walk"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client applies the patch and fires &lt;code&gt;onStateChanged&lt;/code&gt;, so your UI re-renders with the new day added while the agent is still working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontend tools and human-in-the-loop
&lt;/h2&gt;

&lt;p&gt;This is the part that is easiest to overlook and most useful in practice.&lt;/p&gt;

&lt;p&gt;When the client lists a tool in &lt;code&gt;tools&lt;/code&gt;, it is saying "I can run this, in the browser." The flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The client sends a run with a frontend tool, for example &lt;code&gt;confirmPurchase&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The agent decides to call it and streams &lt;code&gt;TOOL_CALL_START&lt;/code&gt;, &lt;code&gt;TOOL_CALL_ARGS&lt;/code&gt;, &lt;code&gt;TOOL_CALL_END&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The frontend executes the tool. This can be anything, including showing a dialog and waiting for the user to click "Approve."&lt;/li&gt;
&lt;li&gt;The frontend adds the result as a tool message and starts a new run. The agent continues from there.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;confirmPurchase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"confirmPurchase"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Ask the user to approve a purchase before it is placed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"number"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"item"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;runAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;confirmPurchase&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives you human-in-the-loop approval without any special protocol extension. The pause is just a tool call that the UI resolves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that are easy to get wrong
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pair your start and end events.&lt;/strong&gt; Every &lt;code&gt;TEXT_MESSAGE_START&lt;/code&gt; needs a matching &lt;code&gt;TEXT_MESSAGE_END&lt;/code&gt; with the same &lt;code&gt;messageId&lt;/code&gt;. The same applies to tool calls and &lt;code&gt;toolCallId&lt;/code&gt;. Clients rely on this pairing to know when a message is complete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do not send empty deltas.&lt;/strong&gt; &lt;code&gt;TEXT_MESSAGE_CONTENT.delta&lt;/code&gt; must be a non-empty string. Filter out empty chunks from your LLM stream before emitting them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tool arguments are streamed as string fragments.&lt;/strong&gt; Each &lt;code&gt;TOOL_CALL_ARGS.delta&lt;/code&gt; is a piece of a JSON string, not a parsed object. Only after &lt;code&gt;TOOL_CALL_END&lt;/code&gt; do you have complete, parseable arguments. The client SDK handles the buffering if you use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Always end a run.&lt;/strong&gt; Emit &lt;code&gt;RUN_FINISHED&lt;/code&gt; on success or &lt;code&gt;RUN_ERROR&lt;/code&gt; on failure. A stream that just stops leaves the UI spinning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep &lt;code&gt;threadId&lt;/code&gt; stable.&lt;/strong&gt; Generate it once per conversation and reuse it. Generate a fresh &lt;code&gt;runId&lt;/code&gt; per request. If you mix these up, server-side session handling and debugging tools get confused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Know which side owns each tool.&lt;/strong&gt; Backend tools are configured in the agent and never appear in &lt;code&gt;RunAgentInput.tools&lt;/code&gt;. Frontend tools are sent by the client per run. Mixing these up is a common source of "the agent called a tool nobody implemented."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use snapshots to recover.&lt;/strong&gt; If a client reconnects or gets out of sync, &lt;code&gt;STATE_SNAPSHOT&lt;/code&gt; and &lt;code&gt;MESSAGES_SNAPSHOT&lt;/code&gt; let the server reset it to a known-good state instead of trying to replay every delta.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consider the binary encoding for heavy traffic.&lt;/strong&gt; The encoder supports content negotiation. Clients that send &lt;code&gt;Accept: application/vnd.ag-ui.event+proto&lt;/code&gt; get Protocol Buffers instead of JSON over SSE, and it falls back to SSE when that is not supported.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ecosystem: what already speaks AG-UI
&lt;/h2&gt;

&lt;p&gt;You may not need to build an adapter yourself. According to the repository, integrations exist for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agent frameworks&lt;/strong&gt;: LangGraph, CrewAI, Microsoft Agent Framework, Google ADK, AWS Strands Agents, Mastra, Pydantic AI, Agno, LlamaIndex, AG2, and community integrations such as the Claude Agent SDK and Langroid. Others, including the OpenAI Agent SDK and Cloudflare Agents, are in progress.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocols and platforms&lt;/strong&gt;: A2A, Amazon Bedrock AgentCore, Oracle Agent Spec, and MCP Apps for generative UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SDKs&lt;/strong&gt;: TypeScript and Python as the core, plus Kotlin, Go, Dart, Java, Rust, Ruby, C++, and .NET.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clients&lt;/strong&gt;: CopilotKit, terminal clients, React Native, and chat platforms such as Slack and Microsoft Teams.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check the repository README for the current list, since it changes often.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;The fastest path is the scaffolding command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-ag-ui-app my-agent-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;&lt;a href="https://dojo.ag-ui.com" rel="noopener noreferrer"&gt;AG-UI Dojo&lt;/a&gt;&lt;/strong&gt;. It has small, focused examples (roughly 50 to 200 lines each) for agentic chat, shared state, generative UI, and human-in-the-loop, across many frameworks. Reading the source of one Dojo example is the quickest way to see a real event flow.&lt;/li&gt;
&lt;li&gt;Read the &lt;strong&gt;&lt;a href="https://docs.ag-ui.com" rel="noopener noreferrer"&gt;docs&lt;/a&gt;&lt;/strong&gt;, especially the events and types reference for your SDK language.&lt;/li&gt;
&lt;li&gt;If you are writing your own backend, start with the five core events above, test with &lt;code&gt;curl -N&lt;/code&gt;, and add tool calls and state once text streaming works.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Closing: &lt;br&gt;
If your team maintains more than one agent UI, or expects to change agent frameworks, standardizing on AG-UI now will save you a lot of rework later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/ag-ui-protocol/ag-ui" rel="noopener noreferrer"&gt;ag-ui-protocol/ag-ui&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>ChatGPT Stopped Recommending This App Overnight. The Culprit Was a Domain Move (and One Regex)</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Sat, 14 Nov 2026 21:32:05 +0000</pubDate>
      <link>https://dev.to/arshtechpro/chatgpt-stopped-recommending-this-app-overnight-the-culprit-was-a-domain-move-and-one-regex-5c3i</link>
      <guid>https://dev.to/arshtechpro/chatgpt-stopped-recommending-this-app-overnight-the-culprit-was-a-domain-move-and-one-regex-5c3i</guid>
      <description>&lt;p&gt;For weeks, ChatGPT was quietly acting as an iOS app's best salesperson, sending roughly a third of all its downloads. Then, almost overnight, it went silent.&lt;/p&gt;

&lt;p&gt;No bad review. No App Store penalty. No new version. Nothing in the app had changed.&lt;/p&gt;

&lt;p&gt;The website had moved to a new address. It was a routine, by-the-book migration, the kind that's usually forgotten by lunchtime. Within days, the app's biggest traffic source had dropped to close to zero, and total downloads were cut in half.&lt;/p&gt;

&lt;p&gt;Here's how a "harmless" domain move wiped out a ChatGPT traffic source, the one-line regex bug that quietly made it worse, and the checklist that would have prevented all of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "textbook" migration
&lt;/h2&gt;

&lt;p&gt;The app is a small iPhone utility with a marketing site: a homepage, feature pages, comparison pages and about a dozen how-to guides. The site was originally served from a Cloudflare &lt;strong&gt;Workers&lt;/strong&gt; subdomain (&lt;code&gt;something.workers.dev&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;In early October it was rebuilt with Astro and moved to a Cloudflare &lt;strong&gt;Pages&lt;/strong&gt; subdomain (&lt;code&gt;something.pages.dev&lt;/code&gt;). As part of the rebuild:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;canonical tags, &lt;code&gt;og:url&lt;/code&gt;, JSON-LD, the sitemap and &lt;code&gt;robots.txt&lt;/code&gt; all switched to the new host&lt;/li&gt;
&lt;li&gt;URLs changed shape: &lt;code&gt;/guides/foo.html&lt;/code&gt; became &lt;code&gt;/guides/foo&lt;/code&gt;, and &lt;code&gt;/guides/&lt;/code&gt; became &lt;code&gt;/guides&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;the old Workers host became a small redirect Worker that sends visitors to the new host&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On paper, it was flawless. In practice, it was about to go badly wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  The day the referrals stopped
&lt;/h2&gt;

&lt;p&gt;App Store Connect reports first-time downloads by source. One source is &lt;strong&gt;App Referrer&lt;/strong&gt;, meaning another app sent the user to the App Store, and ChatGPT appears there by name.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Period&lt;/th&gt;
&lt;th&gt;Share of downloads from App Referrer (mostly ChatGPT)&lt;/th&gt;
&lt;th&gt;Daily downloads&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Several weeks before the move&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;roughly a third&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;baseline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A couple of weeks after the move&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;close to zero&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;roughly half&lt;/strong&gt; of baseline&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;App Store search dipped only modestly, so the main loss was ChatGPT. The referrals stopped within days of the canonical change. (All figures here are rounded on purpose.)&lt;/p&gt;

&lt;p&gt;This is a correlation, not a controlled experiment. Still, no other change lined up: the listing, keywords and app version stayed the same through that window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why AI assistants punish a domain move harder than Google does
&lt;/h2&gt;

&lt;p&gt;ChatGPT's web answers rely heavily on &lt;strong&gt;Bing's index&lt;/strong&gt;. When a page that recommended the app was indexed under the old host, ChatGPT could find it, cite it and link to the App Store.&lt;/p&gt;

&lt;p&gt;After the move:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The old URLs told Bing "the real page is now elsewhere" (new canonicals and redirects).&lt;/li&gt;
&lt;li&gt;The new host was brand new to Bing: no history and no inbound links.&lt;/li&gt;
&lt;li&gt;Bing didn't hand the old pages' standing to the new host quickly. The old pages lost value, and the new ones had none yet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Google handled it a bit better and indexed the new homepage within a few weeks. Bing's URL Inspection showed something more worrying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Blocked&lt;/strong&gt; – URL cannot appear on Bing.&lt;br&gt;
"The inspected URL is known to Bing but has some issues which are preventing us from serving it."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;strong&gt;Live URL&lt;/strong&gt; test for the same page passed: "URL can be indexed by Bing", "No SEO/GEO issues found". So it wasn't a technical block. It was a quality or trust decision about a new, unlinked site, and the Bing dashboard said as much: &lt;em&gt;"Your site lacks inbound links from high-quality domains."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-line bug hiding in plain sight
&lt;/h2&gt;

&lt;p&gt;The redirect Worker on the old host looked roughly like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;TARGET&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://new-host.example'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Some pages must still be served in place (older app builds load them in a web view).&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;PROXIED_PAGES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'/privacy'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'/terms'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// "Assets" are proxied so the proxied pages can load CSS and images.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isAsset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/_astro/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;PROXIED_PAGES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;isAsset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TARGET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// served as 200&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TARGET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spot it? It's easy to miss. The "is it an asset?" regex matches &lt;strong&gt;any&lt;/strong&gt; file extension, including &lt;code&gt;.html&lt;/code&gt;. Every old &lt;code&gt;/guides/foo.html&lt;/code&gt; URL, which were exactly the URLs search engines had indexed, was &lt;strong&gt;proxied with a 200&lt;/strong&gt; instead of redirected with a 301.&lt;/p&gt;

&lt;p&gt;So the old host kept serving full copies of every page, while those copies' canonical tags pointed at the new host. To a crawler, that looks like two sites with the same content, one of them disowning itself. That's a good way to make a search engine distrust both.&lt;/p&gt;

&lt;p&gt;The fix is small: exclude HTML from the asset rule, and map old URL shapes straight to the final URL in &lt;strong&gt;one&lt;/strong&gt; hop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;isAsset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/_astro/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// /index.html → /, /guides/ → /guides, /guides/foo.html → /guides/foo&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;canonicalPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;\&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TARGET&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;canonicalPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A quick way to test every legacy URL, using the old sitemap from git history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; p&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  curl -s -o /dev/null -w &lt;span class="s2"&gt;"$p -&amp;gt; %{http_code} %{redirect_url}\n"&lt;/span&gt; &lt;span class="s2"&gt;"https://old-host.example$p"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; old-paths.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every line should show &lt;code&gt;301&lt;/code&gt; pointing at the matching new URL. Following the redirect (&lt;code&gt;curl -L&lt;/code&gt;) should end on a &lt;code&gt;200&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two more traps waiting in Search Console
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google Search Console showed "Couldn't fetch" for a sitemap that worked.&lt;/strong&gt; The sitemap returned &lt;code&gt;200&lt;/code&gt; with valid XML, even when fetched with a Googlebot user agent. The status stayed stuck with no "Last read" date for over a week. It's a known display quirk on new properties: the file is fine, Google just hasn't fetched it yet. Resubmitting with a query string (&lt;code&gt;sitemap-0.xml?v=2&lt;/code&gt;) creates a new entry, and &lt;code&gt;robots.txt&lt;/code&gt; should list the sitemap anyway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Request indexing" hit "Quota exceeded" on the very first click.&lt;/strong&gt; On new properties this happens often. Don't fight it: the sitemap and internal links from an already-indexed page do the same job without a quota.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The checklist that would have saved the traffic
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don't move unless you have to.&lt;/strong&gt; If the old address is indexed and cited, its history is an asset.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you move, move once, ideally to a domain you own.&lt;/strong&gt; Shared hosts like &lt;code&gt;*.pages.dev&lt;/code&gt; or &lt;code&gt;*.workers.dev&lt;/code&gt; start with little trust, and every later move resets it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redirect every old URL with a single 301 to its exact new equivalent.&lt;/strong&gt; Test the real legacy URLs (from the old sitemap in git), not just the homepage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never serve full copies of pages from the old host&lt;/strong&gt;, even by accident through an asset rule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set up Bing Webmaster Tools and Google Search Console before the move&lt;/strong&gt;, not after. Bing has a site-move tool, and you'll want the before-and-after data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use IndexNow&lt;/strong&gt; to tell Bing about changed URLs immediately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan for inbound links.&lt;/strong&gt; A new host with no backlinks may be crawled but not shown. Directory listings, launch sites and a few relevant articles help.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where it stands now
&lt;/h2&gt;

&lt;p&gt;The redirect fix is live, every legacy URL now returns a clean 301, a Bing review has been requested, and the backlink work has started. Recovery isn't guaranteed or quick. Search engines rebuild trust over weeks, not days. A follow-up will share what actually brought the traffic back.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The app in this story is &lt;a href="https://cleankit.pages.dev" rel="noopener noreferrer"&gt;Clean Kit&lt;/a&gt;, an iPhone photo and storage cleaner that runs entirely on-device. It's &lt;a href="https://apps.apple.com/app/apple-store/id6761145538?pt=128704456&amp;amp;ct=devto&amp;amp;mt=8" rel="noopener noreferrer"&gt;on the App Store&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
For the curious, the site in question has a set of &lt;a href="https://cleankit.pages.dev/guides" rel="noopener noreferrer"&gt;iPhone storage guides&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mobile</category>
      <category>webdev</category>
      <category>seo</category>
    </item>
    <item>
      <title>MuJoCo for Developers: A Practical Guide to Google DeepMind's Physics Engine</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Wed, 11 Nov 2026 06:59:38 +0000</pubDate>
      <link>https://dev.to/arshtechpro/mujoco-for-developers-a-practical-guide-to-google-deepminds-physics-engine-3po0</link>
      <guid>https://dev.to/arshtechpro/mujoco-for-developers-a-practical-guide-to-google-deepminds-physics-engine-3po0</guid>
      <description>&lt;p&gt;If you have trained a reinforcement learning agent to walk, looked at a robotics paper, or used Gymnasium's &lt;code&gt;HalfCheetah&lt;/code&gt; or &lt;code&gt;Humanoid&lt;/code&gt; environments, you have already used MuJoCo, possibly without knowing it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/google-deepmind/mujoco" rel="noopener noreferrer"&gt;MuJoCo&lt;/a&gt; (short for &lt;strong&gt;Mu&lt;/strong&gt;lti-&lt;strong&gt;Jo&lt;/strong&gt;int dynamics with &lt;strong&gt;Co&lt;/strong&gt;ntact) is an open-source physics engine maintained by Google DeepMind. It is built for fast and accurate simulation of articulated bodies (robots, animals, humans, mechanisms) interacting with their environment through contact.&lt;/p&gt;

&lt;p&gt;This guide covers what a developer actually needs to know to get productive with it: how to install it, how its data model works, how to run and visualize a simulation, and where the sharp edges are.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why MuJoCo matters
&lt;/h2&gt;

&lt;p&gt;A few things make MuJoCo stand out from game physics engines and other robotics simulators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy over spectacle.&lt;/strong&gt; It is designed for model-based control, optimization and research, where you need physics you can trust, not just physics that looks right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speed.&lt;/strong&gt; The core is written in C, uses preallocated memory, and avoids allocations during simulation. Stepping a model millions of times is normal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contact handling.&lt;/strong&gt; Contacts are solved with a convex optimization formulation, which makes it stable for grasping, walking and other contact-rich tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free and open source.&lt;/strong&gt; It is licensed under Apache 2.0, so you can use it in commercial and research projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A large ecosystem.&lt;/strong&gt; Gymnasium, dm_control, MuJoCo Playground, MuJoCo Menagerie and many robotics frameworks are built on top of it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;For most developers, Python is the starting point. The PyPI package ships with a copy of the MuJoCo library, so there is nothing else to download.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install mujoco
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check that it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -c &lt;span class="s2"&gt;"import mujoco; print(mujoco.__version__)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few practical notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The current README lists &lt;strong&gt;Python 3.11 or newer&lt;/strong&gt; for the bindings.&lt;/li&gt;
&lt;li&gt;Prebuilt binaries exist for Linux (x86-64 and AArch64), Windows (x86-64) and macOS (universal).&lt;/li&gt;
&lt;li&gt;Linux wheels target &lt;code&gt;manylinux2014&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If you want the C library directly, download a release from the &lt;a href="https://github.com/google-deepmind/mujoco/releases" rel="noopener noreferrer"&gt;GitHub releases page&lt;/a&gt;. Building from &lt;code&gt;main&lt;/code&gt; is possible, but the tip of &lt;code&gt;main&lt;/code&gt; can be unstable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The two core objects: MjModel and MjData
&lt;/h2&gt;

&lt;p&gt;This is the single most important concept to understand. MuJoCo splits a simulation into two structures:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Object&lt;/th&gt;
&lt;th&gt;What it holds&lt;/th&gt;
&lt;th&gt;Changes during simulation?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MjModel&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The description of the world: bodies, joints, masses, geometry, actuators, timestep, solver options&lt;/td&gt;
&lt;td&gt;No (treat it as constant)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MjData&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The current state and everything computed from it: positions, velocities, controls, forces, contacts, time&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You build one &lt;code&gt;MjModel&lt;/code&gt;, then create one or more &lt;code&gt;MjData&lt;/code&gt; objects from it. Because the state lives entirely in &lt;code&gt;MjData&lt;/code&gt;, you can run many independent simulations of the same model in parallel just by creating more &lt;code&gt;MjData&lt;/code&gt; instances.&lt;/p&gt;

&lt;p&gt;The most-used fields in &lt;code&gt;MjData&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;data.qpos&lt;/code&gt; – generalized positions (joint angles, free-body positions and orientations)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.qvel&lt;/code&gt; – generalized velocities&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.ctrl&lt;/code&gt; – control inputs for actuators (this is what your policy or controller writes to)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.time&lt;/code&gt; – simulation time&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.xpos&lt;/code&gt;, &lt;code&gt;data.xquat&lt;/code&gt; – global positions and orientations of bodies&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.contact&lt;/code&gt;, &lt;code&gt;data.ncon&lt;/code&gt; – active contacts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Describing a world with MJCF
&lt;/h2&gt;

&lt;p&gt;Models are usually written in &lt;strong&gt;MJCF&lt;/strong&gt;, MuJoCo's XML format. URDF files (common in ROS) can also be loaded, but MJCF exposes the full feature set.&lt;/p&gt;

&lt;p&gt;Here is a minimal scene: a floor, a light, and a box that falls onto the floor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;mujoco&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"falling_box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;timestep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.002"&lt;/span&gt; &lt;span class="na"&gt;gravity&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 -9.81"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;worldbody&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;light&lt;/span&gt; &lt;span class="na"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 3"&lt;/span&gt; &lt;span class="na"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 -1"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;geom&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"floor"&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"plane"&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"2 2 0.1"&lt;/span&gt; &lt;span class="na"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.8 0.8 0.8 1"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"box"&lt;/span&gt; &lt;span class="na"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;freejoint/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;geom&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"box"&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.1 0.1 0.1"&lt;/span&gt; &lt;span class="na"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0.2 0.4 0.8 1"&lt;/span&gt; &lt;span class="na"&gt;mass&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/worldbody&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/mujoco&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key MJCF building blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;worldbody&lt;/code&gt;&lt;/strong&gt; is the root of the kinematic tree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;body&lt;/code&gt;&lt;/strong&gt; elements nest inside each other to form a tree (a robot arm is a chain of nested bodies).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;joint&lt;/code&gt;&lt;/strong&gt; defines how a body moves relative to its parent (&lt;code&gt;hinge&lt;/code&gt;, &lt;code&gt;slide&lt;/code&gt;, &lt;code&gt;ball&lt;/code&gt;, or &lt;code&gt;freejoint&lt;/code&gt; for a body that moves freely in 3D).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;geom&lt;/code&gt;&lt;/strong&gt; defines shape for collision and rendering, and contributes mass and inertia.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;actuator&lt;/code&gt;&lt;/strong&gt; defines motors, position servos and other force generators that you drive through &lt;code&gt;data.ctrl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sensor&lt;/code&gt;&lt;/strong&gt; defines measurements (joint positions, touch, IMU readings and so on) written to &lt;code&gt;data.sensordata&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Your first simulation in Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;

&lt;span class="no"&gt;XML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"""
&amp;lt;mujoco&amp;gt;
  &amp;lt;worldbody&amp;gt;
    &amp;lt;light pos="0 0 3" dir="0 0 -1"/&amp;gt;
    &amp;lt;geom type="plane" size="2 2 0.1"/&amp;gt;
    &amp;lt;body name="box" pos="0 0 1"&amp;gt;
      &amp;lt;freejoint/&amp;gt;
      &amp;lt;geom type="box" size="0.1 0.1 0.1" mass="1"/&amp;gt;
    &amp;lt;/body&amp;gt;
  &amp;lt;/worldbody&amp;gt;
&amp;lt;/mujoco&amp;gt;
"""&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_xml_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;XML&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Simulate 2 seconds of physics&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mj_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Time:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Box height:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"box"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is happening:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;from_xml_string&lt;/code&gt; compiles the XML into an &lt;code&gt;MjModel&lt;/code&gt;. Use &lt;code&gt;from_xml_path&lt;/code&gt; for files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MjData(model)&lt;/code&gt; allocates state for that model.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mj_step&lt;/code&gt; advances the simulation by one timestep (&lt;code&gt;model.opt.timestep&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.body("box")&lt;/code&gt; is named access, which saves you from tracking integer indices.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two other functions you will use constantly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mujoco.mj_resetData(model, data)&lt;/code&gt; resets the state to its initial values.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mujoco.mj_forward(model, data)&lt;/code&gt; computes all derived quantities (positions, contacts, sensor values) for the current state without advancing time. Call it after you manually set &lt;code&gt;qpos&lt;/code&gt; or &lt;code&gt;qvel&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Controlling a robot
&lt;/h2&gt;

&lt;p&gt;Actuators turn values in &lt;code&gt;data.ctrl&lt;/code&gt; into forces. Here is a single pendulum with a motor at the hinge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;

&lt;span class="no"&gt;XML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"""
&amp;lt;mujoco&amp;gt;
  &amp;lt;option timestep="0.002"/&amp;gt;
  &amp;lt;worldbody&amp;gt;
    &amp;lt;body name="pole" pos="0 0 1"&amp;gt;
      &amp;lt;joint name="hinge" type="hinge" axis="0 1 0" damping="0.1"/&amp;gt;
      &amp;lt;geom type="capsule" fromto="0 0 0 0 0 -0.5" size="0.03" mass="1"/&amp;gt;
    &amp;lt;/body&amp;gt;
  &amp;lt;/worldbody&amp;gt;
  &amp;lt;actuator&amp;gt;
    &amp;lt;motor name="torque" joint="hinge" gear="1" ctrlrange="-5 5"/&amp;gt;
  &amp;lt;/actuator&amp;gt;
&amp;lt;/mujoco&amp;gt;
"""&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_xml_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;XML&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;  &lt;span class="c1"&gt;# 45 degrees&lt;/span&gt;
&lt;span class="n"&gt;kp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;20.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.0&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;angle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;joint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hinge"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qpos&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;velocity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;joint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hinge"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qvel&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ctrl&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kp&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;kd&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;velocity&lt;/span&gt;  &lt;span class="c1"&gt;# simple PD controller&lt;/span&gt;
    &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mj_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Final angle: {np.degrees(data.joint('hinge').qpos[0]):.1f} degrees"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pattern is always the same: read state from &lt;code&gt;data&lt;/code&gt;, compute a control, write it to &lt;code&gt;data.ctrl&lt;/code&gt;, call &lt;code&gt;mj_step&lt;/code&gt;. A reinforcement learning environment is this loop with a reward function around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Visualizing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Interactive viewer
&lt;/h3&gt;

&lt;p&gt;The quickest way to inspect any model file is the built-in viewer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python -m mujoco.viewer --mjcf=path/to/model.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To watch your own simulation loop, use the passive viewer. It runs your code and renders alongside it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;viewer&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_xml_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"model.xml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;viewer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch_passive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;viewer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;viewer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;step_start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mj_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;viewer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# Keep roughly real-time&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;opt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;timestep&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;step_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On macOS, &lt;code&gt;launch_passive&lt;/code&gt; must be run with &lt;code&gt;mjpython&lt;/code&gt; (installed with the package) instead of &lt;code&gt;python&lt;/code&gt;, because macOS requires GUI work on the main thread.&lt;/p&gt;

&lt;h3&gt;
  
  
  Offscreen rendering
&lt;/h3&gt;

&lt;p&gt;For datasets, videos or vision-based policies, render to NumPy arrays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;renderer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Renderer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;480&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;640&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mj_forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update_scene&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pixels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;renderer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# shape (480, 640, 3), dtype uint8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a headless Linux server, set the rendering backend before importing MuJoCo, for example &lt;code&gt;MUJOCO_GL=egl&lt;/code&gt; (GPU) or &lt;code&gt;MUJOCO_GL=osmesa&lt;/code&gt; (software).&lt;/p&gt;

&lt;h2&gt;
  
  
  Editing models in code with MjSpec
&lt;/h2&gt;

&lt;p&gt;Writing XML by hand gets tedious when you need to generate variations (different terrain, randomized objects, procedurally built robots). &lt;code&gt;MjSpec&lt;/code&gt; lets you build and modify models programmatically and then compile them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;

&lt;span class="n"&gt;spec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjSpec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;worldbody&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_geom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mjtGeom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mjGEOM_PLANE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;worldbody&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"ball_{i}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_freejoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_geom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mjtGeom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mjGEOM_SPHERE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also load an existing XML with &lt;code&gt;mujoco.MjSpec.from_file(...)&lt;/code&gt;, change it, recompile, and even export it back to XML with &lt;code&gt;spec.to_xml()&lt;/code&gt;. The official &lt;a href="https://colab.research.google.com/github/google-deepmind/mujoco/blob/main/python/mjspec.ipynb" rel="noopener noreferrer"&gt;Model Editing notebook&lt;/a&gt; walks through this in depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling up: MJX and MuJoCo Warp
&lt;/h2&gt;

&lt;p&gt;Modern robot learning often needs thousands of simulations in parallel. MuJoCo offers two GPU-oriented options alongside the standard C engine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MJX (MuJoCo XLA)&lt;/strong&gt; reimplements MuJoCo in JAX. You get &lt;code&gt;jit&lt;/code&gt; compilation, &lt;code&gt;vmap&lt;/code&gt; for batching thousands of environments, and automatic differentiation through the physics step. It runs on GPU and TPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MuJoCo Warp&lt;/strong&gt; is a GPU implementation built on NVIDIA Warp, developed with NVIDIA and officially released in MuJoCo 3.5.0. It targets high throughput on NVIDIA GPUs, especially for contact-heavy scenes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A minimal MJX example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;jax&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mjx&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mujoco&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MjModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_xml_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"model.xml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mjx_model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mjx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@jax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vmap&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;batched_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qpos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mjx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;make_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mjx_model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qpos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;qpos&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;mjx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mjx_model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;jit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;batched_step&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;qpos_batch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;jax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;numpy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nq&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qpos_batch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 4096 simulations in one call&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A rule of thumb: use the standard C engine for single simulations, debugging and CPU work; use MJX if you live in the JAX ecosystem or need gradients; use MuJoCo Warp for maximum GPU throughput. Not every feature is supported in every backend, so check the MJX and Warp docs for your model's features.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ecosystem around MuJoCo
&lt;/h2&gt;

&lt;p&gt;You rarely need to start from scratch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/google-deepmind/mujoco_menagerie" rel="noopener noreferrer"&gt;MuJoCo Menagerie&lt;/a&gt;&lt;/strong&gt; – a curated collection of high-quality robot models (arms, quadrupeds, humanoids, hands) ready to load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/google-deepmind/mujoco_playground" rel="noopener noreferrer"&gt;MuJoCo Playground&lt;/a&gt;&lt;/strong&gt; – GPU-accelerated environments and training pipelines for locomotion and manipulation, including sim-to-real work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://gymnasium.farama.org/environments/mujoco/" rel="noopener noreferrer"&gt;Gymnasium&lt;/a&gt;&lt;/strong&gt; – the standard RL benchmark environments (&lt;code&gt;Ant&lt;/code&gt;, &lt;code&gt;Hopper&lt;/code&gt;, &lt;code&gt;Humanoid&lt;/code&gt; and others) use MuJoCo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/google-deepmind/dm_control" rel="noopener noreferrer"&gt;dm_control&lt;/a&gt;&lt;/strong&gt; – DeepMind's control suite, including PyMJCF for composing models in Python.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bindings in other languages&lt;/strong&gt; – first-party C#/Unity and JavaScript/WebAssembly bindings, plus community bindings for Rust, Julia, Swift, Java and MATLAB Simulink.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Converters&lt;/strong&gt; – tools exist for OpenSim, SDFormat, OBJ meshes and Onshape CAD assemblies to MJCF.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things developers should know before going deep
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Pin your version.&lt;/strong&gt; MuJoCo releases roughly every month and uses a modified form of Semantic Versioning (introduced in 3.5.0). Physics fixes between releases can change simulation results. If you publish benchmarks or train long-running policies, pin the exact version in &lt;code&gt;requirements.txt&lt;/code&gt; and record it with your results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Do not use &lt;code&gt;mujoco-py&lt;/code&gt;.&lt;/strong&gt; Many older tutorials use &lt;code&gt;mujoco-py&lt;/code&gt;, the legacy OpenAI wrapper. It is unmaintained. Use the official &lt;code&gt;mujoco&lt;/code&gt; package instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Timestep matters.&lt;/strong&gt; The default timestep is 0.002 seconds. Making it larger speeds things up but can make contact-heavy scenes unstable. If objects jitter, explode or pass through each other, reduce the timestep before changing anything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Generalized coordinates are not always obvious.&lt;/strong&gt; &lt;code&gt;qpos&lt;/code&gt; and &lt;code&gt;qvel&lt;/code&gt; have different sizes when a model contains free or ball joints, because orientation is stored as a quaternion (4 values in &lt;code&gt;qpos&lt;/code&gt;) but angular velocity has 3 values in &lt;code&gt;qvel&lt;/code&gt;. Use &lt;code&gt;model.nq&lt;/code&gt; and &lt;code&gt;model.nv&lt;/code&gt;, and use named access (&lt;code&gt;data.joint("name")&lt;/code&gt;) instead of hardcoding indices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Call &lt;code&gt;mj_forward&lt;/code&gt; after editing state.&lt;/strong&gt; If you set &lt;code&gt;qpos&lt;/code&gt; manually and then read body positions or sensor values without stepping, they will be stale until you call &lt;code&gt;mj_forward&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Reuse MjData for performance.&lt;/strong&gt; Allocating new &lt;code&gt;MjData&lt;/code&gt; objects in a hot loop is wasteful. Reset with &lt;code&gt;mj_resetData&lt;/code&gt; instead. For batches of CPU rollouts, look at the multithreaded &lt;code&gt;rollout&lt;/code&gt; module.&lt;/p&gt;

&lt;p&gt;A good learning path is: run the introductory notebook, load a robot from Menagerie in the viewer, write a small control loop for it, and then wrap that loop in a Gymnasium environment. From there, MJX or MuJoCo Warp are the natural next step if you need to train at scale.&lt;/p&gt;

</description>
      <category>robotics</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>ai</category>
    </item>
    <item>
      <title>OpenMausBot: A Local-First, Open-Source Team of AI Agents in a Chat App</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Sun, 08 Nov 2026 19:02:52 +0000</pubDate>
      <link>https://dev.to/arshtechpro/openmausbot-a-local-first-open-source-team-of-ai-agents-in-a-chat-app-2haj</link>
      <guid>https://dev.to/arshtechpro/openmausbot-a-local-first-open-source-team-of-ai-agents-in-a-chat-app-2haj</guid>
      <description>&lt;p&gt;If you use agent CLIs like Claude Code or Codex every day, you have probably wished you could run several of them side by side, give each one a role, and manage them like contacts in a messaging app. That is the idea behind OpenMausBot.&lt;/p&gt;

&lt;p&gt;This post is a practical walkthrough for developers: what it is, how it is built, how to run it in a few minutes, and where you can extend it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is OpenMausBot?
&lt;/h2&gt;

&lt;p&gt;OpenMausBot is an open-source, local-first chat app where every chat is a real AI agent. Each bot in the sidebar is backed by an agent CLI running on your machine, and each one can have its own:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;personality and instructions&lt;/li&gt;
&lt;li&gt;model&lt;/li&gt;
&lt;li&gt;computer (a cloud Linux desktop, an isolated local VM, or your own machine)&lt;/li&gt;
&lt;li&gt;set of connected apps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project describes itself as an independent, open-source alternative to products like Grok Bot, Meta Muse, OpenAI dots, and Cue by Manus. It is not affiliated with xAI, Meta, OpenAI, or Manus. It is also known as MausBot and was formerly called OpenGrokBot.&lt;/p&gt;

&lt;p&gt;Quick facts from the repository:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Detail&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Language&lt;/td&gt;
&lt;td&gt;TypeScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI&lt;/td&gt;
&lt;td&gt;React, Vite, Tailwind CSS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Desktop shell&lt;/td&gt;
&lt;td&gt;Electron (macOS, Windows, Ubuntu 24.04)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;License&lt;/td&gt;
&lt;td&gt;Apache 2.0 (the &lt;code&gt;enterprise/&lt;/code&gt; folder has its own source-available license)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime requirement&lt;/td&gt;
&lt;td&gt;Node 24 or newer, pnpm for source builds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent engines&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;claude&lt;/code&gt;, &lt;code&gt;codex&lt;/code&gt;, and &lt;code&gt;grok&lt;/code&gt; CLIs, plus custom engines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Why developers might care
&lt;/h2&gt;

&lt;p&gt;There are three design choices that make this project interesting from an engineering point of view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Bring your own agents.&lt;/strong&gt; OpenMausBot does not proxy your requests through a hosted service. Bots run on the &lt;code&gt;claude&lt;/code&gt;, &lt;code&gt;codex&lt;/code&gt;, and &lt;code&gt;grok&lt;/code&gt; CLIs already installed and logged in on your machine, so your existing subscriptions and logins are reused. You can point an engine at a custom CLI binary in Settings under Engines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Local first.&lt;/strong&gt; One small harness server listens on &lt;code&gt;127.0.0.1&lt;/code&gt; and owns every agent process. Transcripts, keys, and events are stored in &lt;code&gt;~/.openmausbot&lt;/code&gt;, not in someone else's cloud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Approvals instead of blind autonomy.&lt;/strong&gt; A permission broker turns risky actions such as shell commands and file edits into inline cards in the chat. You choose Allow or Deny, for cloud and local computers alike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture in two minutes
&lt;/h2&gt;

&lt;p&gt;OpenMausBot is split into two processes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The app&lt;/strong&gt; (React and Tailwind, port 5199 in dev) holds no transports of its own. It sends typed commands over HTTP and folds a single Server-Sent Events (SSE) stream into state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The harness server&lt;/strong&gt; (&lt;code&gt;127.0.0.1:8799&lt;/code&gt;) owns every agent process. It normalizes each provider's native protocol into one canonical runtime event stream, which is logged per thread as NDJSON.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App (React + Tailwind, :5199)
   |  HTTP commands          ^  one SSE stream
   v                         |
Harness server (127.0.0.1:8799)
   |-- Driver registry --&amp;gt; claude CLI / codex CLI / grok CLI
   |-- Event bus (SSE)
   |-- Permission broker &amp;lt;-- permission requests from agents
   |-- Boat API         --&amp;gt; cloud computer
   |-- Composio session --&amp;gt; Gmail, Slack, GitHub, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main layers map to folders in the repo:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Drivers&lt;/td&gt;
&lt;td&gt;&lt;code&gt;server/drivers/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;One per provider, over stream-JSON, JSON-RPC, or ACP. Unknown drivers degrade to "unavailable" instead of crashing the fleet.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Harness&lt;/td&gt;
&lt;td&gt;&lt;code&gt;server/harness/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Registry (configs to live instances) and the fan-in event bus.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API&lt;/td&gt;
&lt;td&gt;&lt;code&gt;server/index.ts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bots, turns, approvals, model catalog, computer lifecycle, connectors, config over HTTP and SSE.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Voice&lt;/td&gt;
&lt;td&gt;&lt;code&gt;server/tts/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Text-to-speech providers; cloud keys stay on the server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App&lt;/td&gt;
&lt;td&gt;&lt;code&gt;src/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The chat shell: server-backed store, one reducer, no client-side transports.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Desktop&lt;/td&gt;
&lt;td&gt;&lt;code&gt;electron/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Desktop shells with an embedded harness.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you have built anything with an event-sourced UI, this will feel familiar: commands go in over HTTP, events come out over one stream, and the client is a reducer over those events.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get it running
&lt;/h2&gt;

&lt;p&gt;You have three options.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 1: Download a release
&lt;/h3&gt;

&lt;p&gt;Released builds embed the harness server, so there is no separate server setup. Builds are available for macOS (Apple silicon and Intel), Windows x64, and Ubuntu 24.04 x64 (beta, as a &lt;code&gt;.deb&lt;/code&gt; or AppImage). Grab them from the &lt;a href="https://github.com/milind-soni/OpenMausBot/releases/latest" rel="noopener noreferrer"&gt;latest release&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note that the Windows installer is not code-signed yet, so SmartScreen will show "unknown publisher". Use More info, then Run anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option 2: Run from the terminal with npm
&lt;/h3&gt;

&lt;p&gt;This is the fastest path if you just want to try it, and it works on a server too. You need Node 24 or newer.&lt;br&gt;
&lt;/p&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; openmausbot
openmausbot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also skip the global install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx openmausbot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First launch walks you through arrow-key prompts: choose AI access, sign in or paste a hidden API key, choose a model, and optionally connect a phone. The next run reuses your saved setup. Useful flags and commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openmausbot &lt;span class="nt"&gt;--no-open&lt;/span&gt;     &lt;span class="c"&gt;# do not open the browser automatically&lt;/span&gt;
openmausbot setup         &lt;span class="c"&gt;# reconfigure without resetting bots or conversations&lt;/span&gt;
npx openmausbot serve     &lt;span class="c"&gt;# background service for a VPS or always-on machine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Option 3: Build from source
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/milind-soni/OpenMausBot &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;OpenMausBot
pnpm &lt;span class="nb"&gt;install

&lt;/span&gt;pnpm dev:server    &lt;span class="c"&gt;# harness server on 127.0.0.1:8799&lt;/span&gt;
pnpm dev           &lt;span class="c"&gt;# app on http://127.0.0.1:5199&lt;/span&gt;
pnpm dev:desktop   &lt;span class="c"&gt;# Electron shell; keep the two commands above running&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requirements: macOS, Windows, or Ubuntu 24.04 x64, Node 24+, pnpm, and at least one agent CLI (&lt;a href="https://claude.com/claude-code" rel="noopener noreferrer"&gt;&lt;code&gt;claude&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://github.com/openai/codex" rel="noopener noreferrer"&gt;&lt;code&gt;codex&lt;/code&gt;&lt;/a&gt;, or &lt;a href="https://x.ai/cli" rel="noopener noreferrer"&gt;&lt;code&gt;grok&lt;/code&gt;&lt;/a&gt;) installed and logged in. Installed CLIs show up in the model picker automatically.&lt;/p&gt;

&lt;p&gt;Useful scripts while developing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm typecheck        &lt;span class="c"&gt;# app and server&lt;/span&gt;
pnpm &lt;span class="nb"&gt;test&lt;/span&gt;             &lt;span class="c"&gt;# unit, driver, API, and desktop capability tests&lt;/span&gt;
pnpm build            &lt;span class="c"&gt;# typecheck and production build&lt;/span&gt;
pnpm check:electron   &lt;span class="c"&gt;# syntax-check Electron main and preload files&lt;/span&gt;
pnpm package:mac      &lt;span class="c"&gt;# DMG and ZIP (needs Swift/Xcode tools)&lt;/span&gt;
pnpm package:win      &lt;span class="c"&gt;# installer and ZIP&lt;/span&gt;
pnpm package:linux    &lt;span class="c"&gt;# .deb, AppImage, verified CUA runtime&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optional credentials
&lt;/h2&gt;

&lt;p&gt;Local chat works without any extra keys. Add these in App Settings (the gear icon in the sidebar footer) only when you want the matching feature:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Credential&lt;/th&gt;
&lt;th&gt;What it enables&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Composio project key&lt;/td&gt;
&lt;td&gt;Connect Gmail, GitHub, Slack, Notion, and other apps as tools for your bots&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Boat API key&lt;/td&gt;
&lt;td&gt;Give bots an isolated remote Linux computer with a desktop and terminal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ElevenLabs or Fish Audio key&lt;/td&gt;
&lt;td&gt;Read replies aloud and call your bots&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Composio and Boat are third-party services with their own accounts and terms. Boat is paid after its trial, so a cloud computer can incur charges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features worth knowing about
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Model picker per bot.&lt;/strong&gt; Claude and Codex models appear side by side, and you can switch a bot's model mid-conversation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Computers for bots.&lt;/strong&gt; A bot can use a cloud desktop, an isolated Local VM, or your own computer. Control of your own machine is explicit opt-in and available on macOS and Ubuntu Xorg. On Ubuntu Wayland it is currently disabled behind a safety gate (tracked in issue #345).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Channels.&lt;/strong&gt; Separate Work, Personal, and project contexts without cloning bots. Each channel has its own transcript, shared instructions, working folder, and roster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Teams from one Markdown file.&lt;/strong&gt; A team package uses YAML frontmatter plus a normal Markdown playbook, so the app can install it in one click while humans can still read it. Connections stay off until you approve them, routines arrive paused, and packages never carry credentials, conversations, or memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Triggers.&lt;/strong&gt; Schedules and webhooks let a bot act without you. Schedules can run once, on selected weekdays, or every 5 to 1,440 minutes. Interval schedules skip a run if the previous one is still active, so slow work cannot pile up in a queue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voice.&lt;/strong&gt; Spoken replies and calls through ElevenLabs, Fish Audio, Grok, built-in Mac voices, or a local Chatterbox server. Calls are macOS-only for now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automate it: webhooks, CLI, and MCP
&lt;/h2&gt;

&lt;p&gt;This is where it gets useful for developers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Webhook triggers
&lt;/h3&gt;

&lt;p&gt;OpenMausBot starts a webhook-only receiver on &lt;code&gt;127.0.0.1:8800&lt;/code&gt; by default. Set &lt;code&gt;OMB_WEBHOOK_PORT&lt;/code&gt; to change it. Key points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The webhook secret is shown once, when the trigger is created or rotated.&lt;/li&gt;
&lt;li&gt;Bearer authentication is recommended so the secret stays out of URLs and access logs.&lt;/li&gt;
&lt;li&gt;The receiver exposes only &lt;code&gt;/health&lt;/code&gt; and secret &lt;code&gt;/hooks/...&lt;/code&gt; endpoints. It never exposes the broader API.&lt;/li&gt;
&lt;li&gt;The app must be running to accept a delivery. For public delivery, proxy only this receiver through a hosted relay or something like Tailscale Funnel.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Headless CLI for scripts and CI
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;openmausbot&lt;/code&gt; command can drive a running workspace without a screen. It returns one JSON document with &lt;code&gt;--json&lt;/code&gt; and uses exit codes a script can branch on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openmausbot team apply team.yaml
openmausbot run &lt;span class="s2"&gt;"Room Lead"&lt;/span&gt; &lt;span class="s2"&gt;"Rehearse the launch of https://example.com"&lt;/span&gt; &lt;span class="nt"&gt;--export&lt;/span&gt; ./out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MCP server
&lt;/h3&gt;

&lt;p&gt;OpenMausBot ships a stdio MCP server so external clients such as Claude Desktop and Cursor can orchestrate your bots. The tool surface is deliberately bounded: inspect bots and channels, read and search transcripts, create and configure bots, channels, and tasks, send work, wait for completion, switch models, and interrupt turns.&lt;/p&gt;

&lt;p&gt;It does not expose approval grants, deletion, arbitrary settings, credentials, or computer lifecycle. That is a sensible boundary, because it means an outside client cannot approve its own risky actions. Setup details are in the &lt;a href="https://github.com/milind-soni/OpenMausBot/blob/main/docs/mcp-server.md" rel="noopener noreferrer"&gt;MCP docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extending it
&lt;/h2&gt;

&lt;p&gt;You have three extension paths, in increasing order of effort.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Add an MCP tool server with zero code.&lt;/strong&gt; See &lt;code&gt;docs/custom-mcp-servers.md&lt;/code&gt; in the repo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add a custom engine with config only.&lt;/strong&gt; Any ACP-speaking CLI or OpenAI-compatible endpoint plugs in through configuration. See &lt;code&gt;docs/custom-engines.md&lt;/code&gt;. The docs also cover running bots on OpenRouter, Fireworks AI, DeepSeek, Cline, or your own OpenAI- or Anthropic-compatible provider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write a new driver.&lt;/strong&gt; The driver interface in &lt;code&gt;server/contracts.ts&lt;/code&gt; is deliberately small. Adding a provider is one file in &lt;code&gt;server/drivers/&lt;/code&gt; plus a one-line registration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to contribute, read &lt;code&gt;CONTRIBUTING.md&lt;/code&gt; and &lt;code&gt;LICENSING.md&lt;/code&gt; first. The repo uses a CLA and describes how contributions are signed off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security mindset
&lt;/h2&gt;

&lt;p&gt;Any tool that lets an agent run shell commands and control a computer deserves care. Reasonable defaults when you try it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep bots on Ask mode (approval cards) until you trust a workflow.&lt;/li&gt;
&lt;li&gt;Start with the cloud computer or Local VM before pointing a bot at your own machine.&lt;/li&gt;
&lt;li&gt;Connect only the apps a given bot needs.&lt;/li&gt;
&lt;li&gt;Review a team package before importing it from someone else.&lt;/li&gt;
&lt;li&gt;If you expose it to the internet, use a managed HTTPS endpoint with pairing, Tailscale, or your own reverse proxy, never a bare open port.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Repository: &lt;a href="https://github.com/milind-soni/OpenMausBot" rel="noopener noreferrer"&gt;github.com/milind-soni/OpenMausBot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://www.openmausbot.com" rel="noopener noreferrer"&gt;openmausbot.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Self-hosting guide: &lt;code&gt;docs/self-hosting.md&lt;/code&gt; and &lt;code&gt;docs/deploy-vps.md&lt;/code&gt; in the repo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try it, start with &lt;code&gt;npx openmausbot&lt;/code&gt;, create one bot, and watch the approval cards while it works. That is the fastest way to see why the architecture is built the way it is.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>typescript</category>
      <category>agents</category>
    </item>
    <item>
      <title>NVKE: NVIDIA - Run Your Own Managed GPU Kubernetes Service on Bare Metal</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Sun, 08 Nov 2026 18:56:30 +0000</pubDate>
      <link>https://dev.to/arshtechpro/nvke-run-your-own-managed-gpu-kubernetes-service-on-bare-metal-ipa</link>
      <guid>https://dev.to/arshtechpro/nvke-run-your-own-managed-gpu-kubernetes-service-on-bare-metal-ipa</guid>
      <description>&lt;p&gt;If you have ever tried to hand out Kubernetes clusters on GPU servers to several teams or customers, you know the problem. Provisioning machines, forming clusters, keeping them isolated, upgrading them and replacing broken nodes all turn into glue scripts very quickly.&lt;/p&gt;

&lt;p&gt;NVIDIA Kubernetes Engine (NVKE) is an open source project that tackles this. It is a management plane you install on your own NVIDIA GPU infrastructure, and it creates and operates Kubernetes clusters on demand. Think of it as the thing that lets a platform team run something like a managed Kubernetes service, but on bare metal that you own.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Heads up:&lt;/strong&gt; NVKE is currently a &lt;strong&gt;preview&lt;/strong&gt;. APIs, configuration and behavior can change between releases, and the project does not recommend it for production workloads. This article covers what that means in practice further down.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You run the NVKE management plane. Your users run workloads on the clusters it creates.&lt;/li&gt;
&lt;li&gt;Every workload cluster gets its own Kubernetes control plane, its own etcd and its own node pools.&lt;/li&gt;
&lt;li&gt;Users talk to their cluster with plain &lt;code&gt;kubectl&lt;/code&gt; and the Kubernetes API. They do not need to know NVKE exists.&lt;/li&gt;
&lt;li&gt;Machines are provisioned through NVIDIA Infra Controller (NICo), which is the only supported infrastructure provider in the preview.&lt;/li&gt;
&lt;li&gt;License is Apache-2.0, and the code is written in Go.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who this is for
&lt;/h2&gt;

&lt;p&gt;NVKE is aimed at &lt;strong&gt;platform teams&lt;/strong&gt;: the people who own a pool of GPU servers and need to give other teams or customers their own isolated Kubernetes clusters.&lt;/p&gt;

&lt;p&gt;If you only want to run workloads on a single GPU cluster, this is probably more than you need. If you are building an internal "Kubernetes as a service" on top of GPU hardware, keep reading.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it is structured
&lt;/h2&gt;

&lt;p&gt;An NVKE installation has two kinds of Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The management cluster.&lt;/strong&gt; This runs the NVKE management plane and the infrastructure controllers. You create it with the &lt;code&gt;nvkectl&lt;/code&gt; command line tool, which uses a temporary seed cluster to bootstrap it. Installing the management plane services is a separate step after that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Workload clusters.&lt;/strong&gt; These are the clusters your users actually run applications on. The management plane creates and operates them through NICo, Cluster API and a node agent.&lt;/p&gt;

&lt;p&gt;The README describes NVKE as a self-hosting factory for Kubernetes clusters, and explicitly says it is not a Kubernetes distribution and not a Cluster API flavour. A throwaway seed cluster stands up the management cluster, and the management plane then provisions and manages many isolated workload clusters.&lt;/p&gt;

&lt;p&gt;Here is the flow in plain terms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;seed cluster (temporary)
        |
        v
management cluster  (runs the NVKE management plane)
        |
        |  requests machines through NICo
        v
workload clusters   (own control plane, etcd, node pools)
        |
        v
your users, using kubectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What NVKE does for you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Creates independent workload clusters.&lt;/strong&gt; You request a cluster through the NVKE API or &lt;code&gt;nvkectl&lt;/code&gt;. NVKE provisions the machines through NICo and forms a Kubernetes cluster with its own control plane.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manages the cluster lifecycle.&lt;/strong&gt; You can create, scale and delete node pools, upgrade Kubernetes and replace nodes. In the preview, some of these steps are manual and have limits, so read the &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/workload-clusters/node-pools.md" rel="noopener noreferrer"&gt;node pool guide&lt;/a&gt; before relying on them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Establishes node identity.&lt;/strong&gt; Nodes attest themselves through SPIFFE/SPIRE, using their TPM, before they receive join credentials. This means a machine has to prove what it is before it can join a cluster. Encryption of etcd data is available per cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connects builds to deployment.&lt;/strong&gt; A companion project, &lt;a href="https://github.com/dsx-ai-factory/nvkr" rel="noopener noreferrer"&gt;NVIDIA Kubernetes Recipes (NVKR)&lt;/a&gt;, builds the node images and NVKE components from pinned inputs. NVKE deploys those artifacts, while NVKR owns their build and release evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it without GPU hardware
&lt;/h2&gt;

&lt;p&gt;You do not need GPUs or an NVIDIA account to evaluate NVKE. The local quickstart creates a development management plane and a workload cluster on &lt;strong&gt;simulated machines&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What you need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Linux host or VM, amd64 or arm64&lt;/li&gt;
&lt;li&gt;At least 6 CPUs, 12 GiB of free memory and 100 GiB of free disk&lt;/li&gt;
&lt;li&gt;Docker, virtual TPM support and the other tools listed in the guide&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Follow the &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/get-started/quickstart-local.md" rel="noopener noreferrer"&gt;local quickstart&lt;/a&gt; through workload cluster creation, and confirm the cluster's nodes report &lt;code&gt;Ready&lt;/code&gt;. That is your success check.&lt;/p&gt;

&lt;p&gt;On macOS, use the &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/get-started/local-site.md" rel="noopener noreferrer"&gt;local site guide&lt;/a&gt; instead. It runs the evaluation inside a Colima virtual machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install it on real infrastructure
&lt;/h2&gt;

&lt;p&gt;For a real installation you bring your own:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Machines&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;Node images&lt;/li&gt;
&lt;li&gt;Registries&lt;/li&gt;
&lt;li&gt;Access to NICo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start with &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/operate/plan-installation.md" rel="noopener noreferrer"&gt;Plan your installation&lt;/a&gt;. It covers the prerequisites and the order of operations: prepare nodes, bootstrap the management cluster, then install the management plane services.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/overview/supported-platforms.md" rel="noopener noreferrer"&gt;platform and version reference&lt;/a&gt; lists the validated combinations and pinned dependencies. Check it before you pick hardware or versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build from source
&lt;/h2&gt;

&lt;p&gt;If you want to read the code, hack on it or contribute, you can build everything locally.&lt;/p&gt;

&lt;p&gt;Requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go 1.27.3, the version pinned in &lt;code&gt;go.work&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;GNU Make 4 or later&lt;/li&gt;
&lt;li&gt;Public Go modules reachable on the first build&lt;/li&gt;
&lt;li&gt;Optional: &lt;a href="https://flox.dev/" rel="noopener noreferrer"&gt;Flox&lt;/a&gt;, which supplies the repository's development tools (and GNU Make 4 on macOS)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/dsx-ai-factory/nvke.git
&lt;span class="nb"&gt;cd&lt;/span&gt; nvke
make build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This builds the Go workspace and writes seven binaries to &lt;code&gt;bin/&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Binary&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The node agent, which runs on Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;updater&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;controller&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nvkectl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The command line tool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;capd-reboot-controller&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nvke-os-image-check&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;management-engine&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Building does not start a management plane or create a cluster. It only produces the binaries.&lt;/p&gt;

&lt;p&gt;The repository is a multi-module Go workspace, and the &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/go-workspace.md" rel="noopener noreferrer"&gt;workspace guide&lt;/a&gt; explains how the modules and outputs fit together.&lt;/p&gt;

&lt;h2&gt;
  
  
  What developers should know before starting
&lt;/h2&gt;

&lt;p&gt;This is the section to read twice.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. It is a preview, so expect change
&lt;/h3&gt;

&lt;p&gt;APIs, configuration and behavior can change between releases. Do not plan a production rollout around the current behavior. See &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/overview/preview-status.md" rel="noopener noreferrer"&gt;Preview status and known limitations&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. API authentication is off by default
&lt;/h3&gt;

&lt;p&gt;After installation, the API uses plain HTTP and authentication is turned off. You must configure &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/operate/api-authentication.md" rel="noopener noreferrer"&gt;API authentication and protected access&lt;/a&gt; before you let any callers in. Do not expose a fresh install to a network you do not control.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The management cluster does not look after itself
&lt;/h3&gt;

&lt;p&gt;The management cluster does not upgrade, scale or replace itself. There is also no management-plane upgrade procedure and no backup and restore procedure yet. Plan for that operational gap.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. FDE node images are for evaluation only
&lt;/h3&gt;

&lt;p&gt;The FDE node images provide no data-at-rest confidentiality. Treat them as an evaluation tool, not a security feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. NICo is the only infrastructure provider
&lt;/h3&gt;

&lt;p&gt;For the preview, NVIDIA Infra Controller (NICo) is the sole compatible infrastructure provider. If your hardware is managed some other way, NVKE does not support it yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Some lifecycle steps are manual
&lt;/h3&gt;

&lt;p&gt;Node replacement and Kubernetes upgrades have manual steps and preview limits. The node pool guide documents them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A sensible path for a first evaluation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Read &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/overview/what-is-nvke.md" rel="noopener noreferrer"&gt;What is NVKE&lt;/a&gt; to understand the operator workflow.&lt;/li&gt;
&lt;li&gt;Run the local quickstart on a Linux VM and get a workload cluster to &lt;code&gt;Ready&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Read the &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/architecture.md" rel="noopener noreferrer"&gt;Architecture&lt;/a&gt; doc to see the data flows between components.&lt;/li&gt;
&lt;li&gt;Read the known limitations page and decide whether the preview gaps matter for your use case.&lt;/li&gt;
&lt;li&gt;If you have GPU hardware and NICo access, move on to planning a real installation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where to find the docs
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;I want to...&lt;/th&gt;
&lt;th&gt;Go to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prepare nodes and bootstrap the management cluster&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/operate/bootstrap-management-cluster.md" rel="noopener noreferrer"&gt;Bootstrap the management cluster&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install NVKE services&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/deploy/README.md" rel="noopener noreferrer"&gt;Deploy path README&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build node images and get release artifacts&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/operate/build-node-images.md" rel="noopener noreferrer"&gt;Get NVKE artifacts from NVKR&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create and manage customer clusters&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/workload-clusters/create.md" rel="noopener noreferrer"&gt;Create a workload cluster&lt;/a&gt; and &lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/workload-clusters/node-pools.md" rel="noopener noreferrer"&gt;Manage node pools&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Give a customer access&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/workload-clusters/access.md" rel="noopener noreferrer"&gt;Access a workload cluster&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inspect cluster health and telemetry&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/dsx-ai-factory/nvke/blob/main/docs/operate/observe.md" rel="noopener noreferrer"&gt;Observe NVKE and its clusters&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The project also publishes documentation at &lt;a href="https://docs.nvidia.com/nvke/" rel="noopener noreferrer"&gt;docs.nvidia.com/nvke&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing up
&lt;/h2&gt;

&lt;p&gt;NVKE gives platform teams a way to run a managed Kubernetes service on their own NVIDIA GPU hardware, with isolated clusters, TPM-based node attestation and a lifecycle managed through an API and &lt;code&gt;nvkectl&lt;/code&gt;. It is early, and the preview limitations are real, especially the disabled API authentication and the missing management-plane upgrade and backup procedures.&lt;/p&gt;

&lt;p&gt;Repository: &lt;a href="https://github.com/dsx-ai-factory/nvke" rel="noopener noreferrer"&gt;github.com/dsx-ai-factory/nvke&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>nvidia</category>
      <category>opensource</category>
      <category>devops</category>
    </item>
    <item>
      <title>LZ4 Explained for Developers - The Compression Library Built for Speed</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Thu, 05 Nov 2026 12:29:12 +0000</pubDate>
      <link>https://dev.to/arshtechpro/lz4-explained-for-developers-the-compression-library-built-for-speed-1hm</link>
      <guid>https://dev.to/arshtechpro/lz4-explained-for-developers-the-compression-library-built-for-speed-1hm</guid>
      <description>&lt;p&gt;If you have ever used ZFS, zram on Linux, Kafka, or ClickHouse, you have probably used LZ4 without knowing it. It is one of those libraries that quietly sits underneath a lot of infrastructure because it does one thing extremely well: it compresses and decompresses data &lt;em&gt;fast&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This article covers what LZ4 is, when you should (and should not) use it, the things that trip developers up, and how it compares to other free and paid compression tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is LZ4?
&lt;/h2&gt;

&lt;p&gt;LZ4 is a lossless compression algorithm and C library written by Yann Collet (who also created Zstandard). It was first released in 2011, is licensed under the &lt;strong&gt;BSD 2-Clause license&lt;/strong&gt; for the library, and has more than 12k stars on GitHub.&lt;/p&gt;

&lt;p&gt;The design goal is simple: trade some compression ratio for raw speed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compression:&lt;/strong&gt; more than 500 MB/s per core&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decompression:&lt;/strong&gt; multiple GB/s per core, often hitting RAM bandwidth limits&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ratio:&lt;/strong&gt; roughly 2:1 on typical mixed data at the default level&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words, LZ4 does not make your files as small as gzip or Zstandard can, but it is so fast that compression often costs less than the I/O or network time it saves.&lt;/p&gt;




&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;These figures come from the benchmark published in the LZ4 README (lzbench, Silesia corpus, single thread, Core i7-9700K @ 4.9GHz):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compressor&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Compression&lt;/th&gt;
&lt;th&gt;Decompression&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;memcpy (no compression)&lt;/td&gt;
&lt;td&gt;1.000&lt;/td&gt;
&lt;td&gt;13700 MB/s&lt;/td&gt;
&lt;td&gt;13700 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LZ4 default&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.101&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;780 MB/s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4970 MB/s&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LZO 2.09&lt;/td&gt;
&lt;td&gt;2.108&lt;/td&gt;
&lt;td&gt;670 MB/s&lt;/td&gt;
&lt;td&gt;860 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Snappy 1.1.4&lt;/td&gt;
&lt;td&gt;2.091&lt;/td&gt;
&lt;td&gt;565 MB/s&lt;/td&gt;
&lt;td&gt;1950 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zstandard 1.4.0 -1&lt;/td&gt;
&lt;td&gt;2.883&lt;/td&gt;
&lt;td&gt;515 MB/s&lt;/td&gt;
&lt;td&gt;1380 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zlib deflate -1&lt;/td&gt;
&lt;td&gt;2.730&lt;/td&gt;
&lt;td&gt;100 MB/s&lt;/td&gt;
&lt;td&gt;415 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LZ4 HC -9&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.721&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;41 MB/s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;4900 MB/s&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zlib deflate -6&lt;/td&gt;
&lt;td&gt;3.099&lt;/td&gt;
&lt;td&gt;36 MB/s&lt;/td&gt;
&lt;td&gt;445 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things stand out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;LZ4 decompresses several times faster than everything else in the table.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LZ4 HC&lt;/strong&gt; reaches a ratio close to zlib -1 while keeping the same blazing decompression speed. That matters a lot for "compress once, read many times" workloads.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: these numbers are from older versions of each library. Always benchmark with your own data (more on that below).&lt;/p&gt;




&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Install
&lt;/h3&gt;

&lt;p&gt;Most Linux distributions and package managers already ship it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Debian / Ubuntu&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;lz4 liblz4-dev

&lt;span class="c"&gt;# Fedora / RHEL&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;lz4 lz4-devel

&lt;span class="c"&gt;# macOS&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;lz4

&lt;span class="c"&gt;# Windows (vcpkg)&lt;/span&gt;
vcpkg &lt;span class="nb"&gt;install &lt;/span&gt;lz4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or build from source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/lz4/lz4.git
&lt;span class="nb"&gt;cd &lt;/span&gt;lz4
make
&lt;span class="nb"&gt;sudo &lt;/span&gt;make &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Command line
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;lz4&lt;/code&gt; CLI feels a lot like &lt;code&gt;gzip&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Compress (creates file.txt.lz4)&lt;/span&gt;
lz4 file.txt

&lt;span class="c"&gt;# Decompress&lt;/span&gt;
lz4 &lt;span class="nt"&gt;-d&lt;/span&gt; file.txt.lz4

&lt;span class="c"&gt;# Higher compression (levels 3-12 use the HC compressor)&lt;/span&gt;
lz4 &lt;span class="nt"&gt;-9&lt;/span&gt; big.log

&lt;span class="c"&gt;# Use multiple threads (v1.10+), 0 = auto-detect cores&lt;/span&gt;
lz4 &lt;span class="nt"&gt;-T0&lt;/span&gt; huge-file.bin

&lt;span class="c"&gt;# Compress a directory with tar&lt;/span&gt;
&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt; lz4 &lt;span class="nt"&gt;-cf&lt;/span&gt; backup.tar.lz4 ./my-folder

&lt;span class="c"&gt;# Benchmark levels 1 through 9 on your own file&lt;/span&gt;
lz4 &lt;span class="nt"&gt;-b1e9&lt;/span&gt; sample.dat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last command is the most useful one in this article. Run it on real data before choosing a level.&lt;/p&gt;

&lt;h3&gt;
  
  
  C API
&lt;/h3&gt;

&lt;p&gt;The core API is small. Here is a complete round trip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;lz4.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello LZ4! Hello LZ4! Hello LZ4! Hello LZ4!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;src_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;strlen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="cm"&gt;/* Worst-case output size for incompressible input */&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;max_dst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LZ4_compressBound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src_size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;compressed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_dst&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;comp_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LZ4_compress_default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;compressed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;src_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_dst&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;comp_size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"compression failed&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="cm"&gt;/* You must know (or store) the original size yourself */&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;restored&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src_size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;dec_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LZ4_decompress_safe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compressed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;restored&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;comp_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;src_size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dec_size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;fprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"decompression failed&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d -&amp;gt; %d bytes, restored: %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;src_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;comp_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;restored&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compressed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;restored&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compile with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc demo.c &lt;span class="nt"&gt;-llz4&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;lz4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;lz4.frame&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;some repetitive payload &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10_000&lt;/span&gt;

&lt;span class="n"&gt;compressed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lz4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;restored&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lz4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decompress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compressed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;restored&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; -&amp;gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compressed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; bytes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Other languages
&lt;/h3&gt;

&lt;p&gt;LZ4 has bindings or ports in almost every ecosystem:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Common package&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;lz4&lt;/code&gt; (PyPI)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Go&lt;/td&gt;
&lt;td&gt;&lt;code&gt;github.com/pierrec/lz4/v4&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;lz4_flex&lt;/code&gt; (pure Rust) or &lt;code&gt;lz4&lt;/code&gt; (bindings)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Java&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;at.yawk.lz4:lz4-java&lt;/code&gt; (see the security note below)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;C#/.NET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;K4os.Compression.LZ4&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  What developers really need to know
&lt;/h2&gt;

&lt;p&gt;This is the section to read even if you skip everything else.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Block format vs frame format
&lt;/h3&gt;

&lt;p&gt;LZ4 has two formats, and mixing them up is the most common source of bugs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Block format&lt;/strong&gt; (&lt;code&gt;lz4.h&lt;/code&gt;): raw compressed bytes. No header, no checksum, &lt;strong&gt;no record of the original size&lt;/strong&gt;. You must store the uncompressed size yourself and pass it at decompression time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frame format&lt;/strong&gt; (&lt;code&gt;lz4frame.h&lt;/code&gt;): a self-describing container with a magic number, optional content size, optional xxHash checksums, and support for streaming arbitrarily large data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rule of thumb: &lt;strong&gt;use the frame format&lt;/strong&gt; unless you are building your own container and know exactly why you need raw blocks. The frame format is what the CLI produces, and it is what other tools and languages expect for interoperability.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Always use the safe decompressor
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;LZ4_decompress_safe()&lt;/code&gt; (or the frame API). It checks bounds and will not write past your buffer even if the input is corrupted or malicious.&lt;/p&gt;

&lt;p&gt;Avoid &lt;code&gt;LZ4_decompress_fast()&lt;/code&gt;. It is deprecated, and it trusts the input, which makes it unsafe for anything that comes from a network, a user, or a disk you do not fully control.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Compression level does not slow down decompression
&lt;/h3&gt;

&lt;p&gt;LZ4 offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Acceleration&lt;/strong&gt; (&lt;code&gt;LZ4_compress_fast&lt;/code&gt; with a factor &amp;gt; 1): even faster compression, lower ratio.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default&lt;/strong&gt; (level 1): the classic fast mode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Level 2&lt;/strong&gt;: new in v1.10, a middle ground between fast and HC.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HC levels 3 to 12&lt;/strong&gt;: much slower compression, better ratio.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these decompress at essentially the same speed. So for assets, packages, or anything written once and read many times, use a high HC level at build time and enjoy fast reads forever.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Small data needs a dictionary
&lt;/h3&gt;

&lt;p&gt;Compressing a 300-byte JSON message on its own gives poor results because there is no history to find repeats in. LZ4 supports &lt;strong&gt;dictionary compression&lt;/strong&gt;, which pre-loads shared context. Only the last 64 KB of a dictionary is used.&lt;/p&gt;

&lt;p&gt;You can train a dictionary with Zstandard's builder and use it with LZ4:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zstd &lt;span class="nt"&gt;--train&lt;/span&gt; samples/&lt;span class="k"&gt;*&lt;/span&gt;.json &lt;span class="nt"&gt;-o&lt;/span&gt; messages.dict
lz4 &lt;span class="nt"&gt;-D&lt;/span&gt; messages.dict message.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dictionary support was fully stabilized in v1.10.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Multithreading arrived in v1.10
&lt;/h3&gt;

&lt;p&gt;Version 1.10.0 (July 2024, "Multicores edition") added multithreaded compression to the CLI, which gives large speedups on big files with many cores. Decompression is still effectively single-threaded, but it is already fast enough to saturate most NVMe drives.&lt;/p&gt;

&lt;p&gt;If your distro ships an older 1.9.x build, you will not get &lt;code&gt;-T&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Do not compress data that is already compressed
&lt;/h3&gt;

&lt;p&gt;JPEGs, MP4s, ZIPs, and encrypted data will not shrink. LZ4 is fast enough that this is rarely a disaster, but you still burn CPU for nothing. Many systems check the ratio after compressing and store the raw data if the gain is too small.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Check your bindings for security updates
&lt;/h3&gt;

&lt;p&gt;The C library is heavily fuzzed (it is part of OSS-Fuzz), but bindings are separate projects with their own bugs. A notable example: the original &lt;code&gt;org.lz4:lz4-java&lt;/code&gt; is no longer maintained, and the community fork moved to the &lt;code&gt;at.yawk.lz4:lz4-java&lt;/code&gt; Maven coordinates, which includes fixes for CVE-2025-12183 and CVE-2025-66566. If you are on the JVM, check which artifact your dependency tree actually pulls in (Kafka clients and many other libraries depend on it transitively).&lt;/p&gt;




&lt;h2&gt;
  
  
  Where LZ4 is used in the real world
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linux kernel&lt;/strong&gt;: zram, zswap, SquashFS, and kernel image compression&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Filesystems&lt;/strong&gt;: ZFS and OpenZFS use LZ4 as the go-to on-the-fly compression&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Databases and analytics&lt;/strong&gt;: ClickHouse (default codec), plus many column stores&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Messaging&lt;/strong&gt;: Kafka and Pulsar support LZ4 for message batches&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Game engines and asset pipelines&lt;/strong&gt;: fast asset loading&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The common thread: places where latency and throughput matter more than squeezing out the last few percent of disk space.&lt;/p&gt;




&lt;h2&gt;
  
  
  Comparison with other tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Free and open source
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;License&lt;/th&gt;
&lt;th&gt;Speed&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LZ4&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;BSD-2&lt;/td&gt;
&lt;td&gt;Fastest decompression, very fast compression&lt;/td&gt;
&lt;td&gt;Low to medium (HC)&lt;/td&gt;
&lt;td&gt;Real-time, in-memory, storage engines, read-heavy data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zstandard (zstd)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;BSD / GPLv2&lt;/td&gt;
&lt;td&gt;Fast, tunable from very fast to very slow&lt;/td&gt;
&lt;td&gt;Medium to very high&lt;/td&gt;
&lt;td&gt;The best general-purpose default today&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Snappy&lt;/strong&gt; (Google)&lt;/td&gt;
&lt;td&gt;BSD-3&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Low (similar to LZ4)&lt;/td&gt;
&lt;td&gt;Existing Google/Hadoop/Parquet ecosystems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;gzip / zlib (deflate)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;zlib&lt;/td&gt;
&lt;td&gt;Slow compression, slow decompression&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Maximum compatibility (HTTP, archives, everywhere)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Brotli&lt;/strong&gt; (Google)&lt;/td&gt;
&lt;td&gt;MIT&lt;/td&gt;
&lt;td&gt;Slow at high levels, decent decompression&lt;/td&gt;
&lt;td&gt;High, especially for text&lt;/td&gt;
&lt;td&gt;Static web assets served over HTTP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;xz / LZMA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Public domain / LGPL&lt;/td&gt;
&lt;td&gt;Very slow compression&lt;/td&gt;
&lt;td&gt;Very high&lt;/td&gt;
&lt;td&gt;Distribution packages, long-term archives&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LZO&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;GPL&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Legacy systems&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;How to read this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LZ4 vs Zstandard&lt;/strong&gt;: Zstandard (same author) is the better all-rounder. At its fastest levels it is competitive with LZ4 on compression speed and gets a noticeably better ratio, but LZ4 still decompresses roughly 2-4x faster. Pick LZ4 when decompression speed or CPU budget is the bottleneck; pick zstd when storage or bandwidth costs dominate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LZ4 vs Snappy&lt;/strong&gt;: they target the same niche with similar ratios. In most benchmarks LZ4 is faster on both compression and decompression. Snappy is mainly worth choosing when your ecosystem already standardizes on it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LZ4 vs gzip&lt;/strong&gt;: gzip compresses better but is many times slower in both directions. Use gzip when you need universal compatibility, not speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LZ4 vs Brotli / xz&lt;/strong&gt;: different goals. Those tools aim for small output and accept slow compression; LZ4 aims for speed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Paid and commercial options
&lt;/h3&gt;

&lt;p&gt;There are few commercial libraries in this space because the open source options are so strong, but a few are worth knowing:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;What it offers&lt;/th&gt;
&lt;th&gt;When it makes sense&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Oodle&lt;/strong&gt; (Epic Games Tools, formerly RAD Game Tools)&lt;/td&gt;
&lt;td&gt;Proprietary, commercially licensed; bundled with Unreal Engine&lt;/td&gt;
&lt;td&gt;Codecs such as Kraken, Mermaid, Selkie and Leviathan, tuned for very fast decompression with better ratios than LZ4 at similar speeds; also network packet compression&lt;/td&gt;
&lt;td&gt;Game studios shipping large assets, especially on consoles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Intel QuickAssist Technology (QAT)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hardware accelerator, paid via supported CPUs or add-in cards&lt;/td&gt;
&lt;td&gt;Offloads compression (including deflate and LZ4) from the CPU&lt;/td&gt;
&lt;td&gt;High-throughput servers where CPU cycles are expensive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Commercial archivers&lt;/strong&gt; (WinZip, WinRAR, PKZIP)&lt;/td&gt;
&lt;td&gt;Paid end-user software&lt;/td&gt;
&lt;td&gt;GUI tools, encryption, archive management&lt;/td&gt;
&lt;td&gt;Desktop users, not libraries you embed in an application&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Honest take: for the vast majority of developers there is no compelling reason to pay for a compression library. The paid options shine in narrow cases, mainly game asset delivery (Oodle) and hardware offload at data center scale (QAT). For everything else, LZ4 and Zstandard cover the field.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;LZ4 is not trying to win the compression ratio contest. It is trying to make compression so cheap that you can turn it on almost everywhere, and it succeeds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Further reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/lz4/lz4" rel="noopener noreferrer"&gt;LZ4 on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>performance</category>
      <category>c</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>T3 Code: A Free, Open-Source Control Panel for Claude Code, Codex and Other Coding Agents</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Tue, 03 Nov 2026 07:19:51 +0000</pubDate>
      <link>https://dev.to/arshtechpro/t3-code-a-free-open-source-control-panel-for-claude-code-codex-and-other-coding-agents-1p10</link>
      <guid>https://dev.to/arshtechpro/t3-code-a-free-open-source-control-panel-for-claude-code-codex-and-other-coding-agents-1p10</guid>
      <description>&lt;p&gt;If you use AI coding agents every day, you have probably hit this wall: three terminals running Claude Code, one running Codex, all poking at the same repo, and no single place to see what each one is doing or what it changed.&lt;/p&gt;

&lt;p&gt;T3 Code is an attempt to fix that. It comes from Theo Browne's team (the people behind the T3 Stack and T3 Chat), it is MIT licensed, and it costs nothing. In this post I will cover what it actually is, how to get it running, what you need to watch out for, and how it stacks up against the free and paid alternatives.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;T3 Code is &lt;strong&gt;not&lt;/strong&gt; a coding agent and has &lt;strong&gt;no model of its own&lt;/strong&gt;. It is a GUI and control layer that drives the agent CLIs you already have installed.&lt;/li&gt;
&lt;li&gt;It works with &lt;strong&gt;Claude Code, Codex, Cursor, Grok Build, OpenCode and Google Antigravity&lt;/strong&gt;, using your existing subscriptions.&lt;/li&gt;
&lt;li&gt;You get a desktop app (macOS, Windows, Linux), a web app, and iOS/Android apps for checking on agents remotely.&lt;/li&gt;
&lt;li&gt;Each task is a &lt;strong&gt;thread&lt;/strong&gt; that can run on its own Git branch or worktree, with an inline diff and a one-click PR flow.&lt;/li&gt;
&lt;li&gt;It is &lt;strong&gt;very early software&lt;/strong&gt; (v0.0.x). New threads default to &lt;strong&gt;Full access&lt;/strong&gt;, which means no approval prompts. Change that first.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What T3 Code actually is
&lt;/h2&gt;

&lt;p&gt;The project describes itself as an "agent harness control surface". In plain terms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; You (desktop / web / phone)
          |
          v
   T3 Code server  &amp;lt;-- owns processes, terminals, Git, project files
          |
   +------+-------+-----------+----------+
   |      |       |           |          |
 Claude  Codex  Cursor CLI  OpenCode   Grok / Antigravity
  Code    CLI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A server process on your machine owns everything that runs: the agent processes, terminals, Git operations and project files. The desktop, web and mobile apps are thin clients that connect to that server. The desktop app bundles its own server, so on a single machine you do not have to think about this split at all.&lt;/p&gt;

&lt;p&gt;Because T3 Code drives the official CLIs, it signs in through each CLI's own login. It does not resell API keys or add its own usage quota. Whatever you pay Anthropic, OpenAI or Cursor today is what you keep paying. T3 Code itself is $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why developers are paying attention
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;One window for many agents.&lt;/strong&gt; Run Claude Code and Codex side by side, compare their approaches on the same problem, and switch models in the middle of a thread.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Branch per thread.&lt;/strong&gt; Each thread can work on its own branch or Git worktree. A worktree is a second checkout of the same repo on a different branch, so two agents can edit files at the same time without stepping on each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Diff review and PRs in the same place.&lt;/strong&gt; You see the diff as the agent works, then commit, push and open a pull request from the app. The PR gets a generated title and body.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remote control.&lt;/strong&gt; Leave the agents running on your workstation and check on them from your phone or laptop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An MCP server.&lt;/strong&gt; Other agents (Claude Code in a terminal, Codex, ChatGPT) can connect to T3 Code over MCP to read threads and start new ones. That makes a "coordinator agent" pattern possible without writing your own plumbing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Install and log in to at least one agent CLI
&lt;/h3&gt;

&lt;p&gt;T3 Code cannot do anything without an agent behind it. Set up at least one of these first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Claude Code&lt;/span&gt;
claude auth login

&lt;span class="c"&gt;# Codex&lt;/span&gt;
codex login

&lt;span class="c"&gt;# Cursor CLI&lt;/span&gt;
agent login

&lt;span class="c"&gt;# OpenCode&lt;/span&gt;
opencode auth login

&lt;span class="c"&gt;# Grok Build&lt;/span&gt;
grok login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Google Antigravity is the exception: you enable it inside T3 Code's settings and sign in with Google. No CLI needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Install T3 Code
&lt;/h3&gt;

&lt;p&gt;Pick whichever fits your workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it once without installing anything permanent:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx t3@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install the CLI (server plus local web app):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS / Linux&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://t3.codes/install.sh | sh

&lt;span class="c"&gt;# Windows (PowerShell)&lt;/span&gt;
irm https://t3.codes/install.ps1 | iex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;t3                   &lt;span class="c"&gt;# start the server and open the local web app&lt;/span&gt;
t3 service &lt;span class="nb"&gt;install&lt;/span&gt;   &lt;span class="c"&gt;# keep it running in the background&lt;/span&gt;
t3 update            &lt;span class="c"&gt;# move to a newer release&lt;/span&gt;
t3 &lt;span class="nt"&gt;--help&lt;/span&gt;            &lt;span class="c"&gt;# full reference&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install the desktop app:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS&lt;/span&gt;
brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; t3-code

&lt;span class="c"&gt;# Windows&lt;/span&gt;
winget &lt;span class="nb"&gt;install &lt;/span&gt;T3Tools.T3Code
&lt;span class="c"&gt;# or&lt;/span&gt;
scoop &lt;span class="nb"&gt;install &lt;/span&gt;extras/t3code

&lt;span class="c"&gt;# Debian / Ubuntu (download the .deb from GitHub Releases first)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; ./T3-Code-&lt;span class="k"&gt;*&lt;/span&gt;.deb

&lt;span class="c"&gt;# Arch Linux&lt;/span&gt;
yay &lt;span class="nt"&gt;-S&lt;/span&gt; t3code-bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Change the default permission mode
&lt;/h3&gt;

&lt;p&gt;Do this before your first real task. See the next section for why.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Open a project and start a thread
&lt;/h3&gt;

&lt;p&gt;Add your repo as a project, start a thread, choose the agent and whether it should run in a new worktree, and give it a task. When it finishes, review the diff and decide whether to open a PR or throw the branch away.&lt;/p&gt;

&lt;h2&gt;
  
  
  Permission modes: the setting that matters most
&lt;/h2&gt;

&lt;p&gt;Every thread has a permission mode that decides how much the agent can do without asking you:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;When to use it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Supervised&lt;/td&gt;
&lt;td&gt;Asks before commands and file changes. Work outside the workspace is restricted.&lt;/td&gt;
&lt;td&gt;Important repos, unfamiliar tasks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auto-accept edits&lt;/td&gt;
&lt;td&gt;File edits go through, commands still need approval&lt;/td&gt;
&lt;td&gt;Refactors where you mainly care about shell commands&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auto&lt;/td&gt;
&lt;td&gt;Routine actions run, risky ones still ask&lt;/td&gt;
&lt;td&gt;Day-to-day work with providers that support it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full access&lt;/td&gt;
&lt;td&gt;No prompts at all for commands or edits&lt;/td&gt;
&lt;td&gt;Throwaway worktrees and sandboxes only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things to know:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Full access is the default for new threads.&lt;/strong&gt; The agent can run any command and edit any file without asking. For a tool designed to run several agents at once, that is a risky default. Change it in Settings to Supervised or Auto.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto mode depends on the provider.&lt;/strong&gt; Codex hands routine approvals to an AI reviewer and Claude uses its own auto permission mode. Providers without an equivalent, such as OpenCode, fall back to asking every time, like Supervised.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The mode is set per thread, so changing it in one thread does not affect others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remote access in practice
&lt;/h2&gt;

&lt;p&gt;The machine running T3 Code does the work. Your phone or laptop is just a remote. That means the host has to stay awake and reachable.&lt;/p&gt;

&lt;p&gt;You have three main ways to connect:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LAN or Tailscale (traffic stays on your network):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;t3 serve &lt;span class="nt"&gt;--host&lt;/span&gt; &amp;lt;your-lan-or-tailnet-ip&amp;gt;
t3 pair            &lt;span class="c"&gt;# prints a QR code and a one-time pairing link&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For HTTPS over Tailscale:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;t3 serve &lt;span class="nt"&gt;--tailscale-serve&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;T3 Connect (no router or VPN setup):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;t3 connect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This needs a T3 account and routes the connection through T3's relay. Convenient, but be aware of that trade-off if your company has rules about where code-related traffic goes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSH from the desktop app:&lt;/strong&gt; add an SSH host in Settings, and T3 Code starts a server there and forwards the port for you. Projects, credentials and agent work stay on the remote machine. The remote host must be Linux or an Apple Silicon Mac.&lt;/p&gt;

&lt;p&gt;Treat pairing links and codes like passwords. Keep them out of screenshots, logs and bug reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Letting other agents drive T3 Code (MCP)
&lt;/h2&gt;

&lt;p&gt;Every T3 Code environment exposes an MCP endpoint at &lt;code&gt;https://&amp;lt;environment-address&amp;gt;/mcp&lt;/code&gt;. For example, to connect Claude Code running in a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add &lt;span class="nt"&gt;--transport&lt;/span&gt; http t3 https://&amp;lt;environment-address&amp;gt;/mcp
claude mcp login t3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Codex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;codex mcp add t3 &lt;span class="nt"&gt;--url&lt;/span&gt; https://&amp;lt;environment-address&amp;gt;/mcp
codex mcp login t3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new agent gets &lt;strong&gt;Read only&lt;/strong&gt; access by default. You can raise it to Supervised or higher so it can start, message and stop threads. The address must be HTTPS (or &lt;code&gt;localhost&lt;/code&gt; on the same machine), and sign-ins expire after 30 days.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to know before you adopt it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It is early.&lt;/strong&gt; The README says to expect bugs, and stable releases are still on v0.0.x with nightly builds shipping several times a day. Stick to the stable channel for real work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contributions are mostly closed.&lt;/strong&gt; The team says small fixes may be considered, but big features will not be accepted for now. Feature ideas go to GitHub Discussions. If you need something specific, the MIT license lets you fork.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docs live in the repo.&lt;/strong&gt; There is no docs site yet. Everything is under &lt;a href="https://github.com/pingdotgg/t3code/tree/main/docs" rel="noopener noreferrer"&gt;&lt;code&gt;docs/&lt;/code&gt;&lt;/a&gt;, and it is genuinely useful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your existing agent config still applies.&lt;/strong&gt; Because T3 Code runs the real CLIs, things like your &lt;code&gt;CLAUDE.md&lt;/code&gt;, &lt;code&gt;AGENTS.md&lt;/code&gt;, hooks and MCP servers configured for each CLI should keep working.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The PR flow assumes a Git and GitHub-style workflow.&lt;/strong&gt; If your work is not branch-and-PR shaped, you will get less out of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Costs still exist, just not here.&lt;/strong&gt; Running four agents in parallel burns through your Claude or ChatGPT plan limits four times faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  How T3 Code compares to other tools
&lt;/h2&gt;

&lt;p&gt;There are two broad groups to compare against: &lt;strong&gt;orchestrators&lt;/strong&gt; (tools like T3 Code that sit on top of agents) and &lt;strong&gt;AI editors and first-party agent apps&lt;/strong&gt; (tools that come with their own model access).&lt;/p&gt;

&lt;h3&gt;
  
  
  Orchestrators and agent managers
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;th&gt;License&lt;/th&gt;
&lt;th&gt;Platforms&lt;/th&gt;
&lt;th&gt;Agents supported&lt;/th&gt;
&lt;th&gt;Interface&lt;/th&gt;
&lt;th&gt;Mobile / remote&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;T3 Code&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;MIT&lt;/td&gt;
&lt;td&gt;macOS, Windows, Linux, web&lt;/td&gt;
&lt;td&gt;Claude Code, Codex, Cursor, OpenCode, Grok Build, Antigravity&lt;/td&gt;
&lt;td&gt;Desktop + web GUI&lt;/td&gt;
&lt;td&gt;Yes: iOS, Android, web&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Conductor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free local plan; paid Pro for cloud workspaces&lt;/td&gt;
&lt;td&gt;Closed source&lt;/td&gt;
&lt;td&gt;macOS only&lt;/td&gt;
&lt;td&gt;Claude Code, Codex, Cursor, OpenCode&lt;/td&gt;
&lt;td&gt;Native Mac app&lt;/td&gt;
&lt;td&gt;Cloud workspaces on paid plan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Claude Squad&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;AGPL-3.0&lt;/td&gt;
&lt;td&gt;macOS, Linux (Windows via WSL)&lt;/td&gt;
&lt;td&gt;Claude Code, Codex, Gemini, Aider, others&lt;/td&gt;
&lt;td&gt;Terminal UI (tmux)&lt;/td&gt;
&lt;td&gt;Via SSH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vibe Kanban&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Apache-2.0&lt;/td&gt;
&lt;td&gt;Cross-platform (runs via npx)&lt;/td&gt;
&lt;td&gt;10+ including Claude Code, Codex, Gemini CLI, Copilot, Amp, Cursor, OpenCode&lt;/td&gt;
&lt;td&gt;Kanban board in browser&lt;/td&gt;
&lt;td&gt;Self-host and tunnel&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Quick notes on each:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Conductor&lt;/strong&gt; is the closest competitor and the most polished Mac experience. It uses Git worktrees per workspace, like T3 Code. Its free plan covers local workspaces; reviews list Pro at around $50/month for cloud workspaces that keep running when your laptop is closed. If you are not on a Mac, it is not an option.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Squad&lt;/strong&gt; is a lightweight Go binary built on tmux and worktrees. It is great if you live in the terminal and do not want a GUI at all. No phone app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vibe Kanban&lt;/strong&gt; frames agent work as kanban tickets, which suits people who like to plan a backlog first. Its original company, bloop, shut down in 2026 and the project continues as a community-maintained open-source tool, which is worth weighing for long-term support.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AI editors and first-party agent apps
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;th&gt;Difference from T3 Code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cursor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free Hobby tier; Pro $20/mo, Pro+ $60/mo, Ultra $200/mo, Teams $40/user/mo&lt;/td&gt;
&lt;td&gt;Full AI code editor with bundled model usage&lt;/td&gt;
&lt;td&gt;It is an editor with its own billing. T3 Code is a control layer and can even drive the Cursor CLI.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Codex app&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Included with ChatGPT plans&lt;/td&gt;
&lt;td&gt;OpenAI's own app for Codex&lt;/td&gt;
&lt;td&gt;Codex only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Claude Code / Claude desktop&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Included with Claude plans&lt;/td&gt;
&lt;td&gt;Anthropic's own agent, with built-in worktree support&lt;/td&gt;
&lt;td&gt;Claude only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The key difference: Cursor, Codex and Claude Code are where the model access and billing live. T3 Code does not replace them. It sits on top and lets you run several of them from one place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which one should you pick?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You use more than one agent and want a GUI on any OS:&lt;/strong&gt; T3 Code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You are on a Mac, want the most polished experience, and are fine with closed source:&lt;/strong&gt; Conductor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You prefer staying entirely in the terminal:&lt;/strong&gt; Claude Squad.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You want to plan agent work as tickets on a board:&lt;/strong&gt; Vibe Kanban.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You only use one agent and are happy with it:&lt;/strong&gt; Its own app or CLI is probably enough. Claude Code and Codex both support parallel work on their own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You want an editor with AI built in, not an agent manager:&lt;/strong&gt; Cursor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;T3 Code is not trying to be another AI model or another editor. It is a free, open control layer for the agents you already pay for, with worktrees, diffs, PRs and a phone app in one place. It is rough around the edges and changing fast, so treat it as early-adopter software and lock down the permission defaults. But if you already juggle several coding agents, it is one of the more interesting open-source projects to try right now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/pingdotgg/t3code" rel="noopener noreferrer"&gt;pingdotgg/t3code&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Pricing and feature details were checked in early November 2026. These tools change quickly, so verify on each project's site before making a decision.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>git</category>
    </item>
    <item>
      <title>Maestro Deep Dive: Testing a SwiftUI App End to End</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Tue, 27 Oct 2026 19:13:41 +0000</pubDate>
      <link>https://dev.to/arshtechpro/maestro-deep-dive-testing-a-swiftui-app-end-to-end-with-ci-3bkp</link>
      <guid>https://dev.to/arshtechpro/maestro-deep-dive-testing-a-swiftui-app-end-to-end-with-ci-3bkp</guid>
      <description>&lt;p&gt;In Part 1 we covered what Maestro is, how it works and how it compares to Appium, XCUITest, Detox and the paid device clouds. Now it is time to write real tests.&lt;/p&gt;

&lt;p&gt;In this article we will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a small SwiftUI app with a login screen and a to-do list.&lt;/li&gt;
&lt;li&gt;Make it testable with accessibility identifiers.&lt;/li&gt;
&lt;li&gt;Write a Maestro suite with reusable sub-flows, environment variables, conditional logic, JavaScript and tags.&lt;/li&gt;
&lt;li&gt;Run it locally, generate reports and debug failures.&lt;/li&gt;
&lt;li&gt;Look at how the same test would look in XCUITest, and where AI agents fit in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything here uses the free, open-source Maestro CLI. The full app is about 120 lines of Swift, so you can copy it into a new Xcode project and follow along.&lt;/p&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;macOS with Xcode 16 or newer and an iOS 17+ Simulator runtime&lt;/li&gt;
&lt;li&gt;Java 17 or newer (&lt;code&gt;java -version&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Maestro CLI:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; &lt;span class="s2"&gt;"https://get.maestro.mobile.dev"&lt;/span&gt; | bash
maestro &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This article was written against Maestro CLI 2.10.0.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part A: The sample app
&lt;/h2&gt;

&lt;p&gt;Create a new Xcode project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Template: &lt;strong&gt;iOS &amp;gt; App&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Product name: &lt;code&gt;TodoDemo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Organization identifier: &lt;code&gt;com.example&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Interface: &lt;strong&gt;SwiftUI&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Minimum deployment: iOS 17&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That gives the bundle ID &lt;code&gt;com.example.TodoDemo&lt;/code&gt;, which Maestro uses as the &lt;code&gt;appId&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The app has two screens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Login&lt;/strong&gt;: email, password, a "Log In" button and an error message for wrong credentials. The valid credentials are &lt;code&gt;demo@example.com&lt;/code&gt; / &lt;code&gt;password123&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;My Tasks&lt;/strong&gt;: add tasks, tap to complete them, swipe to delete, see a progress label, and log out. After login it asks for notification permission, which gives us a system dialog to deal with.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;TodoDemoApp.swift&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;SwiftUI&lt;/span&gt;

&lt;span class="kd"&gt;@main&lt;/span&gt;
&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;TodoDemoApp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;@AppStorage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"isLoggedIn"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;isLoggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;some&lt;/span&gt; &lt;span class="kt"&gt;Scene&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;WindowGroup&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;TodoListView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;LoginView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The login state is stored in &lt;code&gt;UserDefaults&lt;/code&gt; through &lt;code&gt;@AppStorage&lt;/code&gt;. That matters for testing: it survives an app restart, so we will need to clear app state between tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;LoginView.swift&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;SwiftUI&lt;/span&gt;

&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;LoginView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;View&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;@AppStorage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"isLoggedIn"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;isLoggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="kd"&gt;@State&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;
    &lt;span class="kd"&gt;@State&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;
    &lt;span class="kd"&gt;@State&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;errorMessage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;some&lt;/span&gt; &lt;span class="kt"&gt;View&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;NavigationStack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;Form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;Section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keyboardType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;textInputAutocapitalization&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;never&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;autocorrectionDisabled&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"emailField"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="kt"&gt;SecureField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Password"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;$password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"passwordField"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;

                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;errorMessage&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errorMessage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;foregroundStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;red&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"loginError"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;

                &lt;span class="kt"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Log In"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;logIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"loginButton"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigationTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Welcome"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;logIn&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Demo only. A real app would call an auth service here.&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lowercased&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"demo@example.com"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"password123"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;errorMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
            &lt;span class="n"&gt;isLoggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;errorMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Invalid email or password"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;TodoListView.swift&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;SwiftUI&lt;/span&gt;
&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;UserNotifications&lt;/span&gt;

&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;TodoItem&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Identifiable&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;UUID&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;isDone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;TodoListView&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;View&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;@AppStorage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"isLoggedIn"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;isLoggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="kd"&gt;@State&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;TodoItem&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="kd"&gt;@State&lt;/span&gt; &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;newTitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;doneCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(\&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isDone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="nv"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;some&lt;/span&gt; &lt;span class="kt"&gt;View&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;NavigationStack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;VStack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;spacing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;HStack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"New task"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;$newTitle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;textFieldStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;roundedBorder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;addItem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"newTaskField"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                    &lt;span class="kt"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Add"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;addItem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"addTaskButton"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;disabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newTitle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trimmingCharacters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;whitespaces&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;horizontal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;ContentUnavailableView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="s"&gt;"No tasks yet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nv"&gt;systemImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"checklist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nv"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Add your first task above."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;List&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                        &lt;span class="kt"&gt;ForEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;$items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;$item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
                            &lt;span class="kt"&gt;Button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isDone&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nv"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                                &lt;span class="kt"&gt;HStack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                                    &lt;span class="kt"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;systemName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isDone&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s"&gt;"checkmark.circle.fill"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"circle"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                                    &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strikethrough&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isDone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                                &lt;span class="p"&gt;}&lt;/span&gt;
                            &lt;span class="p"&gt;}&lt;/span&gt;
                        &lt;span class="p"&gt;}&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onDelete&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;atOffsets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;

                    &lt;span class="kt"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;doneCount&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt; of &lt;/span&gt;&lt;span class="se"&gt;\(&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="s"&gt; done"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;font&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;footnote&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;foregroundStyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;secondary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"progressLabel"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigationTitle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"My Tasks"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toolbar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kt"&gt;ToolbarItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;placement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;topBarTrailing&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="kt"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Log Out"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;isLoggedIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;accessibilityIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"logoutButton"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kt"&gt;UNUserNotificationCenter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;current&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestAuthorization&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sound&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;addItem&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newTitle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trimmingCharacters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;whitespaces&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;guard&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;TodoItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;newTitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it once in the Simulator from Xcode to make sure it works.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why the accessibility identifiers?
&lt;/h3&gt;

&lt;p&gt;Maestro can find elements by visible text (&lt;code&gt;tapOn: "Log In"&lt;/code&gt;), and that is often fine. But text changes: a designer renames "Log In" to "Sign In", or you test in German. Identifiers do not change with copy or locale.&lt;/p&gt;

&lt;p&gt;A practical rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Static controls&lt;/strong&gt; (buttons, fields, labels you assert on): give them an &lt;code&gt;accessibilityIdentifier&lt;/code&gt; and target them with &lt;code&gt;id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic content&lt;/strong&gt; (task titles, user names, server data): target by text, because the text is the thing you are verifying.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see exactly what Maestro sees with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro hierarchy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or by opening the Maestro Studio desktop app and clicking on elements in the live device view.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part B: Build and install for the Simulator
&lt;/h2&gt;

&lt;p&gt;Maestro tests the &lt;strong&gt;Simulator build&lt;/strong&gt; of your app (&lt;code&gt;.app&lt;/code&gt;). You can install it by running from Xcode, or from the command line, which is what CI will do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Boot a simulator (the device name depends on your installed runtimes)&lt;/span&gt;
xcrun simctl boot &lt;span class="s2"&gt;"iPhone 16"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# Build for the simulator&lt;/span&gt;
xcodebuild &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-project&lt;/span&gt; TodoDemo.xcodeproj &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-scheme&lt;/span&gt; TodoDemo &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-configuration&lt;/span&gt; Debug &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-sdk&lt;/span&gt; iphonesimulator &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-destination&lt;/span&gt; &lt;span class="s1"&gt;'platform=iOS Simulator,name=iPhone 16'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-derivedDataPath&lt;/span&gt; build &lt;span class="se"&gt;\&lt;/span&gt;
  build

&lt;span class="c"&gt;# Install the .app on the booted simulator&lt;/span&gt;
xcrun simctl &lt;span class="nb"&gt;install &lt;/span&gt;booted build/Build/Products/Debug-iphonesimulator/TodoDemo.app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Part C: The test suite
&lt;/h2&gt;

&lt;p&gt;Here is the structure we are going to build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.maestro/
├── config.yaml
├── subflows/
│   ├── login.yaml
│   └── dismiss_permission_dialog.yaml
└── flows/
    ├── 01_login_invalid.yaml
    ├── 02_login_success.yaml
    ├── 03_add_and_complete_tasks.yaml
    ├── 04_delete_task.yaml
    └── 05_session_and_logout.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;flows/&lt;/code&gt; contains the tests. &lt;code&gt;subflows/&lt;/code&gt; contains reusable building blocks that are never run on their own.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;config.yaml&lt;/code&gt;: the workspace configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Only files matching these patterns are treated as tests.&lt;/span&gt;
&lt;span class="c1"&gt;# Sub-flows live outside flows/, so they are not run directly.&lt;/span&gt;
&lt;span class="na"&gt;flows&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;flows/*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run &lt;code&gt;maestro test .maestro/&lt;/code&gt;, Maestro reads this file to decide which flows belong to the suite.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sub-flow 1: &lt;code&gt;login.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;emailField"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${EMAIL || 'demo@example.com'}&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;passwordField"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${PASSWORD || 'password123'}&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;loginButton"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things to notice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Everything inside &lt;code&gt;${...}&lt;/code&gt; is JavaScript. &lt;code&gt;EMAIL || 'demo@example.com'&lt;/code&gt; means "use the &lt;code&gt;EMAIL&lt;/code&gt; variable if someone passed one, otherwise fall back to the default". That lets the same sub-flow handle valid and invalid logins.&lt;/li&gt;
&lt;li&gt;There are no waits. After &lt;code&gt;tapOn: { id: "emailField" }&lt;/code&gt;, Maestro waits for the screen to settle before typing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sub-flow 2: &lt;code&gt;dismiss_permission_dialog.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;visible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Allow"&lt;/span&gt;
    &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Allow"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;strong&gt;conditional flow&lt;/strong&gt;. If the system notification dialog is on screen, tap "Allow". If it is not, do nothing and continue. Because Maestro drives the whole device rather than just your app process, it can tap system alerts that in-process frameworks cannot reach directly.&lt;/p&gt;

&lt;p&gt;We will mostly avoid the dialog entirely by pre-granting permissions in &lt;code&gt;launchApp&lt;/code&gt;, but this sub-flow is a safety net for cases where you cannot.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test 1: &lt;code&gt;01_login_invalid.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Login fails with wrong credentials&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;auth&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;regression&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;launchApp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;clearState&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/login.yaml&lt;/span&gt;
    &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;EMAIL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;wrong@example.com"&lt;/span&gt;
      &lt;span class="na"&gt;PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;not-the-password"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;loginError"&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;email&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;or&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;password"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertNotVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Tasks"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;clearState: true&lt;/code&gt; wipes the app's data before launching, so every test starts logged out. This is the single most important habit for a reliable suite: never let one test depend on what a previous test left behind.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;runFlow&lt;/code&gt; with &lt;code&gt;env&lt;/code&gt; overrides the variables for that sub-flow only.&lt;/li&gt;
&lt;li&gt;The selector &lt;code&gt;{ id: "loginError", text: "..." }&lt;/code&gt; matches an element that has that identifier &lt;strong&gt;and&lt;/strong&gt; that text.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Test 2: &lt;code&gt;02_login_success.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Login succeeds with valid credentials&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;smoke&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;auth&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;launchApp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;clearState&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;allow&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/login.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/dismiss_permission_dialog.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Tasks"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;tasks&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;yet"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;takeScreenshot&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;after_login&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;permissions: { notifications: allow }&lt;/code&gt; grants the permission before the app starts, so the dialog should never appear. &lt;code&gt;takeScreenshot&lt;/code&gt; saves a PNG, which is useful for reviewing UI in CI artifacts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test 3: &lt;code&gt;03_add_and_complete_tasks.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Add tasks and mark one as done&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;smoke&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;tasks&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;launchApp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;clearState&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;allow&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/login.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/dismiss_permission_dialog.yaml&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;newTaskField"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Buy&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;milk"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;addTaskButton"&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;newTaskField"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Write&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Maestro&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;article"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;addTaskButton"&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Buy&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;milk"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Write&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Maestro&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;article"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;progressLabel"&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;of&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;done"&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Buy&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;milk"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;progressLabel"&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;of&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;done"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how the test reads almost exactly like a manual QA script. That readability is the main reason teams adopt Maestro.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test 4: &lt;code&gt;04_delete_task.yaml&lt;/code&gt; (loops, JavaScript and swipes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Delete a task with swipe&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;tasks&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;regression&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;launchApp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;clearState&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;allow&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/login.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/dismiss_permission_dialog.yaml&lt;/span&gt;

&lt;span class="c1"&gt;# Create "Task 1", "Task 2" and "Task 3" using a loop and a JS counter&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;evalScript&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${output.counter = 0}&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repeat&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;times&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;evalScript&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${output.counter = output.counter + 1}&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;newTaskField"&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;${output.counter}"&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;addTaskButton"&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;3"&lt;/span&gt;

&lt;span class="c1"&gt;# Swipe left on the row to reveal the system Delete action&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;swipe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;from&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;2"&lt;/span&gt;
    &lt;span class="na"&gt;direction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LEFT&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Delete"&lt;/span&gt;

&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertNotVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;2"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;1"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Task&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;3"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;progressLabel"&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;of&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;done"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;output&lt;/code&gt; is a JavaScript object Maestro provides for storing values across steps.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;repeat&lt;/code&gt; runs a block a fixed number of times (it also supports a &lt;code&gt;while&lt;/code&gt; condition).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;swipe&lt;/code&gt; with &lt;code&gt;from&lt;/code&gt; starts the gesture on a specific element, which is how you trigger SwiftUI's &lt;code&gt;.onDelete&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use loops and scripts sparingly. If a flow starts to look like a program, consider seeding data through a test backend or launch arguments instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test 5: &lt;code&gt;05_session_and_logout.yaml&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.TodoDemo&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Session persists across restarts until logout&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;auth&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;regression&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;launchApp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;clearState&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;allow&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/login.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;runFlow&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;../subflows/dismiss_permission_dialog.yaml&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Tasks"&lt;/span&gt;

&lt;span class="c1"&gt;# Restart without clearing state: the user should still be logged in&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;stopApp&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;launchApp&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Tasks"&lt;/span&gt;

&lt;span class="c1"&gt;# Log out and confirm we are back on the login screen&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;logoutButton"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;loginButton"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This test checks behavior that crosses an app restart, something that is awkward to do in many in-process frameworks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part D: Running the suite
&lt;/h2&gt;

&lt;p&gt;Make sure the Simulator is booted and the app is installed, then from the project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run the whole suite&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; .maestro/

&lt;span class="c"&gt;# Run a single flow&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; .maestro/flows/02_login_success.yaml

&lt;span class="c"&gt;# Run only smoke tests&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--include-tags&lt;/span&gt; smoke .maestro/

&lt;span class="c"&gt;# Exclude slow tests&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--exclude-tags&lt;/span&gt; regression .maestro/

&lt;span class="c"&gt;# Pass variables from the command line&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;EMAIL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;qa@example.com &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;secret .maestro/flows/02_login_success.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Faster authoring with continuous mode
&lt;/h3&gt;

&lt;p&gt;While writing a flow, use continuous mode. Maestro reruns the flow every time you save the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; .maestro/flows/03_add_and_complete_tasks.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combined with Maestro Studio for finding selectors, this gives you a feedback loop of a few seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Validate syntax without a device
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro check-syntax .maestro/flows/04_delete_task.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Useful as a pre-commit hook or a quick CI step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reports and artifacts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# JUnit XML, understood by most CI systems&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; .maestro/ &lt;span class="nt"&gt;--format&lt;/span&gt; junit &lt;span class="nt"&gt;--output&lt;/span&gt; build/maestro-report.xml

&lt;span class="c"&gt;# HTML report for humans&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; .maestro/ &lt;span class="nt"&gt;--format&lt;/span&gt; html &lt;span class="nt"&gt;--output&lt;/span&gt; build/maestro-report.html

&lt;span class="c"&gt;# Put screenshots, logs and per-flow artifacts in a known folder&lt;/span&gt;
maestro &lt;span class="nb"&gt;test&lt;/span&gt; .maestro/ &lt;span class="nt"&gt;--test-output-dir&lt;/span&gt; build/maestro-artifacts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a flow fails, the artifacts include a screenshot before each step, the view hierarchy at the moment of failure, device logs and crash reports. Start debugging there, not in the terminal output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running on several simulators in parallel
&lt;/h3&gt;

&lt;p&gt;If you have more than one simulator booted, you can split the suite across them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--shard-split&lt;/span&gt; 2 .maestro/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--shard-split&lt;/code&gt; divides the flows between devices. &lt;code&gt;--shard-all&lt;/code&gt; runs every flow on every device, which is useful for testing several iOS versions or screen sizes at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part E: The same test in XCUITest
&lt;/h2&gt;

&lt;p&gt;To make the comparison from Part 1 concrete, here is roughly what Test 2 (successful login) looks like in XCUITest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;XCTest&lt;/span&gt;

&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="kt"&gt;LoginUITests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;XCTestCase&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;setUp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;continueAfterFailure&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;testLoginSucceeds&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;XCUIApplication&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;launchArguments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"-isLoggedIn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"NO"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;// reset @AppStorage&lt;/span&gt;
        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launch&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;textFields&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"emailField"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="kt"&gt;XCTAssertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForExistence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;typeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"demo@example.com"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;secureTextFields&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"passwordField"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;typeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"password123"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buttons&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"loginButton"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;// System alerts live in SpringBoard, outside the app under test&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;springboard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;XCUIApplication&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;bundleIdentifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"com.apple.springboard"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;allow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;springboard&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buttons&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Allow"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForExistence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kt"&gt;XCTAssertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;navigationBars&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"My Tasks"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForExistence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="kt"&gt;XCTAssertTrue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;staticTexts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"No tasks yet"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;XCUITest is not bad. It is fast, it is Apple's own tooling and it runs on physical devices. But compare the two:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Maestro&lt;/th&gt;
&lt;th&gt;XCUITest&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Lines for this test&lt;/td&gt;
&lt;td&gt;About 10 (plus a reusable sub-flow)&lt;/td&gt;
&lt;td&gt;About 30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Explicit waits&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;waitForExistence&lt;/code&gt; on most steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;System dialogs&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tapOn: "Allow"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Separate SpringBoard app handle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resetting state&lt;/td&gt;
&lt;td&gt;&lt;code&gt;clearState: true&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Launch arguments or custom reset code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rebuild after change&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes, test target recompiles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reusable on Android&lt;/td&gt;
&lt;td&gt;Often, with the same flow&lt;/td&gt;
&lt;td&gt;No, rewrite in Espresso&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Physical iPhones&lt;/td&gt;
&lt;td&gt;Not officially, see Part 1&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Many teams use both: XCUITest or unit tests for detailed component behavior, Maestro for end-to-end user journeys.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part F: Writing flows with an AI coding agent
&lt;/h2&gt;

&lt;p&gt;Maestro ships an MCP server inside the CLI. It lets an AI coding agent see the simulator, inspect the view hierarchy, run flows and read the results. To connect it, add this to your agent's MCP configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"maestro"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"maestro"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mcp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most agents also have a one-line command. For example, with the Codex CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;codex mcp add maestro &lt;span class="nt"&gt;--&lt;/span&gt; maestro mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and with the Gemini CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini mcp add maestro maestro mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can ask something like: "Write a Maestro flow that logs in to TodoDemo, adds three tasks, completes the second one and checks the progress label. Run it and fix it until it passes."&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting checklist
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Element not found&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;maestro hierarchy&lt;/code&gt; or open Studio. Is the identifier set on the element you think it is? Is the text an exact match?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tap lands on the keyboard&lt;/td&gt;
&lt;td&gt;The keyboard may cover the target. Add &lt;code&gt;- hideKeyboard&lt;/code&gt; or scroll first with &lt;code&gt;scrollUntilVisible&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Test passes locally, fails in CI&lt;/td&gt;
&lt;td&gt;CI machines are slower. Use &lt;code&gt;extendedWaitUntil&lt;/code&gt; with a longer timeout for slow screens, and increase &lt;code&gt;MAESTRO_DRIVER_STARTUP_TIMEOUT&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests affect each other&lt;/td&gt;
&lt;td&gt;Use &lt;code&gt;launchApp: { clearState: true }&lt;/code&gt; at the start of every flow.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Long animations break assertions&lt;/td&gt;
&lt;td&gt;Add &lt;code&gt;- waitForAnimationToEnd&lt;/code&gt; before the assertion.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.ipa&lt;/code&gt; will not install&lt;/td&gt;
&lt;td&gt;Maestro needs a Simulator build (&lt;code&gt;.app&lt;/code&gt;) built with &lt;code&gt;-sdk iphonesimulator&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flags stopped working after an upgrade&lt;/td&gt;
&lt;td&gt;Check the changelog. &lt;code&gt;--ios-version&lt;/code&gt; is being replaced by &lt;code&gt;--device-os&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example of a longer explicit wait for a slow screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;extendedWaitUntil&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;visible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;progressLabel"&lt;/span&gt;
    &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15000&lt;/span&gt;   &lt;span class="c1"&gt;# milliseconds&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Best practices summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;One user journey per flow.&lt;/strong&gt; Short flows fail for one clear reason.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reset state at the start of every flow&lt;/strong&gt; with &lt;code&gt;clearState: true&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use identifiers for controls, text for content.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extract repeated steps into sub-flows&lt;/strong&gt; (login, onboarding, navigation).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep logic out of YAML&lt;/strong&gt; where possible. Seed data through APIs or launch arguments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tag your flows&lt;/strong&gt; (&lt;code&gt;smoke&lt;/code&gt;, &lt;code&gt;regression&lt;/code&gt;, feature names) and run smoke tests on every PR, the full suite nightly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin the Maestro version&lt;/strong&gt; in CI and upgrade on purpose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always keep artifacts&lt;/strong&gt; from failed runs.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Ending
&lt;/h2&gt;

&lt;p&gt;With about 120 lines of Swift and five short YAML files, we have a test suite that covers login, error handling, adding, completing and deleting tasks, session persistence, logout and system permission dialogs. It runs locally in under a couple of minutes, runs in GitHub Actions without changes, and can move to a device cloud with one command.&lt;/p&gt;

&lt;p&gt;That is Maestro's real value: the distance between "we should test this" and "it is tested in CI" is very short.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/mobile-dev-inc/maestro" rel="noopener noreferrer"&gt;mobile-dev-inc/maestro&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ios</category>
      <category>testing</category>
      <category>mobile</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Maestro: Mobile UI Testing Without the Pain - Introduction</title>
      <dc:creator>ArshTechPro</dc:creator>
      <pubDate>Tue, 27 Oct 2026 19:10:57 +0000</pubDate>
      <link>https://dev.to/arshtechpro/maestro-mobile-ui-testing-without-the-pain-introduction-1fg8</link>
      <guid>https://dev.to/arshtechpro/maestro-mobile-ui-testing-without-the-pain-introduction-1fg8</guid>
      <description>&lt;p&gt;If you have ever written mobile end-to-end tests, you probably know the routine. You set up Appium, fight with drivers and capabilities, write a test that passes locally, and then watch it fail in CI because an animation took 200ms longer than expected. You add a &lt;code&gt;sleep(2)&lt;/code&gt;. Then another. Six months later nobody trusts the suite.&lt;/p&gt;

&lt;p&gt;Maestro is an open-source framework built to make that experience less painful. This article covers what it is, how it works, what you should know before adopting it, and how it stacks up against the other free and paid options.&lt;/p&gt;

&lt;p&gt;This is Part 1 of a two-part series. &lt;a href="https://dev.to/arshtechpro/maestro-deep-dive-testing-a-swiftui-app-end-to-end-with-ci-3bkp"&gt;Part 2&lt;/a&gt; is a hands-on deep dive with a small SwiftUI app and a complete test suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Maestro?
&lt;/h2&gt;

&lt;p&gt;Maestro is a UI and end-to-end testing framework for Android, iOS and web apps. Instead of writing tests in Java, Kotlin, Swift or JavaScript, you describe user journeys (called &lt;strong&gt;Flows&lt;/strong&gt;) in YAML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.example.myapp&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;launchApp&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sign&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;in"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Email"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jane@example.com"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Password"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hunter2"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Continue"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Welcome,&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Jane"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a complete, runnable test. No page objects, no driver setup code, no explicit waits.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Maestro works (and why it matters)
&lt;/h2&gt;

&lt;p&gt;Maestro is a &lt;strong&gt;black-box&lt;/strong&gt; tool. It does not link into your app, does not need an SDK, and does not need your source code. It drives the device the way a user would, and it reads the screen through the platform's accessibility layer and view hierarchy.&lt;/p&gt;

&lt;p&gt;On iOS, Maestro installs a small XCTest-based driver on the simulator. On Android, it installs a driver app that talks to UIAutomator. The CLI sends commands to the driver, reads back the UI hierarchy, and decides what to do next.&lt;/p&gt;

&lt;p&gt;Three design choices make it feel different from older tools:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Automatic waiting.&lt;/strong&gt; After each command, Maestro waits for the screen to settle before moving on. If you &lt;code&gt;tapOn: "Continue"&lt;/code&gt; and the button is not visible yet, it keeps looking for a while before failing. In practice this removes most of the &lt;code&gt;sleep()&lt;/code&gt; calls you would write elsewhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Flakiness tolerance.&lt;/strong&gt; Mobile UIs are noisy: taps sometimes do not register, elements shift during animations, keyboards appear and disappear. Maestro's commands are designed to retry and re-check rather than fail on the first miss.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Interpreted, not compiled.&lt;/strong&gt; Flows are read at runtime. Change a YAML file, rerun, and see the result in seconds. There is no test target to rebuild.&lt;/p&gt;

&lt;p&gt;Because it operates "at arm's length", Maestro can also do things in-process tools cannot: tap system permission dialogs, open Safari or Settings, and come back to your app in the same flow.&lt;/p&gt;




&lt;h2&gt;
  
  
  The ecosystem: CLI, Studio, MCP and Cloud
&lt;/h2&gt;

&lt;p&gt;Maestro is more than one binary. Here is what each piece does and what it costs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;th&gt;Open source?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro CLI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Runs flows locally and in CI. The core of everything.&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Yes (Apache 2.0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro Studio (desktop)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Visual IDE: inspect elements, record interactions, build flows without the terminal. Available for macOS, Windows and Linux.&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro MCP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Built into the CLI (&lt;code&gt;maestro mcp&lt;/code&gt;). Lets AI coding agents such as Claude Code, Cursor, Copilot, Codex and Gemini run flows, inspect the screen and write tests.&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro Cloud&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hosted parallel execution on managed simulators, emulators and browsers.&lt;/td&gt;
&lt;td&gt;Paid&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A note on Studio: older versions of the CLI shipped a browser-based Studio (&lt;code&gt;maestro studio&lt;/code&gt;). That was removed in CLI 2.6.0 in favor of the desktop app. If you find older tutorials using &lt;code&gt;maestro studio&lt;/code&gt;, that is why they no longer match.&lt;/p&gt;

&lt;p&gt;A note on AI: the old &lt;code&gt;maestro chat&lt;/code&gt; command was discontinued in 2.7.0. The supported path for AI-assisted test authoring is now Maestro MCP.&lt;/p&gt;




&lt;h2&gt;
  
  
  Getting started in five minutes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Install
&lt;/h3&gt;

&lt;p&gt;You need Java 17 or newer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;java &lt;span class="nt"&gt;-version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then install the CLI on macOS, Linux or Windows (WSL):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; &lt;span class="s2"&gt;"https://get.maestro.mobile.dev"&lt;/span&gt; | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, on macOS with Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew tap mobile-dev-inc/tap
brew &lt;span class="nb"&gt;install &lt;/span&gt;maestro
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Start a device
&lt;/h3&gt;

&lt;p&gt;For iOS you need Xcode with at least one Simulator runtime installed. For Android, an emulator from Android Studio. Maestro can also start one for you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro list-devices
maestro start-device &lt;span class="nt"&gt;--platform&lt;/span&gt; ios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Write a flow
&lt;/h3&gt;

&lt;p&gt;Save this as &lt;code&gt;contacts.yaml&lt;/code&gt;. It uses the built-in iOS Contacts app, so you do not need your own app yet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;appId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;com.apple.MobileAddressBook&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;launchApp&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Add"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;First&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;name"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ada"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Last&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;name"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;inputText&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Lovelace"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Done"&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;assertVisible&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ada&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Lovelace"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Button and field labels in Apple's built-in apps can change between iOS versions. If a step fails, open Maestro Studio or run &lt;code&gt;maestro hierarchy&lt;/code&gt; to see the exact labels on your simulator.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Run it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;maestro &lt;span class="nb"&gt;test &lt;/span&gt;contacts.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see each step printed as it runs, with a pass or fail marker. On failure, Maestro saves a screenshot, the view hierarchy and logs so you can see what was on screen at the moment it broke.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is important for developers to know
&lt;/h2&gt;

&lt;p&gt;These are the things that are easy to miss in the marketing material but matter once you adopt Maestro on a real project.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. iOS testing targets Simulators
&lt;/h3&gt;

&lt;p&gt;Maestro's officially supported local iOS target is the &lt;strong&gt;Simulator&lt;/strong&gt;. You need a Simulator build (&lt;code&gt;.app&lt;/code&gt;), not an App Store or Ad Hoc &lt;code&gt;.ipa&lt;/code&gt;. Support for physical iPhones has been one of the most requested features in the repository for a long time. Today, if you need real iOS hardware, your options are third-party projects or device clouds that have added Maestro support on physical devices (TestingBot is one example). Check the current docs before you plan around real devices.&lt;/p&gt;

&lt;p&gt;Android has no such limitation: emulators and USB-connected physical devices both work.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Accessibility identifiers make tests stable
&lt;/h3&gt;

&lt;p&gt;Maestro can find elements by visible text, which is great for getting started. For a test suite you plan to keep, add stable identifiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SwiftUI / UIKit:&lt;/strong&gt; &lt;code&gt;accessibilityIdentifier&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Android:&lt;/strong&gt; &lt;code&gt;resource-id&lt;/code&gt; / &lt;code&gt;testTag&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Native:&lt;/strong&gt; &lt;code&gt;testID&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flutter:&lt;/strong&gt; &lt;code&gt;Semantics(identifier: ...)&lt;/code&gt; or keys exposed through semantics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then target them with &lt;code&gt;id&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;tapOn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;loginButton"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Text selectors break when copy changes or when you test in another language. IDs do not.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. YAML is simple until it isn't
&lt;/h3&gt;

&lt;p&gt;For linear user journeys, YAML is a joy. For complex logic (loops with conditions, computed data, calling a backend to seed state), you will reach for Maestro's JavaScript support (&lt;code&gt;runScript&lt;/code&gt;, &lt;code&gt;evalScript&lt;/code&gt;, &lt;code&gt;${...}&lt;/code&gt; expressions and an &lt;code&gt;http&lt;/code&gt; client). It works, but it is not a full programming language with an IDE, types and a debugger. If your test strategy depends on heavy logic, factor that into your choice.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Black-box means no app internals
&lt;/h3&gt;

&lt;p&gt;You cannot call into your app's code, stub a network layer from inside the process, or read internal state. If you need that, it has to happen outside Maestro: a test backend, launch arguments, or a debug-only screen. Maestro's own built-in network mocking was deprecated years ago.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. It is not a replacement for unit or in-process UI tests
&lt;/h3&gt;

&lt;p&gt;Maestro is excellent for high-level user journeys: sign-up, checkout, onboarding, critical paths. It is not the right tool for testing every state of a single component. Keep XCTest/XCUITest, Espresso or your framework's widget tests for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. CI is straightforward, scaling is the hard part
&lt;/h3&gt;

&lt;p&gt;Running Maestro in CI is just &lt;code&gt;maestro test&lt;/code&gt; plus JUnit or HTML reports. Scaling is where costs appear. iOS Simulators need macOS machines. Locally you can shard across several simulators (parallel iOS simulator execution became reliable in CLI 2.6.0), but at some point teams either buy more Mac runners or move to a cloud.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. The project moves fast
&lt;/h3&gt;

&lt;p&gt;The CLI ships frequently, and some releases deprecate flags. For example, &lt;code&gt;--ios-version&lt;/code&gt; and &lt;code&gt;--android-api-level&lt;/code&gt; are being replaced by &lt;code&gt;--device-os&lt;/code&gt; and &lt;code&gt;--device-model&lt;/code&gt;. Pin your Maestro version in CI and read the changelog when upgrading.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Maestro compares to other tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Free and open-source frameworks
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Platforms&lt;/th&gt;
&lt;th&gt;Test language&lt;/th&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Setup effort&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;iOS, Android, Web&lt;/td&gt;
&lt;td&gt;YAML (+ JS)&lt;/td&gt;
&lt;td&gt;Black-box&lt;/td&gt;
&lt;td&gt;Minutes&lt;/td&gt;
&lt;td&gt;Cross-platform user journeys, mixed teams, fast feedback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Appium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;iOS, Android, Web, Windows, more&lt;/td&gt;
&lt;td&gt;Java, JS/TS, Python, C#, Ruby&lt;/td&gt;
&lt;td&gt;Black-box (WebDriver)&lt;/td&gt;
&lt;td&gt;Hours to days&lt;/td&gt;
&lt;td&gt;Large cross-platform suites, teams with existing Selenium skills&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;XCUITest&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;iOS only&lt;/td&gt;
&lt;td&gt;Swift / Obj-C&lt;/td&gt;
&lt;td&gt;In Xcode, separate test process&lt;/td&gt;
&lt;td&gt;Low (built into Xcode)&lt;/td&gt;
&lt;td&gt;iOS-only teams who want native tooling and real-device support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Espresso&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Android only&lt;/td&gt;
&lt;td&gt;Kotlin / Java&lt;/td&gt;
&lt;td&gt;Gray-box, in-process&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Android-only teams, fast and stable component-level UI tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Detox&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;iOS, Android (React Native)&lt;/td&gt;
&lt;td&gt;JS / TS&lt;/td&gt;
&lt;td&gt;Gray-box, syncs with RN internals&lt;/td&gt;
&lt;td&gt;Moderate to high&lt;/td&gt;
&lt;td&gt;React Native apps that need tight synchronization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Flutter integration_test / Patrol&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;iOS, Android (Flutter)&lt;/td&gt;
&lt;td&gt;Dart&lt;/td&gt;
&lt;td&gt;In-process, Patrol adds native interaction&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Flutter teams who want tests in Dart&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Maestro vs Appium.&lt;/strong&gt; Appium is the most flexible and the most mature: any language, any platform, huge ecosystem, real iOS devices. It is also the most work to set up and maintain, and tests tend to need explicit waits. Maestro trades flexibility for speed of authoring and lower flakiness. Many teams that move from Appium to Maestro do so because test maintenance, not test execution, was their bottleneck.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maestro vs XCUITest.&lt;/strong&gt; XCUITest is Apple's own framework. It is fast, deeply integrated with Xcode and supports real devices. But tests are Swift code that needs a test target, compilation and more boilerplate, and it only covers iOS. If you ship on both platforms, you would also need Espresso and two separate suites. Maestro gives you one suite, often with shared flows across platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maestro vs Detox.&lt;/strong&gt; Detox is gray-box: it knows when React Native is idle, which makes it very stable for RN apps. That same coupling makes setup harder and limits it to React Native. Maestro works with any framework but synchronizes based on what is on screen rather than JS thread state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Paid platforms and device clouds
&lt;/h3&gt;

&lt;p&gt;Most paid offerings are &lt;strong&gt;infrastructure&lt;/strong&gt;: they run tests you have already written on hosted devices. Prices below are list prices published at the time of writing (October 2026). Always confirm on the vendor's pricing page.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;th&gt;Pricing model&lt;/th&gt;
&lt;th&gt;Maestro support&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maestro Cloud&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Official hosted runner for Maestro flows, parallel execution, artifacts, notifications&lt;/td&gt;
&lt;td&gt;$250 per device per month for iOS or Android, $125 per browser per month for web; enterprise plans available; 7-day free trial&lt;/td&gt;
&lt;td&gt;Native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BrowserStack App Automate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Large real-device cloud for Appium, Espresso, XCUITest and more&lt;/td&gt;
&lt;td&gt;Per parallel session; App Automate starts around $199 per parallel per month billed annually&lt;/td&gt;
&lt;td&gt;Yes, via integration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sauce Labs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Real devices and emulators, enterprise features&lt;/td&gt;
&lt;td&gt;Per parallel test with unlimited users and minutes&lt;/td&gt;
&lt;td&gt;Check current docs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TestingBot&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Real devices and simulators, Maestro CLI integration&lt;/td&gt;
&lt;td&gt;Subscription&lt;/td&gt;
&lt;td&gt;Yes, including physical iOS devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DeviceCloud (devicecloud.dev)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Maestro-focused cloud runner&lt;/td&gt;
&lt;td&gt;Pro plan from $25 per month including test credits, usage on top&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AWS Device Farm / Firebase Test Lab&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pay-as-you-go device access from the major clouds&lt;/td&gt;
&lt;td&gt;Metered usage with free tiers or trials&lt;/td&gt;
&lt;td&gt;Possible with custom setup, not first-class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;AI-native testing tools&lt;/strong&gt; (for example Drizz, Autosana)&lt;/td&gt;
&lt;td&gt;Natural-language or vision-based test authoring and self-healing&lt;/td&gt;
&lt;td&gt;Subscription, usually quote-based&lt;/td&gt;
&lt;td&gt;Not applicable; they are alternatives&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A simple way to think about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authoring cost&lt;/strong&gt; (how long tests take to write and maintain): Maestro is among the lowest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execution cost&lt;/strong&gt; (where tests run): free on your own machines, then you pay either for Mac CI runners or for a device cloud. The cloud choice is mostly about price per parallel, device coverage (real vs virtual) and where your data is allowed to go.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  When to choose Maestro
&lt;/h2&gt;

&lt;p&gt;Maestro is a strong fit if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You ship on both iOS and Android, or plan to.&lt;/li&gt;
&lt;li&gt;You want end-to-end coverage of critical user journeys without building a test framework.&lt;/li&gt;
&lt;li&gt;QA engineers, product people or designers should be able to read and contribute to tests.&lt;/li&gt;
&lt;li&gt;Flaky tests are a bigger problem for you than raw test speed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Look elsewhere, or combine tools, if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must run iOS tests on physical devices in your own lab with official support.&lt;/li&gt;
&lt;li&gt;Your tests need deep access to app internals or in-process mocking.&lt;/li&gt;
&lt;li&gt;You need thousands of fine-grained UI assertions per component (use XCUITest, Espresso or framework tests for those).&lt;/li&gt;
&lt;li&gt;Your organization already has a large, healthy Appium suite.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Maestro's pitch is simple: describe what a user does, in plain YAML, and let the framework handle the waiting and retrying. For most teams the biggest win is not execution speed but the fact that tests are quick to write, easy to read and less likely to become the flaky suite nobody trusts.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Part 2&lt;/strong&gt;, we will build a small SwiftUI app with a login screen and a to-do list, then write a full Maestro suite for it: stable selectors, sub-flows, environment variables, conditional logic for permission dialogs, tags, reports and a GitHub Actions workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/mobile-dev-inc/maestro" rel="noopener noreferrer"&gt;mobile-dev-inc/maestro&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ios</category>
      <category>mobile</category>
      <category>testing</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
