@notlebedev/pi-direnv

direnv / nix flake dev shell environment integration for the pi coding agent

Packages

Package details

extensionskill

Install @notlebedev/pi-direnv from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@notlebedev/pi-direnv
Package
@notlebedev/pi-direnv
Version
0.2.1
Published
Dec 2, 2026
Downloads
not available
Author
notlebedev
License
MIT
Types
extension, skill
Size
46.5 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./direnv.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-direnv

npm CI

A pi extension that loads a project's direnv environment into Pi's bash tool and keeps it up to date as you change your dev shell. Add a package to your Nix flake, reload, and use it without restarting Pi.

What it does

  • Loads the project's .envrc environment when a Pi session starts. Like direnv itself, .envrc is discovered by walking up from the session's working directory, and the loaded environment applies to the whole tree rooted at the .envrc directory. The agent's bash tool and ! / !! commands use it.
  • Reloads the environment when the dev shell's inputs change. It uses direnv's own record of the files it tracks (DIRENV_WATCHES), so watch_file / watch_dir entries and flake inputs are honored without configuration; new packages and variables are available to agent right away.
  • Reminds the agent when the environment needs reloading. The agent can reload it automatically, or you can use /direnv reload.
  • Provides /direnv for status, /direnv reload to reload, and /direnv allow to approve the .envrc and reload.

Install

Install the published package for your user (all projects):

pi install npm:@notlebedev/pi-direnv

To install for the current project instead (requires project trust):

pi install --local npm:@notlebedev/pi-direnv

Pin a version with @0.2.1, for example npm:@notlebedev/pi-direnv@0.2.1. You can also add the package to the packages list in your Pi settings, or install straight from git:

pi install git:github.com/NotLebedev/pi-direnv@v0.2.1

Once published, the package appears in the Pi package gallery.

You need direnv on your PATH, a .envrc in the project root, and an approved .envrc. Approve it yourself with direnv allow (or /direnv allow in Pi). The extension never approves .envrc files automatically.

pi-direnv includes a direnv-dev-shell skill for tasks that need a missing command or require changes to the project's dev shell. It guides the agent to make minimal shell changes, call direnv_reload, and verify the updated Bash environment. It also tells the user when a dev-shell file changes and treats task-only package additions as temporary unless they are needed project-wide. The skill preserves the explicit .envrc approval boundary. Pi can load it automatically when relevant; invoke it directly with /skill:direnv-dev-shell when needed.

Quick start

For a Nix flake project, put this in .envrc:

use flake

Define a dev shell in flake.nix, then approve the environment and start Pi:

direnv allow
pi

Reload workflow

  1. At session start, pi-direnv loads .envrc so the agent's bash commands use the project's environment.
  2. You or the agent adds a package or changes dev-shell configuration.
  3. pi-direnv notices that direnv's tracked inputs changed, marks the environment stale, and reminds the agent to call direnv_reload. This tool reloads direnv and injects the updated environment into the bash tool.
  4. The agent can now use the new package in bash, without restarting Pi.

You can also reload manually with /direnv reload. If .envrc changed, approve it first with /direnv allow.

Compatibility

Another extension that overrides Pi's bash tool can prevent this extension from applying the environment. If the dev shell is not available in bash, remove the conflicting extension or make sure pi-direnv loads first; then run /reload.

Development

Requires Node.js 22.19 or newer. With Nix, enter the provided development shell using nix develop, then run:

npm install
npm test
npm run typecheck