pi-git-guardrails
Native Pi extension that blocks dangerous git operations, including git calls hidden inside scripts.
Package details
Install pi-git-guardrails from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-git-guardrails- Package
pi-git-guardrails- Version
0.1.1- Published
- Apr 29, 2026
- Downloads
- not available
- Author
- ramaaudra
- License
- MIT
- Types
- extension
- Size
- 26.3 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-git-guardrails
Native Pi extension that blocks dangerous git operations before the assistant can run them. It also injects a temporary git shim into assistant Bash commands so nested scripts such as npm run release or ./deploy.sh are guarded too.
Install
From npm:
pi install npm:pi-git-guardrails
From GitHub:
pi install git:github.com/ramaaudra/pi-git-guardrails
Project-local install from GitHub:
pi install git:github.com/ramaaudra/pi-git-guardrails -l
Try a local checkout for one run:
pi -e ./pi-git-guardrails
Blocked by Default
git pushin all variantsgit reset --hardgit clean -f,git clean -fd,git clean --forcegit branch -Dand force branch deletiongit checkout .,git checkout -- .,git restore .
Path-specific restore/checkout remains allowed, for example git restore src/app.ts and git checkout -- src/app.ts.
Commands
/git-guardrails statusshows ON/OFF, session block count, pending allow-next, active rules, and recent audit entries./git-guardrails allow-next pushallows exactly one matchinggit push, including from nested scripts./git-guardrails off 5mdisables the guardrail temporarily. Supportss,m, andhsuffixes./git-guardrails onre-enables immediately and clears any temporary off timer.
Nested Script Protection
The extension prepends a session-local directory containing a git shim to PATH for assistant Bash calls. This catches normal git ... calls inside scripts, package scripts, Makefiles, and similar child processes.
Known limits:
- It does not catch scripts that call an absolute git path such as
/usr/bin/git. - It does not catch programs that use a Git library directly instead of spawning
git. - It is a coding-agent safety guardrail, not an OS-level sandbox.
Develop
npm test
npm run pack:dry-run
Publish
npm login
npm publish
If npm asks for a scoped public package flow in the future, use:
npm publish --access public
License
MIT