Skip to main content

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.

Metadata

Release files for code-maat-python 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-maat-python 0.2.0
File Size Uploaded Provenance
code_maat_python-0.2.0.tar.gz 37.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for code-maat-python 0.2.0
File Interpreter ABI Platform
code_maat_python-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 86.0 kB

Release files / code_maat_python-0.2.0.tar.gz

Download URL code_maat_python-0.2.0.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e23c0adaf137e289f4594cb371f5613b60def943cbdd7f80ee1fc9e16e768aba
BLAKE2b-256 checksum
How to use checksums
7728e8b3173e8443d81d21ab1f67988c847a8ca02df015b3e9cb287493681f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Release files / code_maat_python-0.2.0-py3-none-any.whl

Download URL code_maat_python-0.2.0-py3-none-any.whl
Size 48.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe0c8c3357ae19c03a131f0f44598d7d0064f95f87df290f5dcbf52c8576765f
BLAKE2b-256 checksum
How to use checksums
a14e19e44a98424fac4e9b83403e7bf72234672f895a8b28e9b7c47d7be706ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

Security for code-maat-python 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for code_maat_python-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page