---
title: "Using the Pi Coding Agent with Bun CLI | Ameya Shenoy"
description: "Use the Pi coding agent in a Bun environment with a shell wrapper for its CLI. A quick reference from Ameya Shenoy for running Pi with the Bun runtime."
canonical: "https://www.codingcoffee.dev/blog/pi-on-bun"
published: "2026-04-27"
tags: "notes"
---

# Working with Pi in a Bun environment

By Ameya Shenoy · Published 2026-04-27

Use the Pi coding agent in a Bun environment with a shell wrapper for its CLI. A quick reference from Ameya Shenoy for running Pi with the Bun runtime.

- Create a shim for Bun and place it in `$HOME/.local/bin/bun-as-npm`

> Sidenote: make sure `$HOME/.local/bin` is in your path

```sh
#!/usr/bin/env sh

case "$1" in
  install)
    shift
    # Translate "install -g <pkg>" → "add -g <pkg>"
    if [ "$1" = "-g" ] && [ -n "$2" ]; then
      shift
      exec bun add -g "$@"
    fi
    exec bun install "$@"
    ;;
  add)     shift; exec bun add "$@" ;;
  root)
    if [ "$2" = "-g" ]; then
      echo "${BUN_INSTALL:-$HOME/.bun}/install/global/node_modules"
      exit 0
    fi
    exit 1
    ;;
  view)    shift; exec bun info "$@" ;;
  uninstall|remove) shift; exec bun remove "$@" ;;
  *) exec bun "$@" ;;
esac
```

- Make the script executable

```sh
chmod +x "$HOME/.local/bin/bun-as-npm"
```

- Edit `pi`'s `settings.json` file to configure the bun shim as the npm replacement

```json
{
  "npmCommand": ["bun-as-npm"]
}
```

Done! You can now use `pi` in an environment having `bun` and not `npm`

---

Canonical page: https://www.codingcoffee.dev/blog/pi-on-bun

[Site guide](/llms.txt) · [Contact](/contact) · [Sitemap](/sitemap-index.xml)
