> ## Documentation Index
> Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Pi coding agent

> Run the Pi terminal coding agent in an isolated project copy

Pi is a terminal coding agent distributed as a Node.js package. This example pins the tested package version and gives it a copied workspace inside the microVM.

## Run Pi

<Steps>
  <Step title="Start Pi">
    <Tooltip tip="This agent works on microsandbox cloud after omitting replace-on-create from the command."><span className="msb-badge-limited">Limited on cloud <Icon icon="circle-info" size={11} /></span></Tooltip>

    <CodeGroup>
      ```sh macOS & Linux theme={null}
      msb run -t --name pi-demo --replace \
        --cpus 2 --memory 2G --root-disk 4G \
        --copy-dir ./my-project:/workspace \
        --workdir /workspace \
        node:24-bookworm-slim -- sh -lc '
          apt-get update &&
          apt-get install -y --no-install-recommends ca-certificates git &&
          npm install -g @mariozechner/pi-coding-agent@0.73.1 &&
          exec pi
        '
      ```

      ```powershell Windows theme={null}
      msb run -t --name pi-demo --replace `
        --cpus 2 --memory 2G --root-disk 4G `
        --copy-dir ./my-project:/workspace `
        --workdir /workspace `
        node:24-bookworm-slim -- sh -lc '
          apt-get update &&
          apt-get install -y --no-install-recommends ca-certificates git &&
          npm install -g @mariozechner/pi-coding-agent@0.73.1 &&
          exec pi
        '
      ```
    </CodeGroup>

    The tested install downloads 188 packages and takes about a minute on a warm Node image cache. Configure a provider from the TUI when prompted.
  </Step>

  <Step title="Start another session">
    After leaving Pi, return to the same sandbox and workspace with:

    ```sh theme={null}
    msb exec -t pi-demo -- pi
    ```
  </Step>

  <Step title="Verify the installation">
    Exit Pi and run:

    ```sh theme={null}
    msb exec pi-demo -- pi --version
    ```

    The pinned example prints `0.73.1`.
  </Step>

  <Step title="Export changes">
    Create a patch inside the sandbox:

    ```sh theme={null}
    msb exec pi-demo -- sh -lc 'cd /workspace && git add -N . && git diff --binary > /tmp/pi.patch'
    ```

    Copy the patch to the host:

    ```sh theme={null}
    msb cp pi-demo:/tmp/pi.patch ./pi.patch
    ```

    Check that it applies cleanly before applying it:

    ```sh theme={null}
    git apply --check ./pi.patch
    ```
  </Step>

  <Step title="Clean up">
    ```sh theme={null}
    msb rm -f pi-demo
    ```
  </Step>
</Steps>

## Reference

* [Pi repository](https://github.com/badlogic/pi-mono)
