Skip to main content

Modern Python tool for mining and analyzing version control system data

Project description

code-maat

License: GPL-3.0 Python: 3.10+

A Python implementation of Code Maat by Adam Tornhill. Analyzes Git repository history to identify code coupling, change patterns, and team dynamics.

Overview

code-maat extracts insights from version control history:

  • Temporal coupling: Files that change together frequently
  • Code churn: Change frequency and stability metrics
  • Knowledge distribution: Contributor patterns and code ownership
  • Team coordination: Communication needs inferred from code changes

These analyses help identify architectural dependencies not visible in static code structure, inform code review priorities, and understand how teams interact with code over time.

Why Use This Tool?

Version control history contains information about code dependencies that aren't captured by static analysis. Files that frequently change together often share hidden coupling through business logic, data structures, or implicit contracts, even when they don't import each other directly.

Research shows that files with high temporal coupling have 2-10x higher defect rates (Predicting Faults from Cached History, MSR 2008). Understanding these patterns helps with:

  • Prioritizing code review effort on coupled changes
  • Identifying coordination requirements between team members
  • Finding knowledge silos and ownership concentration
  • Discovering stable versus volatile areas of the codebase

Installation

# Using pip
pip install code-maat

# From source with Poetry
git clone https://github.com/hydrosquall/code-maat.git
cd code-maat
poetry install

Quick Start

Generate a Git log in the required format:

cd your-project
git log --all -M -C --numstat --date=short --pretty=format:'--%h--%cd--%cn' > git.log

Run a coupling analysis to find files that frequently change together:

code-maat coupling git.log --min-coupling 50 --rows 10
# Or: python -m code_maat_python coupling git.log --min-coupling 50 --rows 10

Example output:

entity,coupled,degree,average-revs
src/models/user.py,src/views/profile.py,87,45
src/api/auth.py,src/middleware/session.py,76,32
src/utils/validators.py,src/forms/registration.py,65,28

This indicates user.py and profile.py change together in 87% of commits where either file changes, based on 45 average revisions. High coupling may indicate shared responsibilities or implicit dependencies worth reviewing.

Available Analyses

code-maat provides 17 analysis types:

Command Description Use Case
coupling Temporal coupling between file pairs Identify files that frequently change together
soc Sum of coupling scores per entity Aggregate coupling metric for prioritization
entity-churn Lines added/deleted per entity over time Measure change volatility
age Time since last modification Identify stable or abandoned code
communication Shared code changes between authors Map coordination requirements
authors Number of distinct authors per entity Measure knowledge distribution
entity-ownership Line contribution percentage by author Determine primary code owners
main-dev Primary contributor by lines changed Identify domain experts
main-dev-by-revs Primary contributor by commit count Identify active maintainers
refactoring-main-dev Primary contributor to refactorings Track code quality effort
revisions Commit count per entity Find frequently modified files
abs-churn Aggregate churn over time windows Track development activity trends
author-churn Per-author contribution over time Analyze individual contribution patterns
entity-effort Commit count per entity Quantify development effort distribution
fragmentation Author distribution per entity Detect coordination overhead
summary Repository-wide statistics Overview metrics
entities List of all tracked entities Verify log parsing scope

See REFERENCE.md for detailed command documentation.

Documentation

License

GPL-3.0 — see LICENSE for details.

This project is inspired by and compatible with Code Maat by Adam Tornhill.

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

code_maat_python-0.2.0.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

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

code_maat_python-0.2.0-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file code_maat_python-0.2.0.tar.gz.

File metadata

  • Download URL: code_maat_python-0.2.0.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for code_maat_python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e23c0adaf137e289f4594cb371f5613b60def943cbdd7f80ee1fc9e16e768aba
MD5 c5eb4b3ca028b1382ed2bfb9f9bcf330
BLAKE2b-256 7728e8b3173e8443d81d21ab1f67988c847a8ca02df015b3e9cb287493681f0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_maat_python-0.2.0.tar.gz:

Publisher: publish.yml on hydrosquall/code-maat-python

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

File details

Details for the file code_maat_python-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_maat_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe0c8c3357ae19c03a131f0f44598d7d0064f95f87df290f5dcbf52c8576765f
MD5 58261e0856eaabf8aada1f7f797dae31
BLAKE2b-256 a14e19e44a98424fac4e9b83403e7bf72234672f895a8b28e9b7c47d7be706ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_maat_python-0.2.0-py3-none-any.whl:

Publisher: publish.yml on hydrosquall/code-maat-python

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