Skip to main content

Git workflow automation for AXM agents

Project description

AXM Logo

axm-git — Deterministic Git workflows for AI agents

CI axm-audit axm-init Coverage PyPI Python 3.12+ Docs


Features

  • 🔍 Preflight — Structured working tree status with diff summary
  • 🌿 Branch — Create or checkout branches with one call
  • 📦 Commit — Batched atomic commits with auto-retry on commit-hook fixes and optional author identity injection
  • 🏷️ Tag — One-shot semver tagging from Conventional Commits
  • 🚀 Push — Push with dirty-check, auto-upstream detection, and force support
  • 🌲 Worktree — Add, remove, or list git worktrees
  • 🔀 PR — Create GitHub pull requests with optional auto-merge
  • 🧭 Error Recovery — When called on a non-git directory, tools suggest nearby git repos
  • 🪝 Hooks — Lifecycle hook actions (preflight, create-branch, branch-delete, commit-phase, merge-squash, worktree-add, worktree-remove, push, create-pr, await-merge, pull-main) with enabled guard, auto-discovered via entry-points
  • 🪪 Identity — Resolve git author from git-profiles.toml with schedule-based or explicit profile selection. Schedule rules apply only under user-configured workspace_paths; comparison is timezone-aware via the optional timezone field (default Europe/Paris)
  • 🔎 Phase Lookupget_phase_commit() retrieves commit hashes for protocol phases

Installation

uv add axm-git

Quick Start

# Check what changed
git_preflight(path="/path/to/repo")
# → {files: [{path: "foo.py", status: "M"}, ...], clean: false, text: "git_preflight | 1 files · dirty\n..."}

# Create or switch branch
git_branch(name="feat/new-feature", path="/path/to/repo")
# → {branch: "feat/new-feature"}

# Commit in batches
git_commit(path="/path/to/repo", commits=[
    {"files": ["src/foo.py"], "message": "feat: add foo"},
    {"files": ["tests/test_foo.py"], "message": "test: add foo tests"},
])
# → {results: [{sha: "abc1234", precommit_passed: true}, ...]}

# Tag a release
git_tag(path="/path/to/repo")
# → {tag: "v0.2.0", bump: "minor", pushed: true}

# Push to remote
git_push(path="/path/to/repo")
# → {branch: "main", remote: "origin", pushed: true}

MCP Tools

git_preflight

Report working tree changes so the agent can plan commits.

Parameter Default Description
path . Project root directory
diff_lines 200 Max diff lines to include (0 to disable)

Returns: file list with status (M, A, D, ??), diff stat, clean flag, and a compact text summary for agent display.

git_branch

Create or checkout a git branch.

Parameter Default Description
name required Branch name
from_ref None Ref to branch from (tag, commit, branch)
checkout_only False If True, checkout existing branch without creating
delete False If True, delete the branch (git branch -D) instead of creating/checking out
path . Project root directory

Returns: {branch: "<current branch>"} on success.

git_commit

Execute one or more atomic commits with commit-hook handling.

Parameter Default Description
path . Project root directory
commits required List of commit specs (see below)
profile None Identity profile name — overrides schedule-based resolution from git-profiles.toml
strict False When True, a non-Conventional-Commit message is a hard failure instead of a warning

Each commit spec:

Field Required Description
files Files to stage
message Commit summary (Conventional Commits)
body Extended commit body

When a commit hook auto-fixes files (e.g. ruff --fix), the tool re-stages and retries once automatically.

Identity is resolved once per call (not per commit). When resolved, each commit includes --author="Name <email>". The result includes an author key ({name, email} or null).

git_tag

Compute the next semver version from Conventional Commits, create and push the tag.

Parameter Default Description
path . Project root directory
version auto Override the computed version (e.g. "v1.0.0")

Pipeline: clean tree check → CI status check → semver bump → annotate tag → hatch-vcs verify → push.

git_push

Push the current branch to a remote after verifying a clean working tree.

Parameter Default Description
path . Project root directory
remote origin Remote name
set_upstream True Auto-set upstream for new branches
force False Force-push using --force-with-lease (safe: only overwrites if the remote has not advanced past our tracking ref)
force_unconditional False When True (and force set), use a bare --force instead — unconditional overwrite (data-loss risk)

Pipeline: repo check → dirty check → detect branch → detect upstream → push.

git_worktree

Add, remove, or list git worktrees.

Parameter Default Description
path . Project root directory
action required add, remove, or list
worktree_path None Path for the new or existing worktree
branch None Branch name for add
base None Base ref for add (defaults to repo default)
force False Force removal for the remove action

git_pr

Create a GitHub pull request with optional auto-merge.

Parameter Default Description
path . Project root directory
title required Pull request title
body None Pull request description
base None Base branch (defaults to repo default)
auto_merge False Enable auto-merge when checks pass

Development

This package is part of the axm-forge workspace.

git clone https://github.com/axm-protocols/axm-forge.git
cd axm-forge
uv sync --all-groups
uv run --package axm-git --directory packages/axm-git pytest -x -q

📖 Full documentation

License

Apache-2.0 — © 2026 axm-protocols

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axm_git-0.5.1.tar.gz (144.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axm_git-0.5.1-py3-none-any.whl (80.2 kB view details)

Uploaded Python 3

File details

Details for the file axm_git-0.5.1.tar.gz.

File metadata

  • Download URL: axm_git-0.5.1.tar.gz
  • Upload date:
  • Size: 144.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for axm_git-0.5.1.tar.gz
Algorithm Hash digest
SHA256 81d1605db58ad4e48b8a0a87e20168012f96321020d662b99ed8658620c4a44d
MD5 f58a2d0bc4d8147f620b697a6743e452
BLAKE2b-256 0771a6f69ec19c15d0eb7275732be9fe108d7b13e53b2c23b6e70cb458e40791

See more details on using hashes here.

Provenance

The following attestation bundles were made for axm_git-0.5.1.tar.gz:

Publisher: publish.yml on axm-protocols/axm-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axm_git-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: axm_git-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 80.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for axm_git-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40741232fd2ca5c4280b67d9b17dccb7bf9863946b0221781230b45c3e194c54
MD5 018ea471aef7c918d82f0a298d7f40ce
BLAKE2b-256 55e8b273e96b76979e104ff4c4e4cdad522b7d725ddd3053319b2f50e21358ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for axm_git-0.5.1-py3-none-any.whl:

Publisher: publish.yml on axm-protocols/axm-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page