Skip to main content
GitHub tools wrap local git and the GitHub CLI (gh) so agents can branch, commit, push, and open pull requests from a repo checkout.
The user describes a git workflow; the agent runs GitHub tools to branch, commit, push, and open a pull request.
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.
Approval required (SDK PR #6063): github_create_branch, github_commit_and_push, and github_create_pull_request are high-risk tools. Interactive agents (TTY) are prompted before each call; non-interactive agents (gateway hooks, CI, schedulers) are denied unless you set PRAISONAI_TOOL_SAFETY=off, PRAISONAI_AUTO_APPROVE=true, or pass an explicit approval= policy. See Approval.

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, and only your tracked edits (plus any files you list in paths) are committed — untracked files like a new .env or build output are never swept in.
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, repo_path=None) -> 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, repo_path=None, paths=None) -> str

Stages tracked changes (plus any paths you list), 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. Untracked files alone don’t count as changes — list them in paths to commit them.

Branch-safety rules

The tool checks these rules before staging anything, so a refusal leaves your index and working tree untouched.
  1. Agent branches are always allowed. Any branch whose name starts with praisonai/ skips the default and foreign-author checks.
  2. The default branch is never pushed directly. On main (or when branch="main"), the tool creates a fresh praisonai/{slug}-{6hex} branch from HEAD and pushes there instead.
  3. Foreign commits are refused. If the target branch carries commits authored by someone other than your git config user.email, the push stops.
  4. Divergence is refused, never forced. If the remote branch is not an ancestor of HEAD, the push stops — this is never overridable.
  5. Override with care. allow_unsafe_branch=True (or env PRAISONAI_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", repo_path=None) -> str

Creates a pull request via gh pr create.
Returns a success message with the PR URL, or an error if gh is missing or unauthenticated.

Common patterns

Best practices

Run gh auth login before agents call github_create_pull_request. The tool checks gh auth status first.
github_commit_and_push stages only tracked changes (git add -u -- .). New (untracked) files are committed only when you list them in the paths argument — an untracked .env or build output is never swept in. Staging also runs after the branch-safety checks, so a refused push leaves the index untouched.
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.
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.
Include what changed, why, and linked issues — the body field supports markdown.
Tools return error strings rather than raising — check return values in hooks if you need hard failures.

Linear Bot

Example workflow using GitHub tools

Shell Tools

Similar CLI-wrapping tools