Skip to main content
Glama

git-afm

On-device Conventional Commits, pull request descriptions, and diff explanations — powered by Apple Foundation Models.

git-afm reads your staged git diff and produces structured output locally on Apple Silicon. No API keys, no cloud inference, no token costs.

Type: feat | Scope: auth
feat(auth): implement token verification logic

- Add authenticate_user helper function
- Validate token length and admin identity

[c] commit   [e] edit   [r] regenerate   [y] copy   [q] quit

Contents

Related MCP server: Git Commit MCP Server

Requirements

Requirement

Details

Hardware

Apple Silicon (M1 or later)

OS

macOS with Apple Intelligence enabled in System Settings

Runtime

Python 3.10 or later

VCS

Git

The Apple Foundation Models framework is only available on supported Macs with Apple Intelligence turned on. If the model is unavailable, git-afm exits with a clear error instead of falling back to a remote API.

Features

  • Conventional Commits from the staged diff (feat, fix, refactor, perf, test, docs, chore, build, ci), including optional scope and breaking-change (!) markers.

  • Constrained decoding via @fm.generable — the model fills a typed schema, so you get a real commit object instead of brittle JSON parsing.

  • Pull request descriptions (--pr / git-afm-pr) as Markdown with summary, key changes, and a verification checklist.

  • Diff explainer (--explain) in English or Portuguese, without committing.

  • Interactive terminal UI (Rich): commit, edit in $EDITOR, regenerate, copy, or quit.

  • macOS clipboard integration through pbcopy.

  • Local MCP server (afm-mcp) so Cursor, Claude Desktop, Windsurf, and similar clients can call the same on-device tools.

Lockfiles and minified bundles are omitted from the prompt; oversized diffs are truncated so they fit the on-device context window.

Installation

Clone and install in editable mode:

git clone https://github.com/meschkemaes/git-afm.git
cd git-afm
python3 -m pip install -e .

Directly from GitHub:

python3 -m pip install "git+https://github.com/meschkemaes/git-afm.git"

Optional extras:

python3 -m pip install -e ".[mcp]"   # MCP server
python3 -m pip install -e ".[dev]"   # test suite

Git on macOS discovers executables named git-<command>, so after install both of these work:

git afm
git-afm

The package also installs git-afm-pr (shortcut for git-afm --pr) and afm-mcp.

Usage

Interactive commit

Stage the files you want in the commit, then generate a message:

git add -p
git afm

If nothing is staged but unstaged changes exist, git-afm asks whether to stage everything first.

Stage all and generate

git afm -a

Equivalent to git add -A followed by generation.

Portuguese output

git afm --pt

Commit subjects, bullet points, PR copy, and the action menu are generated in Portuguese. The Conventional Commit type (feat, fix, …) stays in English, as the spec requires.

Pull request description

git afm --pr
# or
git-afm-pr

Output is Markdown ready for GitHub or GitLab:

## Summary
…

## Key Changes
- …

## Verification & Testing
- [ ] …

Explain the diff

git afm --explain
git afm --explain --pt

Prints a short natural-language explanation and exits without committing.

Extra context

Guide the model with intent the diff does not make obvious:

git afm -m "this is a hotfix for the login timeout in production"

Non-interactive and dry-run

git afm -y                 # commit immediately
git afm --dry-run          # print only
git afm --dry-run --copy   # print and copy

CLI reference

Flag

Description

-a, --all

Stage all changes (git add -A) before generating

--pr

Generate a Markdown pull request description

--explain

Explain the diff in plain language; do not commit

-y, --yes

Commit (or stage, when needed) without confirmation

-d, --dry-run

Print the result without committing

--pt

Generate text in Portuguese (default: English)

--copy

Copy the result to the macOS clipboard

-m, --context TEXT

Extra developer intent passed to the model

-v, --version

Print the version and exit

Commit types

Type

Use when

feat

A new feature

fix

A bug fix

refactor

A code change that neither fixes a bug nor adds a feature

perf

A performance improvement

test

Adding or correcting tests

docs

Documentation only

chore

Maintenance that does not affect src or tests

build

Build system or dependencies

ci

CI configuration

Breaking changes get a ! after the type (or type(scope)!) and a BREAKING CHANGE footer.

MCP server

git-afm can expose the same on-device model as a Model Context Protocol server.

python3 -m pip install -e ".[mcp]"
afm-mcp

Tools

Tool

Purpose

generate_conventional_commit

Conventional Commit message from a diff

generate_pr_summary

Markdown PR description from a diff

explain_diff

Plain-language explanation of a diff

Each tool accepts diff (required), language (en or pt, default en), and — except explain_diff — optional context.

Client configuration

Add the server to mcp.json (Cursor, Windsurf) or claude_desktop_config.json:

{
  "mcpServers": {
    "apple-foundation": {
      "command": "python3",
      "args": ["-m", "git_afm.mcp_server"]
    }
  }
}

If the afm-mcp script is on your PATH:

{
  "mcpServers": {
    "apple-foundation": {
      "command": "afm-mcp"
    }
  }
}

The Python used in command must be the same environment where git-afm (and the mcp extra) is installed.

How it works

flowchart LR
  A["git diff --cached"] --> B["Filter lockfiles<br/>and truncate"]
  B --> C["Apple Foundation Models<br/>constrained decoding"]
  C --> D["Commit · PR · Explain"]
  1. The CLI reads the staged diff (git diff --cached).

  2. Noise is stripped: lockfiles (package-lock.json, pnpm-lock.yaml, Cargo.lock, …), minified assets, and source maps are omitted; large file hunks are truncated.

  3. Apple Foundation Models fills a @fm.generable schema (ConventionalCommit or PullRequestSummary) through constrained decoding.

  4. The result is rendered in the terminal. You commit, edit, regenerate, copy, or abort.

Inference runs on the Apple Neural Engine. Diffs never leave the machine.

Privacy

There is no network client for generation. git-afm does not send diffs, commit messages, or prompts to a third-party API. Availability still depends on Apple Intelligence being enabled on the local Mac.

Development

See CONTRIBUTING.md.

python3 -m pip install -e ".[dev]"
python3 -m pytest tests/ -v -m "not integration"

Module

Tests

tests/test_models.py

Commit / PR formatting, including breaking changes

tests/test_git_utils.py

Diff filtering, lockfile omission, truncation

tests/test_ui.py

Action-menu copy

tests/test_engine.py

On-device integration (requires Apple Intelligence)

test_engine.py talks to the real Foundation Models runtime and is skipped when Apple Intelligence is unavailable. GitHub Actions runs the unit tests only.

License

MIT © 2026 Lucas Meschke

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to interact with local Git repositories for operations like status, commits, branching, and diffs, plus GitHub API integration for managing pull requests when authenticated.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables AI-powered git assistance including commit message generation, branch naming, and branch analysis using conventional commits and git status/diff/log.
    -