npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-worktree

v1.3.3

Published

Git worktree management for Pi — create isolated workspaces with one command, optionally launch in cmux/tmux.

Downloads

825

Readme

pi-worktree

Git worktree management for Pi Coding Agent. Create isolated dev environments with one command — each with its own branch, database, dependencies, and ports.

Inspired by claude --worktree from Claude Code.

Why?

When working on multiple features in parallel (or running multiple AI coding agents), you need full isolation — not just a git branch, but separate node_modules, databases, env files, and dev server ports. Git worktrees provide the branch isolation; pi-worktree automates everything else via project-level hooks.

One command gets you:

  • A fresh git worktree on its own branch
  • A dedicated database (via createdb or any command you configure)
  • A generated .env.local with worktree-specific config
  • Installed dependencies (npm install / bun install)
  • Applied migrations or schema pushes
  • Pi running in the worktree directory, ready to code

Install

pi install pi-worktree

If Pi is already running, use /reload to pick up the new extension.

Usage

# Create a worktree and start Pi in it
pi --worktree my-feature

# Auto-generated name (e.g. "calm-fox")
pi --worktree

# From within a Pi session
/worktree my-feature
/worktree destroy my-feature
/worktree list

When cmux or tmux is detected, Pi relaunches itself in the worktree directory within the same terminal. Without a multiplexer, it prints the path for manual cd && pi.

Project configuration

Create .pi/worktree.json in your repo root (commit it so all contributors share the same setup). Run /skill:worktree-setup for interactive setup, or create it manually:

{
  "dir": ".worktrees",
  "branchPrefix": "worktree/",
  "linkEnvFiles": true,
  "postCreate": [
    "npm install",
    "npx prisma db push"
  ],
  "preRemove": [
    "dropdb --if-exists myapp_$(basename $PWD) 2>/dev/null || true"
  ]
}

| Key | Default | Description | |-----|---------|-------------| | dir | .worktrees | Directory for worktrees (relative to repo root) | | branchPrefix | worktree/ | Branch name prefix | | linkEnvFiles | true | Symlink gitignored .env* files (except .env.local) from main repo | | postCreate | [] | Shell commands run after creation (cwd = worktree) | | preRemove | [] | Shell commands run before removal (cwd = worktree) |

Don't forget to add the worktree directory to .gitignore:

.worktrees/

How it works

Create (pi --worktree my-feature or /worktree my-feature):

  1. git worktree add -b worktree/my-feature .worktrees/my-feature HEAD
  2. Symlinks gitignored .env* files (except .env.local) from the main repo
  3. Runs each postCreate command in order
  4. Relaunches Pi in the worktree directory

Destroy (/worktree destroy my-feature):

  1. Runs each preRemove command
  2. git worktree remove --force .worktrees/my-feature
  3. git branch -D worktree/my-feature

Relaunch strategy: Pi's tools (bash, read, edit, etc.) bind to the working directory at startup via closure — there is no way to change it mid-session. When a worktree is created from the main repo, Pi shuts down and injects cd <worktree> && pi into the terminal via cmux send or tmux send-keys, so Pi restarts with the correct cwd.

Examples

Node.js + PostgreSQL + Prisma

Each worktree gets its own database and .env.local:

{
  "postCreate": [
    "printf 'DATABASE_URL=postgres://localhost:5432/myapp_%s\\n' $(basename $PWD) > .env.local",
    "createdb myapp_$(basename $PWD) 2>/dev/null || true",
    "npm install",
    "npx prisma db push"
  ],
  "preRemove": [
    "dropdb --if-exists myapp_$(basename $PWD) 2>/dev/null || true"
  ]
}

Bun monorepo with per-worktree staging

For monorepos where each worktree needs a unique stage name (for isolated dev server ports), database, and environment:

{
  "postCreate": [
    "WT=$(basename $PWD); DB=myapp_$(echo $WT | tr '-' '_'); printf 'STAGE=%s\\nDATABASE_URL=postgres://localhost:5432/%s\\n' \"$WT\" \"$DB\" > .env.local",
    "DB=$(grep DATABASE_URL .env.local | sed 's|.*/||'); createdb \"$DB\" 2>/dev/null || true",
    "bun install",
    "bun run prisma:generate",
    "bun run prisma:push"
  ],
  "preRemove": [
    "DB=$(grep DATABASE_URL .env.local 2>/dev/null | sed 's|.*/||'); [ -n \"$DB\" ] && dropdb --if-exists \"$DB\" 2>/dev/null || true"
  ]
}

This pattern works well for projects that derive dev server ports from the stage name, giving each worktree fully isolated services.

Update

pi update pi-worktree

License

MIT