devsandbox 0.10.0

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
---
title: Shared package caches
description: New sandboxes stop downloading the same packages again.
order: 3
icon: hard-drive
tags: [caches, performance]
related: [parallel-agents, services, port-a-devcontainer]
---

import AgentPrompt from '../../components/AgentPrompt.astro';
import AgentPromptLink from '../../components/AgentPromptLink.astro';

## The problem

Each new container starts with an empty package cache, so every instance downloads the same dependencies again. Each name in `caches` is one directory in the config dir's `shared-volumes/`, mounted into every sandbox that lists it.

<AgentPromptLink />

## Config

```toml title="devsandboxes.toml"
[template.base]
image = "node:22"
caches = ["npm"]            # one npm cache for every sandbox and instance

[sandbox.web]
extends = "base"
folder = "../web"
postCreateCommand = "npm install"
```

## Try it

```bash
devsandbox run web                     # npm install fills shared-volumes/npm
devsandbox run web --name fix-login    # served from the cache
```

## How it works

- Valid names are `pnpm`, `cargo`, `npm`, `yarn`, `go` and `pip`. Each sets the tool's env vars to its mount.
- `rm` and `gc` leave caches alone. Delete a directory in `shared-volumes/` to start that cache over.

## Agent instructions

<AgentPrompt
  goal="Share package caches across my devsandbox sandboxes so new instances stop re-downloading dependencies."
  steps={[
    'Find which package managers my sandboxes use and add them to `caches`, in a template every sandbox `extends` if there is one.',
  ]}
  verify={[
    'Existing instances now drift: list them with `devsandbox -C <config dir> ps -a` and ask me before running `devsandbox -C <config dir> rebuild <instance>` on each.',
  ]}
/>