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).Quick Start
1
Simple Usage
2
With Configuration
How It Works
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: str) -> str
Stages all changes, commits, and pushes to origin on the current branch.
Returns a success message,
"No changes to commit.", or an error string.
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
- 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 .). Review the working tree before the agent commits.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

