Skip to main content

Track which lines in your codebase were written by AI

Project description

aidiff

Track which lines in your codebase were written by AI.

PyPI version License: MIT

aidiff demo


aidiff is git blame for AI-generated code. It tracks, scores, and visualizes how much of your codebase was written by AI assistants like Copilot, Claude, ChatGPT, and Cursor.

Why?

AI-generated code is becoming a significant portion of modern codebases. Studies show that AI-assisted developers accept ~30% of suggestions, and that number is growing fast.

But nobody tracks it. This creates invisible technical debt:

  • Which files are mostly AI-generated?
  • Are AI-written functions getting proper review?
  • What's your team's actual AI code ratio over time?

aidiff answers these questions.

Quick Start

pip install aidiff

cd your-repo
aidiff scan          # Scan and show AI ratio
aidiff status        # Full statistics
aidiff report        # Generate HTML report

That's it. Three commands to understand your AI code footprint.

How It Works

aidiff uses a hybrid detection approach:

  1. Explicit tags - # ai-generated, Co-authored-by: Claude, [AI] in commits
  2. Commit analysis - Patterns in commit messages indicating AI involvement
  3. Heuristic analysis - Detects AI coding patterns:
    • Overly verbose variable names (user_authentication_token_validation)
    • Redundant comments (# Initialize the result dictionary)
    • Placeholder TODOs (# TODO: Add error handling)
    • Docstrings longer than the function body
    • Universal type hints on every function

Commands

Command Description
aidiff scan Scan repo and calculate AI ratio
aidiff status Show full statistics with tables
aidiff track <file> Show AI-scored lines in a file
aidiff report Generate HTML report with charts
aidiff install Install pre-commit git hook
aidiff check --ci CI-friendly output for pipelines
aidiff init-action Generate GitHub Action workflow

HTML Report

aidiff report generates a beautiful, self-contained HTML report with:

  • AI code ratio trends over time (Chart.js)
  • File-by-file AI score heatmap
  • Contributor AI usage breakdown
  • Recent commit AI classification

GitHub Action

aidiff init-action  # Generates .github/workflows/aigate.yml

This creates a GitHub Action that automatically comments on PRs with the AI code ratio, warning when it exceeds 70%.

Git Hook

aidiff install  # Installs pre-commit hook

Automatically runs aidiff scan before each commit, keeping .aidiff/data.json up to date.

Configuration

aidiff stores data in .aidiff/data.json in your repo root. This file is meant to be committed and shared with your team.

Insiders

Early supporters get priority features and direct input on the roadmap.

Become a Sponsor to unlock:

  • Custom detection rules
  • Team dashboard
  • Slack/Discord notifications
  • Priority support

License

MIT

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

aidiff-0.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

aidiff-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file aidiff-0.1.0.tar.gz.

File metadata

  • Download URL: aidiff-0.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for aidiff-0.1.0.tar.gz
Algorithm Hash digest
SHA256 852dca3c996aa146111201dccd9ddd241aa521c5ad9019a24c114cadf1daf556
MD5 f08b797fd1848c6bae04417df8e47b8f
BLAKE2b-256 925157622194b3a65c622820e25b5b278fe370477cf7c0c895b458d0f0a49f45

See more details on using hashes here.

File details

Details for the file aidiff-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aidiff-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for aidiff-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47bc85e8f9d2cf7bfbdb0e27737b26c5733993618cbc554751af0afe3637257b
MD5 85b86bf6b8fcef33bc3db0b710e75393
BLAKE2b-256 f2ee0bda7ddc998adad7d91541df68cbc286ba733a90b639951b0a768b746125

See more details on using hashes here.

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