---
title: Gemini CLI
description: Run Google's Gemini CLI against a project on your host
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 mounted from your host, while Gemini authentication and settings live on the sandbox's root disk.

## Run Gemini CLI

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

<Tooltip tip="Writable host-directory mounts are local-only. On microsandbox cloud, use the isolated-copy alternative and omit replace-on-create."><span className="msb-badge-local">Local-only <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 \
  --mount-dir ./my-project:/workspace:rw \
  --workdir /workspace \
  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 `
  --mount-dir ./my-project:/workspace:rw `
  --workdir /workspace `
  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 mounted project, then continue to authentication.

<Tip>
  For an isolated workspace, or when using microsandbox cloud, replace `--mount-dir ./my-project:/workspace:rw` with `--copy-dir ./my-project:/workspace`.
</Tip>

<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="Review or export changes">

With the default writable mount, changes are already in the host checkout. Review them inside the sandbox:

```sh
msb exec gemini-demo -- sh -lc 'cd /workspace && git status --short && git diff --stat && git diff'
```

If you chose the isolated `--copy-dir` alternative, 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
```

Removing the sandbox also removes its Gemini authentication and settings. Changes made through the default workspace mount remain in the host checkout.

</Step>
</Steps>

## Reference

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