Skip to content

Running Unattended Agents in Isolated Sandboxes

Autonomous coding modes (claude --dangerously-skip-permissions, codex --dangerously-bypass-approvals-and-sandbox, agy and kimi --yolo) move fast because they do not stop to ask permission for every shell command. Running them directly on your laptop, however, exposes your home directory, SSH keys and production credentials.

Local sandboxes: Another shell. A separate space on YouTube

Transcript

Sometimes you want to run an agent without giving it the run of your Mac. Or you need a toolchain you'd rather keep in a container. tmatic box makes that everyday job simple. Once it's set up, opening your sandbox can be one short command.

For the shortest daily command, open Settings, then Sandboxes in the Mac app. Under Sandbox defaults, choose Local Docker as the Default environment. Set Default harness to Shell, or choose the agent you normally use. Harness just means the tool to start. The app saves each choice as you change it.

From your project, run tmatic box with nothing after it. With Docker and Shell selected, it opens a container shell. If you selected an agent, it starts that instead. On first use, follow the prompts to start Docker, prepare the image and approve your project folder.

You don't have to save defaults. This first command chooses Docker and a shell just for this launch. The second starts Claude there instead. These choices leave your saved defaults alone. If you only write shell, the tool changes but the target still comes from your settings.

For the target and tool, an explicit command choice wins. Next come this project's dot tmatic settings, then your saved app defaults. If none are set, the starting choices are Docker and Claude. That lets you keep an everyday setup and choose something different whenever you need it.

Here's recorded output from our prepared demo container. We ask the shell which system it is running on and it reports Linux. Your Mac is still the host. You can use that shell for a build, a new dependency or an agent task, with the tools kept inside the container.

The project folder is mounted into this local container. That means edits appear on your Mac straight away. This recorded diff shows a small sample edit. A container limits access to the rest of the host, but it doesn't protect a writable project folder from deletion. Keep the mount to the work you intend to share.

Sign in to the agent in your prepared sandbox, or use tmatic box sync to copy supported sign-ins into a box you trust. The supported agents run in unattended modes. Pick the workspace, let the tool do its work, then review the diff and run your checks before committing.

Save your usual setup, or choose the target and tool each time. Either way, tmatic box gives you a simple way into a separate environment. Next, we'll use a remote checkout and bring its work back.

Remote sandboxes: A shell somewhere else on YouTube

Transcript

The same idea works with a prepared remote machine. Open a shell, run an agent and bring the result home. A remote sandbox has its own checkout, so its changes don't immediately change your Mac's files. We'll use recorded output from a local SSH test box to show the review steps.

For everyday use, choose your prepared remote environment in Settings, Sandboxes. Cloud sandbox keys live on that page too. Or name the target at runtime, as this example does. Replace review demo with your own configured host. Add shell or your agent of choice. Runtime choices take priority over project settings and saved defaults.

Use a remote machine for a shared toolchain, a longer agent task or a development preview. Targets include SSH, Google Cloud, AWS and a Fly option labeled Fly Sprites in the app. The current Fly connection uses a prepared Fly application. This guide doesn't create a cloud machine.

Your sandbox can send recorded work directly to the local recorder on your Mac, normally on port seven three one seven. That path doesn't need Tokematic's hosted server. Enable the recorder in Sandboxes, then check pairing and reachability. SSH, Google Cloud and AWS add a return tunnel. The current Fly connection needs separate routing.

After a task, use box diff to inspect the remote changes. This demo has one deliberate sample edit. Keep the same target for each command. Our example uses manual review; with the default branch setting, an interactive remote session can also create a review branch when it exits.

Use box pull to bring back a snapshot, including uncommitted changes. Here we name the review branch so it's easy to find. This is code from the sandbox. It is different from tmatic pull on its own, which receives session records. Pulling this branch does not switch your current branch.

Compare your current branch with the review branch using git diff. Here's our one-line change. You can inspect the result before changing the files you are working on. For a real task, review the full change and run the project's checks.

Box apply is the separate step that changes your Mac's working files. It refuses tracked file deletions by default unless you explicitly allow them. After applying, check the local diff before committing. If you only needed to inspect the work, stop at the review branch.

Choose your remote target, open your shell or agent and do the task. Then inspect the diff, pull a review branch and decide what to keep. Save defaults for the shortest command, or choose them at runtime whenever you need a different setup.

tmatic box lets you run any supported agent harness in an isolated local Docker container or cloud VM while keeping your host credentials safe, your git tree clean and every session recorded in your local Tokematic store.

Launching a Sandbox

From any Git repository, launch your default sandbox and harness with:

tmatic box
tmatic box -y

Before starting Docker Desktop, building a missing image or mounting/syncing a host folder for the first time, tmatic box asks for confirmation (or accepts -y / --yes on the command line) and remembers approved folders in box.json. By default it mounts only the current Git repository root (--mount repo) at the identical path inside the sandbox; pass --mount <dir> (or tmatic box config --mount-root <dir>) to choose a different folder.

Or pick a specific harness and target on the command line:

tmatic box claude
tmatic box codex
tmatic box agy
tmatic box kimi
tmatic box shell
tmatic box --mount ~/Code claude
tmatic box --box sprite://my-sandbox codex
tmatic box --box gcp://yolo-west claude

Building and Customizing the Sandbox Container

Tokematic embeds a reproducible sandbox image definition (tokematic-yolo:latest) that includes:

  • Agent harnesses: Claude Code (claude), Codex (codex), Antigravity (agy), Kimi Code (kimi) and the Linux tmatic collector.
  • Languages and runtimes: Node.js 22 (with Corepack and Yarn), Python 3 (pip) and the full Rust/LLVM toolchain (rustup, rustc, cargo, rustfmt, clippy, rust-analyzer, rust-src, llvm-tools-preview, clang, lld, lldb and gdb).
  • System utilities: git, ripgrep, fd, jq, sqlite3, tmux, man-db and all tmatic(1) manual pages pre-installed.

When you run tmatic box against local Docker, it automatically starts Docker Desktop on macOS if the daemon is stopped, builds the configured image if missing and creates the container with persistent credential volumes and your chosen workspace mount.

You can also inspect, rebuild or customize the container at any time:

# Print the embedded standard Dockerfile or rebuild tokematic-yolo:latest
tmatic box dockerfile
tmatic box build

# Layer extra Debian packages or build from a custom Dockerfile
tmatic box build --package graphviz --package postgresql-client
tmatic box build --dockerfile ./Dockerfile.sandbox --tag my-sandbox:latest

# Save global or per-repository container and mount defaults
tmatic box config --mount-root repo --add-package graphviz
tmatic project box --image tokematic-yolo:latest --package graphviz --mount repo

Every box image includes a Linux copy of tmatic that matches your app. It runs inside the box and reports its sessions to your computer, so they appear in Usage, Sessions and Live Pulse. The app carries this copy for both Apple silicon and Intel Docker hosts. To build with a different Linux tmatic, point TMATIC_BOX_LINUX_BIN at it:

TMATIC_BOX_LINUX_BIN=~/Downloads/tmatic-aarch64 tmatic box build

Syncing Harness Sign-Ins Without Copying Host Keys

Seed or refresh your agent OAuth tokens and unattended-mode settings inside the sandbox with:

tmatic box sync

For cloud targets (sprite, gcp, aws), store provider API keys in the macOS Keychain via standard input so they never appear in shell history (~/.zsh_history) or process arguments (ps):

pbpaste | tmatic box key set sprite
tmatic box key status

Getting Code On and Off Remote Sandboxes (sprite, gcp, aws, ssh)

Remote cloud sandboxes never need your personal GitHub SSH keys on the remote VM:

  1. Pushing your repository on launch: When tmatic box connects to a remote target, it streams git bundle create - --all over the SSH connection into the identical path on the remote VM, checks out your current HEAD, applies uncommitted tracked edits (git diff HEAD --binary) and streams untracked non-ignored files (git ls-files --others --exclude-standard) via tar.
  2. Automatic exit snapshot (apply: "branch"): When an interactive remote session exits with modified files, tmatic box snapshots both committed and uncommitted changes into a local box/<target>-<timestamp> branch on your Mac.
  3. Inspect changes: Run tmatic box diff (or tmatic box diff --stat) to review uncommitted edits and untracked files inside the sandbox.
  4. Pull into a branch: Run tmatic box pull to snapshot HEAD plus any uncommitted tracked and untracked edits from the sandbox into a local box/<id> branch on your Mac without disturbing your host working tree.
  5. Apply to your working tree: Run tmatic box apply to apply tracked changes and untracked non-ignored files to your host checkout. By default, tmatic box apply refuses to delete tracked files on your host unless you explicitly pass --allow-delete.
  6. Reset the sandbox: Run tmatic box reset to return the sandbox checkout to a clean HEAD.

Forwarding Preview Ports

Forward a web or API server running inside the sandbox to 127.0.0.1 on your Mac:

tmatic box --port 3000 --port 8787:8787
tmatic box port 5173

Next video: Choose where your work goes

2. For Engineers: Pace, Sandboxes & Proving Value

All guides