EXAMPLE 07
  • editors
  • devcontainers

Attach VS Code

Open any instance in VS Code with one key.


The problem

An agent works in instance fix-login and you want to read its diff, step through a test or poke at the running app in your editor. With several instances of one repo open, the windows all look alike, and an editor that attaches as the wrong user hits permission errors on the first save.

devsandbox vscode (or o in the dashboard) opens a window attached to the instance’s container, as the sandbox’s remoteUser, with the sandbox’s extensions, titled after the instance.

Try it

No config needed, only VS Code with the Dev Containers extension and code on your PATH. With instances fix-login and add-search running:

TERMINAL
devsandbox vscode fix-login     # a window titled fix-login
devsandbox vscode add-search    # a second one, titled add-search

In the dashboard, select an instance and press o, or type :code add-search.

How it works

  • VS Code attaches to the container devsandbox already made, as remoteUser if set.
  • Extensions in the sandbox’s customizations.vscode.extensions are installed on attach.
  • The window opens /workspaces/<instance>.code-workspace, which is what names it.
  • customizations.vscode.settings is ignored (accepted but ignored): keep settings in the repo’s .vscode/settings.json.
  • Apple container is experimental: set dev.containers.experimentalAppleContainerSupport to true in VS Code first.

Source: site/src/content/examples/vscode.mdxEdit this page on GitHub(opens in a new tab)

MENU /
View on GitHub
EXAMPLES
All examplesEvery recipe on one page.Parallel coding agentsSeveral coding agents on one repo, fully isolated from one another.One shared PostgresOne development database for all your sandboxes and their instances.Private services per instanceEvery instance gets its own Postgres and Redis, so agents never touch each other's data.Shared package cachesNew sandboxes stop downloading the same packages again.ssh-agent and git pushAgents push over ssh with your host's keys, which never enter the container.Port forwarding on demandOpen a sandbox's dev server or database from your host, without restarting anything.Attach VS CodeOpen any instance in VS Code with one key.devcontainer FeaturesAdd Node, Rust or the GitHub CLI to any image, in TOML.Babysit pull requestsAn agent keeps your open PRs merged with their base, and pings you when it can't.Port a devcontainer.jsonTurn an existing devcontainer.json into a devsandbox config.