---
title: Gemini CLI
description: Run Google's Gemini CLI against a copied project in a microVM
icon: "/images/recipes/agents/gemini-cli.svg"
---

This example runs the official scoped Gemini CLI package inside a disposable Node.js microVM. The project is copied into the guest, while Gemini authentication and settings live in a named volume.

## Run Gemini CLI

<Steps>
<Step title="Start Gemini CLI">

<Tooltip tip="On microsandbox cloud, create the named volume first and omit replace-on-create from this command."><span className="msb-badge-limited">Limited on cloud <Icon icon="circle-info" size={11} /></span></Tooltip>

<CodeGroup>
```sh macOS & Linux
msb run -t --name gemini-demo --replace \
  --cpus 2 --memory 2G --root-disk 4G \
  --copy-dir ./my-project:/workspace \
  --workdir /workspace \
  --mount-named gemini-data:/root/.gemini \
  node:24-bookworm-slim -- sh -lc '
    apt-get update &&
    apt-get install -y --no-install-recommends ca-certificates git &&
    npm install -g @google/gemini-cli@0.52.0 &&
    exec gemini
  '
```

```powershell Windows
msb run -t --name gemini-demo --replace `
  --cpus 2 --memory 2G --root-disk 4G `
  --copy-dir ./my-project:/workspace `
  --workdir /workspace `
  --mount-named gemini-data:/root/.gemini `
  node:24-bookworm-slim -- sh -lc '
    apt-get update &&
    apt-get install -y --no-install-recommends ca-certificates git &&
    npm install -g @google/gemini-cli@0.52.0 &&
    exec gemini
  '
```
</CodeGroup>

Gemini CLI first asks whether you trust the workspace. Review the copied files, then continue to authentication. The sandbox cannot directly modify the original host directory.

<Warning>
  Install the scoped package exactly as shown: `@google/gemini-cli`. Do not substitute similarly named unscoped packages.
</Warning>

</Step>

<Step title="Start another session">

After leaving Gemini CLI, return to the same sandbox and workspace with:

```sh
msb exec -t gemini-demo -- gemini
```

</Step>

<Step title="Verify the installation">

Exit the TUI and run:

```sh
msb exec gemini-demo -- gemini --version
```

The pinned example prints `0.52.0`.

</Step>

<Step title="Export changes">

Create a patch inside the sandbox:

```sh
msb exec gemini-demo -- sh -lc 'cd /workspace && git add -N . && git diff --binary > /tmp/gemini.patch'
```

Copy the patch to the host:

```sh
msb cp gemini-demo:/tmp/gemini.patch ./gemini.patch
```

Check that it applies cleanly before applying it:

```sh
git apply --check ./gemini.patch
```

</Step>

<Step title="Clean up">

Remove the sandbox:

```sh
msb rm -f gemini-demo
```

Remove persisted Gemini data only when you no longer need it:

```sh
msb volume rm gemini-data
```

</Step>
</Steps>

## Reference

- [Gemini CLI installation](https://google-gemini.github.io/gemini-cli/docs/get-started/deployment.html)
