<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB"><generator uri="https://jekyllrb.com/" version="4.1.1">Jekyll</generator><link href="https://miles.so/feed.xml" rel="self" type="application/atom+xml" /><link href="https://miles.so/" rel="alternate" type="text/html" hreflang="en-GB" /><updated>2026-10-19T18:00:08+01:00</updated><id>https://miles.so/feed.xml</id><title type="html">miles.so</title><subtitle>I write things sometimes</subtitle><author><name>Miles</name><email>contact@miles.so</email></author><entry><title type="html">Zed, Claude, and a Docker sandbox to put it in</title><link href="https://miles.so/zed-claude-and-a-docker-sandbox/" rel="alternate" type="text/html" title="Zed, Claude, and a Docker sandbox to put it in" /><published>2026-10-19T11:00:00+01:00</published><updated>2026-10-19T11:00:00+01:00</updated><id>https://miles.so/zed-claude-and-a-docker-sandbox</id><content type="html" xml:base="https://miles.so/zed-claude-and-a-docker-sandbox/"><![CDATA[<p>I have two ways of running a coding agent on my laptop and I don’t like either of them. I can approve every action, which means spending the afternoon clicking “allow” on <code class="language-plaintext highlighter-rouge">ls</code> and, somewhere around the fortieth prompt, no longer reading what I’m allowing. Or I can turn the prompts off and give a fast, keen, occasionally confused process the run of my home directory and whatever credentials happen to be lying around in it.</p>

<p>What I actually want is to turn the prompts off somewhere it doesn’t matter. For me that’s a Docker sandbox. The place I want to talk to the agent from is Zed. Joining the two took one settings block, and I think the block is worth walking through, because there’s more going on in that one line of shell than it looks.</p>

<h2 id="the-three-pieces">The three pieces</h2>

<p>Zed has an agent panel, and it’s my favourite place to work with a coding agent. Its edits show up as diffs in the editor I’m already using, and I can click straight through to the files it mentions.</p>

<p>The panel talks to agents over ACP, the Agent Client Protocol. Zed starts the agent as a subprocess and they exchange JSON-RPC over stdin and stdout. Claude Code doesn’t speak ACP itself, so there’s an adapter, <code class="language-plaintext highlighter-rouge">@agentclientprotocol/claude-agent-acp</code>, that sits in front of it and translates.</p>

<p><code class="language-plaintext highlighter-rouge">sbx</code> is Docker’s CLI for sandboxes. Each one is a small VM with your project directory mounted in and outbound traffic going through a proxy that enforces a network policy. Nothing else from your machine is visible unless you put it there.</p>

<p>The thing that makes this work is that ACP only cares about stdin and stdout. It has no idea where the process is running. If the command Zed launches is “run the adapter inside a sandbox and pipe its stdio back out”, Zed can’t tell the difference, and doesn’t need to.</p>

<h2 id="the-whole-config">The whole config</h2>

<p>This goes under <code class="language-plaintext highlighter-rouge">agent_servers</code> in Zed’s <code class="language-plaintext highlighter-rouge">settings.json</code>:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nl">"agent_servers"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
  </span><span class="nl">"Claude (sandbox)"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"default_config_options"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
      </span><span class="nl">"effort"</span><span class="p">:</span><span class="w"> </span><span class="s2">"default"</span><span class="p">,</span><span class="w">
      </span><span class="nl">"fast"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"custom"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"command"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/bin/zsh"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"args"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="s2">"-lc"</span><span class="p">,</span><span class="w">
      </span><span class="s2">"exec sbx exec -i </span><span class="se">\"</span><span class="s2">claude-$(basename </span><span class="se">\"</span><span class="s2">$PWD</span><span class="se">\"</span><span class="s2">)</span><span class="se">\"</span><span class="s2"> -- npx -y @agentclientprotocol/claude-agent-acp"</span><span class="p">,</span><span class="w">
    </span><span class="p">],</span><span class="w">
    </span><span class="nl">"env"</span><span class="p">:</span><span class="w"> </span><span class="p">{},</span><span class="w">
  </span><span class="p">},</span><span class="w">
</span><span class="p">}</span><span class="err">,</span><span class="w">
</span></code></pre></div></div>

<p>It turns up in the agent panel as its own entry, alongside the built-in ones.</p>

<!-- TODO: screenshot of Zed's agent panel with "Claude (sandbox)" selected -->
<!-- ![Zed's agent panel with the "Claude (sandbox)" agent selected](/assets/img/zed-claude-sandbox.png) -->

<p>The sandbox has to exist before Zed can use it. You create it once per repository, from the repository root:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sbx create claude <span class="nb">.</span>
</code></pre></div></div>

<p>By default a sandbox is named after the agent and the directory, so in a repo called <code class="language-plaintext highlighter-rouge">jekyll-klise</code> you get <code class="language-plaintext highlighter-rouge">claude-jekyll-klise</code>. Remember that, because it’s the name the config goes looking for.</p>

<h2 id="reading-the-command">Reading the command</h2>

<p><code class="language-plaintext highlighter-rouge">/bin/zsh -lc</code> runs the rest in a login shell. Zed starts agent servers as plain subprocesses, and depending on how Zed itself was launched, that subprocess might not have the <code class="language-plaintext highlighter-rouge">PATH</code> my terminal has. A login shell reads my profile, so <code class="language-plaintext highlighter-rouge">sbx</code> gets found either way.</p>

<p><code class="language-plaintext highlighter-rouge">exec</code> replaces the shell with <code class="language-plaintext highlighter-rouge">sbx</code> instead of running it as a child. When Zed stops the agent, the signal goes to <code class="language-plaintext highlighter-rouge">sbx</code> directly rather than to a shell that may or may not pass it on.</p>

<p><code class="language-plaintext highlighter-rouge">claude-$(basename "$PWD")</code> is the sandbox name. Zed runs the command from the project root, so <code class="language-plaintext highlighter-rouge">basename "$PWD"</code> is the repo’s folder name, and sticking <code class="language-plaintext highlighter-rouge">claude-</code> on the front gets you back to the default name from earlier. One sandbox per repo, found by convention, and nothing per-project in Zed’s settings. Open a different repo and the same entry talks to a different sandbox. If that sandbox is stopped, <code class="language-plaintext highlighter-rouge">sbx exec</code> starts it first.</p>

<p><code class="language-plaintext highlighter-rouge">-i</code> keeps stdin open. ACP is a conversation over stdin and stdout, and without <code class="language-plaintext highlighter-rouge">-i</code> the adapter would see its input close straight away and exit. There’s deliberately no <code class="language-plaintext highlighter-rouge">-t</code>: a TTY in the middle would start mangling the JSON-RPC.</p>

<p><code class="language-plaintext highlighter-rouge">npx -y @agentclientprotocol/claude-agent-acp</code> is everything after the <code class="language-plaintext highlighter-rouge">--</code>, and it runs inside the sandbox. It’s the adapter, and it starts Claude Code in there, where it can do what it likes.</p>

<h2 id="why-the-paths-line-up">Why the paths line up</h2>

<p>I fully expected this part to break.</p>

<p>ACP messages are full of absolute paths. Zed tells the agent which files are open, the agent tells Zed which files it changed, and Zed draws diffs and links against those paths. If the sandbox mounted the project at <code class="language-plaintext highlighter-rouge">/workspace</code> while Zed thought it lived at <code class="language-plaintext highlighter-rouge">/Users/me/repos/thing</code>, every one of those paths would point at nothing.</p>

<p>It doesn’t break, because <code class="language-plaintext highlighter-rouge">sbx</code> mounts the workspace at the same absolute path inside the sandbox as on the host. My Mac’s <code class="language-plaintext highlighter-rouge">/Users/...</code> path exists, character for character, inside a Linux VM. Paths Zed sends resolve in the sandbox, paths the agent sends back resolve on the Mac, and nobody has to translate anything. Diffs end up in the right buffer.</p>

<h2 id="what-the-sandbox-does-and-doesnt-protect">What the sandbox does and doesn’t protect</h2>

<p>The agent can see the mounted repository and whatever the network policy lets it reach. It can’t see the rest of my home directory, my host credentials or my SSH keys. It can still make a complete mess of the repository, since that’s the one thing I deliberately handed over. Git is the undo button, so I commit before I let it loose.</p>

<h2 id="where-its-rough">Where it’s rough</h2>

<p>A few things about this setup annoy me.</p>

<p><code class="language-plaintext highlighter-rouge">npx -y</code> checks for the adapter every time the agent starts, and downloads it the first time. That adds a bit of startup time, and it means the sandbox’s network policy has to allow the npm registry.</p>

<p>If you forget <code class="language-plaintext highlighter-rouge">sbx create</code>, the agent panel just fails, and the error doesn’t tell you the sandbox is missing.</p>

<p>Naming by folder is only a convention. Two repos that happen to share a folder name will end up in the same sandbox.</p>

<p>And <code class="language-plaintext highlighter-rouge">"type": "custom"</code> means you’re on your own. Zed’s built-in Claude entry looks after the adapter for you. This one is a command line you own, and if the adapter or <code class="language-plaintext highlighter-rouge">sbx</code> changes underneath it, fixing it is your job.</p>

<p>None of this is specific to Claude, either. Any agent that speaks ACP can go in the same sandbox if you swap out what comes after the <code class="language-plaintext highlighter-rouge">--</code>.</p>

<p>Zed gets the conversation, the sandbox gets the consequences, and one command line joins them.</p>]]></content><author><name>Miles</name><email>contact@miles.so</email></author><category term="zed" /><category term="claude" /><category term="agents" /><category term="docker" /><category term="sandboxes" /><summary type="html"><![CDATA[I have two ways of running a coding agent on my laptop and I don’t like either of them. I can approve every action, which means spending the afternoon clicking “allow” on ls and, somewhere around the fortieth prompt, no longer reading what I’m allowing. Or I can turn the prompts off and give a fast, keen, occasionally confused process the run of my home directory and whatever credentials happen to be lying around in it.]]></summary></entry><entry><title type="html">Deploying a Gitlab repo to Openshift</title><link href="https://miles.so/gitlab-openshift/" rel="alternate" type="text/html" title="Deploying a Gitlab repo to Openshift" /><published>2021-08-14T10:29:20+01:00</published><updated>2021-08-14T10:29:20+01:00</updated><id>https://miles.so/gitlab-openshift</id><content type="html" xml:base="https://miles.so/gitlab-openshift/"><![CDATA[<p>In this post, I’ll go over how to take a Gitlab repo and build a dockerfile using Gitlab’s CI/CD pipeline, authenticate with Openshift, and then deploy a service. I recently had to do this and it required much trial and error so hopefully, this guide will save someone some time.</p>

<h2 id="building-the-docker-image">Building the docker image</h2>

<p>For this step to work, you will already need a dockerfile for your project. There are plenty of guides on this so I won’t go into detail here. An important part to remember to make deploying to Openshift more painless is to include an <code class="language-plaintext highlighter-rouge">EXPOSE</code> instruction in your dockerfile. This will be helpful later when we set up routes.</p>

<p>Once we have a dockerfile, we will need to specify a <code class="language-plaintext highlighter-rouge">.gitlab-ci.yml</code> file which will contain the configuration required for the Gitlab CI to build the docker image. A good starting point is an adaptation of the file specified in the <a href="https://docs.gitlab.com/ee/ci/docker/using_kaniko.html">Gitlab docs</a>:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">stages</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">build</span>

<span class="na">build</span><span class="pi">:</span>
  <span class="na">stage</span><span class="pi">:</span> <span class="s">build</span>
  <span class="na">image</span><span class="pi">:</span>
    <span class="na">name</span><span class="pi">:</span> <span class="s">gcr.io/kaniko-project/executor:debug</span>
    <span class="na">entrypoint</span><span class="pi">:</span> <span class="pi">[</span><span class="s2">"</span><span class="s">"</span><span class="pi">]</span>
  <span class="na">script</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="s">mkdir -p /kaniko/.docker</span>
    <span class="pi">-</span> <span class="s">echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" &gt; /kaniko/.docker/config.json</span>
    <span class="pi">-</span> <span class="s">/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --destination $CI_REGISTRY_IMAGE:latest</span>
  <span class="na">rules</span><span class="pi">:</span>
    <span class="pi">-</span> <span class="na">if</span><span class="pi">:</span> <span class="s">$CI_COMMIT_TAG</span>
</code></pre></div></div>

<p>The only modification to this is that it also creates an image with the tag <code class="language-plaintext highlighter-rouge">latest</code> on build. This will be helpful as later we can point the Openshift image-stream to this label to automatically update the deployment upon build. An important detail to note is the <code class="language-plaintext highlighter-rouge">if: $CI_COMMIT_TAG</code> rule. This means that the pipeline will only run the build on a new tag, not on a commit. This leaves the developer with more fine-grained control of when the build runs.</p>

<p>Kaniko was advantageous here over using docker to build the image as using docker would require docker-in-docker (DinD) which poses security risks as well as larger overheads. Kaniko can build docker images but does it in userspace which is more suited to running in a docker container.</p>

<blockquote>
  <p><code class="language-plaintext highlighter-rouge">git push</code> will not push local tags by default. This is usually helpful as it prevents conflicts with other tags on the remote. In this case the <code class="language-plaintext highlighter-rouge">git push --follow-tags</code> command will push tags with annotations to the remote, thus triggering a build.</p>
</blockquote>

<p>Once we push a tag, the pipeline will build the image and upload it to the repo’s docker registry.</p>

<h2 id="creating-the-image-stream-in-openshift">Creating the image-stream in Openshift</h2>

<p>The first step to deploying to Openshift is to have a working Openshift instance, as well as having the <code class="language-plaintext highlighter-rouge">oc</code> CLI tool installed. You can either log in using an API key or username and password with the following command:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc login https://openshift.example.com <span class="nt">-u</span> your_username
</code></pre></div></div>

<p>You will then be prompted for your password. If you do not already have one, we will need to create a new project using <code class="language-plaintext highlighter-rouge">oc new-project project_name</code>. This will also automatically switch you to the new project.</p>

<p>Now that we have logged in to Openshift, we need to create the secrets to authenticate with Gitlab. This is where we run into the main difficulty I encountered. Gitlab requires authentication against two endpoints. These might change depending on your deployment of Gitlab, but for me, they were <code class="language-plaintext highlighter-rouge">registry.git.example.com</code> and <code class="language-plaintext highlighter-rouge">git.example.com</code>. For this example, you can use either your Gitlab password, or more securely, an access token generated by Gitlab. These tokens can be either user-specific or project-specific. As long as it has registry read access it will work. We first need to run the following commands to create a secret for our first authentication endpoint:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc create secret docker-registry gitlab <span class="se">\</span>
  <span class="nt">--docker-server</span><span class="o">=</span>registry.git.example.com <span class="se">\</span>
  <span class="nt">--docker-username</span><span class="o">=</span>your_username <span class="se">\</span>
  <span class="nt">--docker-password</span><span class="o">=</span>your_password_or_token <span class="se">\</span>
  <span class="nt">--docker-email</span><span class="o">=</span>your_email@example.com

<span class="nv">$ </span>oc secrets <span class="nb">link </span>builder gitlab <span class="nt">--for</span><span class="o">=</span>pull
<span class="nv">$ </span>oc secrets <span class="nb">link </span>default gitlab <span class="nt">--for</span><span class="o">=</span>pull
<span class="nv">$ </span>oc secrets <span class="nb">link </span>deployer gitlab <span class="nt">--for</span><span class="o">=</span>pull
</code></pre></div></div>

<p>We will then need to create the secrets for the second endpoint:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc create secret docker-registry gitlab-delegated <span class="se">\</span>
  <span class="nt">--docker-server</span><span class="o">=</span>git.example.com <span class="se">\</span>
  <span class="nt">--docker-username</span><span class="o">=</span>your_username <span class="se">\</span>
  <span class="nt">--docker-password</span><span class="o">=</span>your_password_or_token <span class="se">\</span>
  <span class="nt">--docker-email</span><span class="o">=</span>your_email@example.com

<span class="nv">$ </span>oc secrets <span class="nb">link </span>builder gitlab-delegated <span class="nt">--for</span><span class="o">=</span>pull
<span class="nv">$ </span>oc secrets <span class="nb">link </span>default gitlab-delegated <span class="nt">--for</span><span class="o">=</span>pull
<span class="nv">$ </span>oc secrets <span class="nb">link </span>deployer gitlab-delegated <span class="nt">--for</span><span class="o">=</span>pull
</code></pre></div></div>

<p>Once these secrets are set up, we should be able to add an image-stream, pulling from the latest tag for the image:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc import-image image_stream_name <span class="se">\</span>
  <span class="nt">--from</span><span class="o">=</span>registry.git.example.com/project/path <span class="se">\</span>
  <span class="nt">--scheduled</span> <span class="se">\</span>
  <span class="nt">--confirm</span>
</code></pre></div></div>

<p>The <code class="language-plaintext highlighter-rouge">--scheduled</code> tag means that the Openshift instance automatically checks for a new image with the <code class="language-plaintext highlighter-rouge">latest</code> tag every 15 minutes by default. We can check the image-stream details with <code class="language-plaintext highlighter-rouge">oc describe is/image_stream_name</code>.</p>

<h2 id="deploying-an-application-using-the-image-stream">Deploying an application using the image-stream</h2>

<p>This is now the easy part. To deploy a new application, we can use the following command:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc new-app image_stream_name
</code></pre></div></div>

<p>This will create all of the correct Openshift objects for the application to run with the name <code class="language-plaintext highlighter-rouge">image_stream_name</code>.</p>

<p>The final step is to expose the application to the outside world. We can do this with the following command:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc expose svc/image_stream_name
</code></pre></div></div>

<p>This uses the <code class="language-plaintext highlighter-rouge">EXPOSE</code> command from earlier to work out automatically which port from the pod to open. By default, the application will then be available on port 80 with so SSL. Adding SSL is better documented than importing images from Gitlab and is therefore beyond the scope of this post. In order to get the DNS of the application, you can run the following command:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>oc describe routes/image_stream_name
</code></pre></div></div>

<p>The DNS can be found under the <code class="language-plaintext highlighter-rouge">Requested Host</code> label.</p>

<p>I hope that my trial and error saves you some time and some Kubernetes related pains.</p>

<!-- You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.

$$
\tilde f(\omega)=\frac{1}{2\pi}
\int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx\,,
$$

Jekyll requires blog post files to be named according to the following format:

`YEAR-MONTH-DAY-title.MARKUP`

Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.

Jekyll also offers powerful support for code snippets:

```ruby
def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Person')
#=> prints 'Hi, Person' to STDOUT.
```

Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].

[jekyll-docs]: https://jekyllrb.com/docs/home
[jekyll-gh]:   https://github.com/jekyll/jekyll
[jekyll-talk]: https://talk.jekyllrb.com/ -->]]></content><author><name>Miles</name><email>contact@miles.so</email></author><category term="openshift" /><category term="docker" /><category term="kubernetes" /><category term="gitlab" /><summary type="html"><![CDATA[In this post, I’ll go over how to take a Gitlab repo and build a dockerfile using Gitlab’s CI/CD pipeline, authenticate with Openshift, and then deploy a service. I recently had to do this and it required much trial and error so hopefully, this guide will save someone some time.]]></summary></entry></feed>