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

@gotgenes/pi-nocd

v2.0.0

Published

Pi extension that injects the resolved working directory into the system prompt so the agent never cd-prefixes the current working directory

Readme

@gotgenes/pi-nocd

npm version CI License: MIT TypeScript pnpm Pi Package

Pi extension that adds an instruction to the system prompt forbidding the agent from cd-prefixing the current working directory.

Requires Pi 1.0.0 or later.

Why

Pi already tells the agent the resolved CWD: its system prompt carries a <cwd> section naming the path, and that section survives downstream shaping (for example pi-anthropic-auth, which only rewrites Pi's own tools, rules, and docs sections).

What Pi ships nowhere — default or shaped — is any instruction against cd-prefixing the CWD. The <cwd> section is a bare statement of fact, not a rule, so the habit of prefixing commands with cd $(pwd) && survives.

This extension hooks before_agent_start and adds a prompt section that supplies the missing prohibition — forbidding both the literal cd <path> && form and the generic cd $(pwd) && form. It repeats the literal resolved path (from ctx.cwd) only to make the forbidden cd <path> && example concrete, not because the path is otherwise unavailable to the agent.

Because the section names a literal path, each session writes its own. A subagent session runs its own copy of this extension, which writes a section naming the child's directory, so a child given an isolated workspace (for example a git worktree from @gotgenes/pi-subagents-worktrees) is told where its own shell commands execute. @gotgenes/pi-subagents drops everything from the parent's <cwd> section onward when it builds a child's prompt, so the parent's section is not carried along.

Install

pi install npm:@gotgenes/pi-nocd

Or add it to your Pi settings (~/.pi/agent/settings.json):

{
  "packages": ["npm:@gotgenes/pi-nocd"]
}

What it injects

For a session whose working directory resolves to /Users/you/project, Pi renders the following section right after its own <cwd> section (the instruction is one line in the prompt, split here at its sentences):

<working_directory>
Shell commands already execute in `/Users/you/project`.
Never prefix a command with `cd` into the current working directory — neither `cd /Users/you/project &&` nor `cd $(pwd) &&`.
Just run the command directly.
</working_directory>

The extension writes the section through systemPromptOptions.sections and never returns a replacement system prompt. A returned prompt would become Pi's forced prompt, which drops every section a later handler adds, such as the <mcp_servers> section Pi's built-in MCP support writes.

The converse also holds: when another extension returns a systemPrompt from before_agent_start before this one runs, Pi ignores every later section edit, and this section is dropped with them.

How it works

| Hook | Behavior | | -------------------- | ------------------------------------------------------------------------ | | before_agent_start | Writes the working_directory prompt section for the resolved ctx.cwd |

Scope and non-goals

Purpose. Pi tells the agent its working directory but never forbids cd-prefixing it. This extension supplies the missing prohibition — and nothing else.

In scope. The wording of the section, and naming the right directory when a child session runs in an isolated workspace.

Non-goals.

  • Enforcing the rule. This extension instructs; it does not gate a command at execution time.
  • Editing prompt text it did not write. The extension reads no prompt text, so another source's working-directory guidance is neither rewritten nor deduplicated.
  • Telling the agent what its working directory is. Pi's own <cwd> section already does that; the literal path appears here only to make the forbidden example concrete.
  • Registering tools or commands. The entire surface is one before_agent_start hook, with no configuration.

License

MIT