Git Commit Aider

by mrorz

Not rated
GitHub

About

Make git commits on behalf of AI to track AI contributions in your codebase.

Details

Author
mrorz
Categories
Developer Tools, Other
Tags
#git

Setup

Install Git Commit Aider in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/mrorz/mcp-git-commit-aider

Follow the installation instructions in the repository README, then restart your MCP client.

Make git commits on behalf of AI to track AI contributions in your codebase.

Make git commits on behalf of AI, so that you can track AI contribution in your codebase.

This is a TypeScript-based MCP server that provides a tool to commit staged changes in a Git repository while appending "(aider)" to the committer's name.

commit_staged- Commit staged changes with a specific message.

- Takesmessage(string, required) as the commit message.
- Takescwd(string, optional) to specify the working directory for the git command.
- Appends "(aider)" to the committer name automatically.
- Reads committer name and email from environment variables (GIT_COMMITTER_NAME,GIT_COMMITTER_EMAIL) if set, otherwise falls back togit config user.nameandgit config user.email.

With this tool installed in your code editor, you can prompt the AI by something like:

This usually happens after the AI has made some changes to your codebase, so often times AI is able to provide a good commit message from the context.

To use this server, add its configuration to your MCP settings file.

{ "mcpServers": { "git-commit-aider": { "command": "npx", "args": ["mcp-git-commit-aider"] } } }

The committer information is retrieved from:
- Environment variablesGIT_COMMITTER_NAMEandGIT_COMMITTER_EMAIL, which followsgit's convention.
- Output ofgit config user.nameandgit config user.emailcommands.

If you don't want to use this MCP server, you can also use thegitcommand directly in your terminal.

You can proceed with normal commit first, and then use the following git command to change the author of the last commit:

git commit --amend --author="$(git config user.name) (aider) <$(git config user.email)>"

This will change the author of the last commit to your name with "(aider)" appended.

To simplify the process, you can set up a Git alias. Run the following command in your terminal:

git config --global alias.aimend '!git commit --amend --author="$(git config user.name) (aider) <$(git config user.email)>"'

Once set up, you can use the alias by running:

Commits with "(aider)" can be picked up byaider --statscommand, which will show you the contribution of AI in your codebase.

Alternatively, you can use the following script to calculate the contribution of AI in your codebase, measured in lines of code (added, deleted, and total changes).

#!/bin/bash # Script to calculate line changes (added, deleted, total) by AI and human authors # between two commits. # Output is in JSON format. # # This logic is extracted and altered from git-quick-stats.sh, MIT license. # --- Configuration --- # You may change the config to match your repository's convention. # String to identify AI-generated commits in author names AI_MATCHER="(aider)" # Define patterns for files/paths to be excluded from the calculation. # These will be converted to git pathspecs like ":(exclude)package-lock.json" IGNORE_PATTERNS=( "package-lock.json" ".lock" ) # --- Helper Functions --- function print_usage() { echo "Usage: $0 <REVISION_RANGE>" echo " <REVISION_RANGE>: The revision range to analyze (e.g., HEAD~5..HEAD, my-branch, commit_sha)." echo " Refer to 'git help log' or 'git help revisions' for more range options." echo "Example: $0 HEAD~5..HEAD" echo "Example: $0 origin..HEAD" echo "Example: $0 my-feature-branch" echo "Example: $0 abcdef1..fedcba2" } # --- Argument Parsing --- if [ "$#" -ne 1 ]; then echo "Error: Incorrect number of arguments. Please provide a single revision range." print_usage exit 1 fi REVISION_RANGE="$1" # --- Main Logic --- # Construct pathspec arguments for git log pathspec_args=() for pattern in "${IGNORE_PATTERNS[@]}"; do pathspec_args+=(":(exclude)$pattern") done git_log_output=$(git log "$REVISION_RANGE" --numstat --pretty="format:AuthorName:%an" -- "${pathspec_args[@]}") # DEBUG: Uncomment to check the calculation for each commit. # echo "$git_log_output" # Process the log output with awk result_json=$(echo "$git_log_output" | awk -v ai_matcher="$AI_MATCHER" ' BEGIN { ai_added = 0 ai_deleted = 0 human_added = 0 human_deleted = 0 current_author = "" is_ai_author = 0 } /^AuthorName:/ { # Extract author name current_author = substr($0, length("AuthorName:") + 1) if (index(current_author, ai_matcher) > 0) { is_ai_author = 1 } else { is_ai_author = 0 } next } # Skip empty lines between commit blocks or lines that are not numstat NF == 0 || !($1 ~ /^[0-9]+$/ && $2 ~ /^[0-9]+$/) { next } # Process numstat line: <added> <deleted> <file> { added_lines = $1 deleted_lines = $2 # Skip binary files where numstat shows "-" for lines if (added_lines == "-" || deleted_lines == "-") { next } # Aggregate stats per author and file for details array file_name = $3 # Robust key using File Separator character \034 key = current_author "\034" file_name file_author_added[key] += added_lines file_author_deleted[key] += deleted_lines if (is_ai_author) { ai_added += added_lines ai_deleted += deleted_lines } else { human_added += added_lines human_deleted += deleted_lines } } END { ai_total_changed = ai_added + ai_deleted human_total_changed = human_added + human_deleted overall_total_changed = ai_total_changed + human_total_changed ai_percentage = 0.00 if (overall_total_changed > 0) { ai_percentage = (ai_total_changed / overall_total_changed)  100 } printf "{\n" printf " \"ai_percentage\": %.2f,\n", ai_percentage printf " \"ai_changes\": {\"added\": %d, \"deleted\": %d, \"total\": %d},\n", ai_added, ai_deleted, ai_total_changed printf " \"human_changes\": {\"added\": %d, \"deleted\": %d, \"total\": %d},\n", human_added, human_deleted, human_total_changed # Details array printf " \"details\": [\n" first_detail = 1 # Iterate over one of the arrays, keys should be consistent for (key in file_author_added) { if (!first_detail) { printf ",\n" } first_detail = 0 # Split key "author\034fileName" into key_parts array # key_parts[1] will be author, key_parts[2] will be fileName split(key, key_parts, "\034") author = key_parts[1] fileName = key_parts[2] # Escape double quotes for JSON compatibility gsub(/"/, "\\\"", author) gsub(/"/, "\\\"", fileName) detail_added = file_author_added[key] + 0 # Ensure numeric detail_deleted = file_author_deleted[key] + 0 # Ensure numeric detail_total = detail_added + detail_deleted printf " {\n" printf " \"fileName\": \"%s\",\n", fileName printf " \"author\": \"%s\", \"isAI\": %s,\n", author, (index(author, ai_matcher) > 0 ? "true" : "false") printf " \"added\": %d, \"deleted\": %d, \"total\": %d\n", detail_added, detail_deleted, detail_total printf " }" } printf "\n ]\n" printf "}\n" } ') # --- Output --- echo "$result_json"
# Assume the script is saved as calculate_ai_contribution.sh and is executable (chmod +x calculate_ai_contribution.sh) # Example 1: Analyze the last 5 commits ./calculate_ai_contribution.sh HEAD~5..HEAD # Example 2: Analyze commits between a specific commit and HEAD ./calculate_ai_contribution.sh 90a5fcd4..HEAD # Example 3: Analyze all commits on a feature branch not yet in main ./calculate_ai_contribution.sh main..my-feature-branch # Example 4: Analyze commits between two tags ./calculate_ai_contribution.sh v1.0..v1.1 # Example output (will vary based on your repository and range): # { # "ai_percentage": 48.53, # "ai_changes": { "added": 100, "deleted": 32, "total": 132 }, # "human_changes": { "added": 103, "deleted": 37, "total": 140 }, # "details": [ # { # "fileName": "src/featureA.js", # "author": "Developer One (aider)", "isAI": true, # "added": 60, "deleted": 10, "total": 70 # }, # { # "fileName": "src/featureB.js", # "author": "Developer One (aider)", "isAI": true, # "added": 40, "deleted": 22, "total": 62 # }, # { # "fileName": "src/utils.js", # "author": "Developer Two", "isAI": false, # "added": 80, "deleted": 15, "total": 95 # }, # { # "fileName": "README.md", # "author": "Developer Two", "isAI": false, # "added": 23, "deleted": 22, "total": 45 # } # ] # }

The JSON output contains the following fields:

- ai_percentage: (Number) The percentage of total lines changed (sum of added and deleted lines) that were contributed by AI authors (identified byAI_MATCHER).
- ai_changes: (Object) An object detailing the aggregated line changes (linesadded,deleted, and theirtotal) made by AI authors.
- human_changes: (Object) An object detailing the aggregated line changes (linesadded,deleted, and theirtotal) made by human authors.
- details: (Array of Objects) Provides a detailed breakdown of changes. Each object in the array represents the contribution of a specificauthorto a particularfileName, including linesadded,deleted, and thetotalchanges for that file by that author.

AI drafts the commits, you decide what ships. GitInProgress lets your AI read your uncommitted working tree and propose how to split it into focused commit candidates — each with a draft commit message. Nothing lands in git history until you review and approve; the AI never commits on its own.

An MCP server for interacting with and automating Git repositories using Large Language Models.

Generates Pull Request messages based on Git commits and changes.

Anchor is local repo and org memory for AI coding agents. It indexes GitHub PR history, current code, tests, regressions, architecture, and cross-repo impact locally, then exposes concise cited context through MCP and CLI workflows. Local-first. Read-only GitHub access. No CLI telemetry. No SaaS. No remote LLM calls.

DOS is a small open-source kernel that doesn't believe your AI agents: it verifies what actually shipped from git evidence, arbitrates file collisions between parallel agents, and refuses with structured reasons.

The most comprehensive MCP server for VS Code — 100+ tools across 25 categories. File ops, terminal, git, LSP providers (hover, completion, definition, references), and more. Free core + premium features.

Creates commit messages from staged files in a local git repository.

An MCP server for interacting with the AtomGit API for version control and code hosting.

Git-native decision memory for coding agents, stored as git trailers and refs/notes.

MCP server that gives AI coding agents real-time npm & PyPI package versions, metadata, and dependency info.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.