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.

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.
  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") -> 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 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.
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