A smart git commit, push, and PR tool. Works as a standalone CLI, with any AI agent, or as a Claude Code skill.
- Reads your staged diff and branch name
- Generates a structured commit message (via Claude, GPT-4o, or your
$EDITOR) - Extracts a ticket/issue ID from the branch name and prefixes the commit
- Works with any ticketing system — Jira, Linear, GitHub Issues, YouTrack, and more
- Commits, pushes, and optionally opens a PR/MR
- Supports GitHub, GitLab, and Bitbucket (auto-detected from remote URL)
Requires Python 3.9+ and git.
git clone https://github.com/keivanzavari/git-agent
# Option A: symlink globally
ln -sf "$PWD/git-agent/git-agent" /usr/local/bin/git-agent
# Option B: add to PATH in your shell profile
export PATH="$PWD/git-agent:$PATH"git_agent.py is stdlib-only and needs no installation. Optional extras:
# MCP server (for VS Code / Copilot / Claude Desktop integration)
pip install -r requirements.txt
# Running the test suite
pip install -r requirements-dev.txtmkdir -p ~/.claude/skills/git-agent
cp git-agent/SKILL.md ~/.claude/skills/git-agent/SKILL.mdThen invoke with /git-agent inside Claude Code.
# Stage your changes first
git add -p
# Standalone — LLM generates the commit message
git-agent
# With ticket context (Jira, Linear, GitHub Issues, etc.)
git-agent "AUTH-42: adds Google SSO via short-lived JWTs in httpOnly cookies"
# Commit + push + open PR
git-agent --pr
# Draft PR on a specific base branch
git-agent --pr --draft --base develop
# Agent-driven: message already written, skip all prompts
git-agent --message "Add OAuth2 login via Google" --pr --yes
# Commit only, no push
git-agent --no-push| Flag | Description |
|---|---|
-m, --message MSG |
Use this commit message (skip LLM generation) |
--title TITLE |
Override PR/MR title |
--pr |
Open a PR/MR after pushing |
--draft |
Open a draft PR/MR (implies --pr) |
--base BRANCH |
Base branch for PR/MR (default: auto-detected) |
--no-push |
Commit only |
-y, --yes |
Skip all confirmation prompts |
Set environment variables in your shell profile (~/.zshrc, ~/.bashrc).
These power the built-in commit message generator used by the standalone CLI and the
generate_commit_message MCP tool.
export ANTHROPIC_API_KEY=sk-ant-... # Claude (preferred)
export OPENAI_API_KEY=sk-... # GPT-4oIn typical MCP usage (Copilot, Claude Desktop), the host agent generates the commit
message and calls commit directly — so these keys are not required for that workflow.
They are only needed when running git-agent standalone or when explicitly invoking
the generate_commit_message MCP tool.
If neither key is set, the standalone CLI falls back to $EDITOR for message input.
# Optional: clickable ticket links in PR bodies — use {id} as the placeholder
export TICKET_URL_TEMPLATE=https://yourorg.atlassian.net/browse/{id} # Jira
# export TICKET_URL_TEMPLATE=https://linear.app/myteam/issue/{id} # Linear
# export TICKET_URL_TEMPLATE=https://github.com/org/repo/issues/{id} # GitHub Issues
# Optional: override the default ticket ID regex ([A-Z]+-[0-9]+)
# export TICKET_PATTERN='[0-9]+' # plain issue numbers (GitHub / GitLab)
# export TICKET_PATTERN='sc-[0-9]+' # Shortcut
# export TICKET_PATTERN='AB#[0-9]+' # Azure DevOps| Platform | CLI (required for PRs) | Install |
|---|---|---|
| GitHub | gh |
https://cli.github.com |
| GitLab | glab |
https://gitlab.com/gitlab-org/cli |
| Bitbucket Server/DC | bb (preferred) |
https://github.com/keivanzavari/bb-cli |
| Bitbucket Cloud | bkt (fallback) |
brew install avivsinai/tap/bitbucket-cli |
The platform is auto-detected from git remote get-url origin. For self-hosted
Bitbucket Server instances set BITBUCKET_SERVER_URL so the hostname can be matched:
export BITBUCKET_SERVER_URL=https://bitbucket.yourcompany.com
export BITBUCKET_TOKEN=your-http-access-token # Personal Settings → HTTP access tokensEach CLI handles its own authentication — run once to set up credentials:
gh auth login # GitHub
glab auth login # GitLab
# bb uses BITBUCKET_SERVER_URL + BITBUCKET_TOKEN env vars (see above)Commits and pushes work without any CLI installed.
A ticket/issue ID is extracted from the branch name via the TICKET_PATTERN regex
(default: [A-Z]+-[0-9]+, which covers Jira, Linear, YouTrack, and similar systems):
feature/AUTH-42/google-sso → [AUTH-42] ...
fix/PLAT-7-null-pointer → [PLAT-7] ...
main → (no prefix)
For other systems, override TICKET_PATTERN:
TICKET_PATTERN='[0-9]+' issue/123-fix-login → [123] ... (GitHub/GitLab)
TICKET_PATTERN='sc-[0-9]+' sc-456/dark-mode → [sc-456] ... (Shortcut)
git-agent ships with an MCP server (git_agent_mcp.py) that exposes its tools to
any MCP-compatible client — including GitHub Copilot agent mode in VS Code and
Claude Desktop.
- Install dependencies:
pip install -r requirements.txt - The
.vscode/mcp.jsonin this repo auto-configures the server for VS Code. Clone the repo and open it — thegit-agentserver will appear in Copilot's tool list once agent mode is enabled.
| Tool | What it does |
|---|---|
get_git_status |
Branch, staged/unstaged files, recent log |
get_staged_diff |
Full diff + stat + ticket ID for the staged changes |
generate_commit_message |
LLM-generated commit message from staged diff (requires ANTHROPIC_API_KEY or OPENAI_API_KEY; in normal agent workflows the host agent generates the message instead) |
commit |
Commit staged changes (optionally push) |
create_pr |
Open a PR/MR on GitHub, GitLab, or Bitbucket |
get_pr_comments |
Fetch reviewer comments and reviews on the open PR/MR for the current branch |
update_pr |
Update the title, description, base branch, or draft status of the open PR/MR |
- "What's staged right now?" → calls
get_staged_diff - "Generate a commit message for my changes" → calls
generate_commit_message - "Commit and push with message: Fix null pointer in auth" → calls
commit - "Open a draft PR against develop" → calls
create_pr - "What are the review comments on my PR?" → calls
get_pr_comments - "Update the PR title to include the ticket number" → calls
update_pr
Any agent with Bash tool access can call git-agent directly:
# The agent generates the message, the script handles the mechanics
git-agent --message "<agent-generated message>" --pr --yes "<extra context>"For Claude Code, use the /git-agent skill which handles message generation
and delegates execution to this script automatically.
python3 -m pytest tests/ -vRequires pytest — see requirements-dev.txt.
- Python 3.9+
gitghCLI (optional — required only for GitHub PR creation/update)glabCLI (optional — required only for GitLab MR creation/update)bbCLI (optional — preferred for Bitbucket Server/DC PR creation/update/comments)bktCLI (optional — fallback for Bitbucket whenbbis not installed)
git_agent.py is stdlib-only (no pip install needed for the CLI).
The MCP server (git_agent_mcp.py) additionally requires mcp>=1.2.0 — see requirements.txt.