pi-git-commit
v1.0.1
Published
Pi extension: block mutative git commands in bash and provide a git_commit tool plus /commit and /toggle-allow-git commands
Maintainers
Readme
pi-git-commit
Keeps mutative git operations out of the agent's bash and provides a safe, reviewable commit flow in pi-coding-agent: a bash guard, a git_commit tool, and /commit + /toggle-allow-git commands.
What you get
- Bash git guard. Mutative git commands are blocked in the agent's bash tool —
add,commit,push,pull,merge,rebase,reset,clean,rm,restore,switch,cherry-pick,revert,mv,init,clone, plus destructive forms ofbranch,tag,checkout,stash,submodule,worktree,config,remote,apply,notes,update-ref,gcand more. Read-only commands (status,diff,log,fetch,branch,tag,stash list, ...) stay allowed. git_committool. The agent stages everything and commits with aFIX/IMPROVE/NEWtype prefix. Enabled automatically on session start./commitcommand. Waits for queued messages to finish, stages all changes, shows the staged diff, and asks the agent to review it and commit viagit_commit— never via bash./toggle-allow-gitcommand. Temporarily allows mutative git commands in bash for the current session. The guard re-arms on the next session.
Quick start
- Make your changes, then run:
/commitThe extension stages the working tree and hands the staged diff to the agent with instructions to review it.
The agent commits using the
git_committool:
{
"type": "FIX",
"message": "Fix off-by-one in the retry loop"
}- If you need to run mutative git yourself, allow it for the session:
/toggle-allow-gitInstallation
pi install npm:pi-git-commitFrom a local checkout:
pi install /path/to/pi-git-commitThe git_commit tool
| Field | Description |
| --- | --- |
| type | FIX (bug fix), IMPROVE (improvement), or NEW (new feature). |
| message | Commit message in imperative mood. Multi-line allowed for detailed changes. |
The tool runs git add . followed by git commit -m "<TYPE>: <message>" and reports staging or commit failures as tool errors. The agent is instructed to only use it after you run /commit.
The bash guard
The guard intercepts tool_call events for the bash tool and blocks commands that match mutative git forms. The block list is a conservative superset: anything that can change repository state is blocked, while a curated set of read-only forms is explicitly allowed (for example git fetch, git stash list, git remote -v, git config --get, git apply --check, git checkout -- <file>, git submodule status, git worktree list).
A blocked command returns:
Mutative git commands are blocked. Use /toggle-allow-git to allow for this session.Troubleshooting
- The agent refuses to commit. The guard blocks
git commitin bash by design. Run/commitand let the agent use thegit_committool. - "Nothing to commit (empty diff)." There are no staged changes — make edits first, then run
/commitagain. - I need git in bash right now. Run
/toggle-allow-git; the guard re-arms automatically on the next session start.
Development
Requires Node.js ≥ 22.19 and npm.
npm install
npm test
npm run typecheckCredits
- badlogic, pi-coding-agent and the tool/command APIs
