safe-coder
Safe Coder is a configuration package for the [`pi` coding agent](https://www.npmjs.com/package/@mariozechner/pi-coding-agent) that adds **safety guardrails** and **project-specific** extensions to reduce risky operations while you code with an AI assista
Package details
Install safe-coder from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:safe-coder- Package
safe-coder- Version
1.0.4- Published
- Apr 30, 2026
- Downloads
- 324/mo · 29/wk
- Author
- discountry
- License
- ISC
- Types
- extension, skill, theme, prompt
- Size
- 140.8 KB
- Dependencies
- 0 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./extensions"
],
"skills": [
"./skills"
],
"prompts": [
"./prompts"
],
"themes": [
"./themes"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
Safe Coder
Safe Coder is a configuration package for the pi coding agent that adds safety guardrails and project-specific extensions to reduce risky operations while you code with an AI assistant.
This project is meant to be used as a dependency or a template: you point pi at this package, and it will load its extensions and skills automatically.
Installation
# install pi coding agent
npm install -g @mariozechner/pi-coding-agent
# install safe coder
pi install npm:safe-coder
Features
- Permission gate for dangerous shell commands
- Intercepts
bashtool calls that look dangerous, such as:rm -rf, recursive removesudocommandschmod/chownwith777
- Prompts for explicit confirmation before allowing these commands to run.
- Intercepts
- Workspace boundary enforcement
- Blocks file tools (
read,write,edit) when they target paths outside the current working directory wherepiwas started, unless you explicitly allow them. - Flags shell commands that appear to touch absolute paths, home-relative paths (
~/), or../-style traversal and asks for confirmation.
- Blocks file tools (
- Protected path guard
- Fully protects any
.envfiles (no read, write, or edit allowed via tools). - Blocks write/edit attempts into common sensitive locations like
.git/andnode_modules/.
- Fully protects any
- Skill-based workflows
- Ships with a
skills/skills.txtreference that documents howpidiscovers and uses Agent Skills. - Compatible with the Agent Skills specification.
- Ships with a
Project Layout
package.json- Declares this package as
safe-coder. - Configures
pito load from:./extensions./skills./prompts./themes
- Declares this package as
extensions/permission-gate.ts- A
piextension that listens totool_callevents and:- Detects dangerous shell commands via regex heuristics.
- Detects file operations that leave the current working directory.
- Uses
ctx.ui.selectto ask the user whether to allow or block the call.
- A
extensions/protected-paths.ts- A
piextension that:- Completely blocks all access to
.envpaths. - Blocks
writeandedittool calls into.git/andnode_modules/. - Optionally notifies the user when an operation is blocked.
- Completely blocks all access to
- A
skills/- Currently contains
skills.txt, which documents how Agent Skills work and howpidiscovers and validates them.
- Currently contains
Requirements
- Node.js (version compatible with
@mariozechner/pi-coding-agent). pnpmas package manager (seepackageManagerfield inpackage.json).- The
picoding agent installed and available on your system.
Installation
You can add this project to another workspace or clone it as a starting point.
git clone <this-repo-url> safe-coder
cd safe-coder
pnpm install # if you add dependencies later
Because this package primarily provides configuration, there are no runtime scripts defined apart from the default test placeholder.
Using with pi
Point pi at this project so it can load its extensions and skills. For example, from the project root:
cd /path/to/safe-coder
pi .
When pi starts:
- It discovers extensions from the
pi.extensionsentry inpackage.jsonand loads:extensions/permission-gate.tsextensions/protected-paths.ts
- It discovers skills via the
pi.skillsentry and anySKILL.md/skill files underskills/.
You will then see:
- Confirmation prompts when the assistant attempts potentially dangerous or out-of-bounds commands.
- Warnings and blocks when the assistant tries to touch protected paths.
Customization
- Adjust dangerous patterns
- Edit
extensions/permission-gate.tsto add or refine regex patterns for dangerous commands or external paths.
- Edit
- Change protected paths
- Edit
extensions/protected-paths.tsand update theprotectedPathsarray or the.envhandling logic.
- Edit
- Add skills
- Create new skill directories under
skills/following the Agent Skills format (each with aSKILL.mdfile and optional scripts/docs). - Update descriptions so the assistant knows when to use each skill.
- Create new skill directories under
Development Notes
- The TypeScript extensions currently use
// @ts-nocheckfor simplicity. You can progressively add types and strictness as needed. - Follow the Agent Skills and
piextension best practices to keep new skills and extensions small, focused, and easy to review for safety.