gh) so agents can branch, commit, push, and open pull requests from a repo checkout.
Prerequisites: git installed with the working directory inside a repository (
github_create_branch, github_commit_and_push); origin remote configured for push; gh CLI installed and authenticated via gh auth login (github_create_pull_request). user.email should match the identity you expect to author commits — the foreign-author guard reads git config user.email.Quick Start
1
Simple Usage
2
With Configuration
How It Works
You don’t have to think about branch safety — the tool quietly does the right thing.
User: “Commit and push what I have.”
Agent: (tool auto-creates praisonai/fix-login-a1b2c3, pushes there, and reports the branch name back)
Tools
github_create_branch(branch_name: str) -> str
Creates and checks out a new branch (git checkout -B).
Returns a success message or an error string.
github_commit_and_push(commit_message, branch=None, allow_unsafe_branch=False) -> str
Stages all changes, commits, and pushes to origin — with branch-safety guardrails that refuse unsafe pushes and never force-push.
Returns a success message,
"No changes to commit.", or an error string.
Branch-safety rules
The tool checks these rules before committing, so a refusal leaves your changes intact.- Agent branches are always allowed. Any branch whose name starts with
praisonai/skips the default and foreign-author checks. - The default branch is never pushed directly. On
main(or whenbranch="main"), the tool creates a freshpraisonai/{slug}-{6hex}branch from HEAD and pushes there instead. - Foreign commits are refused. If the target branch carries commits authored by someone other than your
git config user.email, the push stops. - Divergence is refused, never forced. If the remote branch is not an ancestor of HEAD, the push stops — this is never overridable.
- Override with care.
allow_unsafe_branch=True(or envPRAISONAI_GIT_ALLOW_UNSAFE_BRANCH=true) bypasses rules 2 and 3, but never rule 4.
github_create_pull_request(title, body, head_branch, base_branch="main") -> str
Creates a pull request via gh pr create.
gh is missing or unauthenticated.
Common patterns
- Auto-branch (safest)
- Full PR flow
- Non-main base
- PR only
Best practices
Authenticate gh once
Authenticate gh once
Run
gh auth login before agents call github_create_pull_request. The tool checks gh auth status first.Keep commits scoped
Keep commits scoped
github_commit_and_push stages all changes (git add .), so review the working tree for a tidy commit. An over-broad git add . no longer risks an over-broad push to main — the tool refuses unsafe pushes before committing.Prefer the auto-branch flow
Prefer the auto-branch flow
Leaving
branch=None while on the default branch is the safest, one-line way to ship a change. The tool picks a praisonai/… name, pushes there, and reports the name in its return string.When to set allow_unsafe_branch
When to set allow_unsafe_branch
Only for a branch you own (e.g.
release/v2) that carries commits by someone other than the current committer — never for the default branch as a habit. Set env PRAISONAI_GIT_ALLOW_UNSAFE_BRANCH=true for CI. Divergence (force-push) is never allowed regardless.Write descriptive PR bodies
Write descriptive PR bodies
Include what changed, why, and linked issues — the
body field supports markdown.Handle missing CLI gracefully
Handle missing CLI gracefully
Tools return error strings rather than raising — check return values in hooks if you need hard failures.
Related
Linear Bot
Example workflow using GitHub tools
Shell Tools
Similar CLI-wrapping tools

