unContainer

Guides

Compare two agent previews

Give two coding agents the same starting app. Each changes a heading on its own branch, serves the result on guest port 3000, and hands you a different local URL.

You’ll need the unContainer CLI on a supported host, Git, curl, jq, npx, and two Codex or Claude Code chats able to run local commands. The first guest boot needs network access on the host. The demo app uses Perl from the default Debian guest.

1. Give both agents the same starting point

From a parent directory, create a small local repository using fresh directory and branch names. Keep this terminal open for the final comparison.

mkdir uc-agent-demo && cd uc-agent-demo git init mkdir public echo '<h1>Original preview</h1>' > public/index.html

Save the demo HTTP server as server.pl in the repository root. Install the skill at project scope and commit the baseline so both worktrees inherit it.

npx skills add iddar/uncontainer --skill uncontainer -a codex claude-code -y git add . git commit -m "Add preview app and unContainer skill" repo=$(pwd -P) git worktree add -b demo/amber ../amber HEAD git worktree add -b demo/slate ../slate HEAD

2. Start one chat in each worktree

Open the two sibling directories as existing checkouts. Each agent edits its host file before opening its guest, so the Linux snapshot includes its version. Both can work at the same time.

Agent Amber · demo/amber

Open amber as the working directory in its own Codex or Claude Code chat. Give it this prompt:

Use the uncontainer skill. Confirm that your current branch is demo/amber. Edit public/index.html on the host so its heading reads “Amber preview”. Commit that change on this branch. Then open a fresh Debian session for this worktree with uncontainer session open --publish 3000. Start the preview with uncontainer session exec -- sh -c 'perl server.pl </dev/null >/tmp/preview.log 2>&1 &'. Read the assigned host port from this worktree’s entry in uncontainer session list --json. Fetch the URL from the host and check the heading. Leave the session running and report the branch, session ID, URL and heading.

Agent Slate · demo/slate

Open slate as the working directory in its own Codex or Claude Code chat. Give it this prompt:

Use the uncontainer skill. Confirm that your current branch is demo/slate. Edit public/index.html on the host so its heading reads “Slate preview”. Commit that change on this branch. Then open a fresh Debian session for this worktree with uncontainer session open --publish 3000. Start the preview with uncontainer session exec -- sh -c 'perl server.pl </dev/null >/tmp/preview.log 2>&1 &'. Read the assigned host port from this worktree’s entry in uncontainer session list --json. Fetch the URL from the host and check the heading. Leave the session running and report the branch, session ID, URL and heading.

3. Test both versions from the host

Back in the original terminal, look up each worktree by its full path and guest port. Use the actual URLs printed here in two browser tabs. The addresses stay valid while the sessions are running.

preview_url() { tree=$(cd "$1" && pwd -P) || return 1 port=$(uncontainer session list --json | jq -er --arg tree "$tree" ' .[] | select(.worktree == $tree) | .forwards[] | select(.guest == 3000) | .host') || return 1 printf "http://127.0.0.1:%s/\n" "$port" } amber_url=$(preview_url "$repo/../amber") slate_url=$(preview_url "$repo/../slate") printf "Amber: %s\nSlate: %s\n" "$amber_url" "$slate_url"
curl -fsS --retry 5 --retry-all-errors --retry-delay 1 "$amber_url" | grep -F "Amber preview" curl -fsS --retry 5 --retry-all-errors --retry-delay 1 "$slate_url" | grep -F "Slate preview"

Both checks should match. Each guest has its own listener on port 3000. Publishing without a host port lets the OS assign two different loopback ports. If a check fails, compare the worktree paths and ports with the agents’ reports. If the server failed to start, inspect /tmp/preview.log with session exec -- cat from that worktree.

4. Finish the review

Once the agents are done and you’ve compared both pages, stop their sessions and remove the checkouts. The two commits remain on their branches for inspection.

(cd "$repo/../amber" && uncontainer session close) (cd "$repo/../slate" && uncontainer session close) git -C "$repo" worktree remove ../amber git -C "$repo" worktree remove ../slate git -C "$repo" diff demo/amber demo/slate -- public/index.html