Skip to main content

AI Impact Assessment for Code Changes

Project description

CheckodAI

AI Impact Assessment for code changes - understand what Copilot changed before you commit it.

Overview

CheckodAI is a Python CLI tool that helps developers understand the scope and implications of their code changes by analyzing git diffs and extracting modified symbols (functions, classes, variables). It can optionally use a local LLM (Ollama) to assess the risk of each change.

Privacy

CheckodAI runs entirely locally.

  • No code is uploaded
  • No cloud calls required
  • No telemetry
  • Works offline with local LLM (Ollama)

All analysis happens on your machine.

Key Features:

  • ๐Ÿš€ Local-first: Runs entirely on your machine - no cloud calls
  • ๐Ÿ” Symbol-level analysis: Detects changed functions, classes, and variables
  • ๐Ÿท๏ธ Change type detection: Identifies what type of change (added, removed, modified, signature changed)
  • ๐Ÿ’ก Impact summaries: Human-readable recommendations for each changed symbol
  • ๐Ÿค– AI-powered risk assessment: Uses local Ollama for intelligent impact analysis
  • ๐Ÿ›ก๏ธ Commit guard: Advisory warnings for HIGH risk changes (non-blocking)
  • ๐ŸŽฏ CLI-first interface: Simple checkod assess command
  • ๐Ÿ“Š Summary reports: Clear output of what changed and risk levels
  • ๐Ÿ”ง Production-ready: Proper project structure and error handling
  • โšก Graceful fallback: Works without Ollama using heuristic analysis

Installation

Prerequisites

  • Python 3.8+
  • Git
  • Ollama (optional, for AI risk assessment)

Install Ollama (optional but recommended)

# macOS / Linux
curl -fsSL https://ollama.ai/install.sh | sh

# Or use Homebrew (macOS)
brew install ollama

# Pull the model
ollama pull llama3

# Start the server (runs on localhost:11434)
ollama serve

Quick Start

  1. Install from PyPI:
pip install checkod-ai
  1. Run assessment:
checkod assess

Or for development setup:

  1. Clone the repository:
git clone <repository-url>
cd checkod
  1. Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install in development mode:
pip install -e .

Usage

Basic Usage

Analyze changes in the current repository:

checkod assess

Analyze changes in a specific repository:

checkod assess --repo /path/to/repo

Skip AI risk assessment (if Ollama not available):

checkod assess --no-risk

Commit Guard

The commit guard provides advisory warnings for HIGH risk changes:

# Assessment with advisory warnings enabled
checkod assess --risk

If HIGH risk is detected:

โš ๏ธ  HIGH IMPACT CHANGE DETECTED

This change may affect critical system behavior.

Recommended:
  โ€ข run related tests
  โ€ข verify downstream services
  โ€ข review impact summary

Commit will proceed.

Exit code: 0 (advisory, non-blocking)

See COMMIT_GUARD.md for detailed guard usage and integration patterns.

Example Output

๐Ÿ” Starting Impact Assessment...

๐Ÿ“‹ Git Diff (1250 characters):
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
diff --git a/src/utils.py b/src/utils.py
index abc1234..def5678 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -10,6 +10,10 @@
+def calculateDiscount(price, tier):
+    return price * (1 - tier * 0.1)
...
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

๐Ÿ“Š Changed Symbols (3 detected):
  โ€ข calculateDiscount
  โ€ข OrderStatus
  โ€ข userTier

๐Ÿ“ˆ Change Summary:
  Functions: 1 function added
  Classes: 1 class added
  Variables: 1 variable added

================================================================================
๐Ÿ“‹ Impact Summary
================================================================================
You changed: calculateDiscount()
Change Type: function added
Risk Level: MEDIUM

This may affect:
  โ€ข checkout_service (logic flow)
  โ€ข /api/orders (user-facing behavior)
  โ€ข test_checkout (test coverage)

Recommended Actions:
  โ€ข Write unit tests for calculateDiscount
  โ€ข Test integration with checkout service
  โ€ข Document function parameters and return type
  โ€ข Verify checkout_service handles the change
  โ€ข Load test affected service endpoints

โœ… Assessment complete!

With AI risk assessment enabled (Ollama running), you'll also see:

================================================================================
๐Ÿค– AI Risk Assessment (powered by local Ollama)
================================================================================
๐Ÿ“ Analyzing risk for each symbol...

Symbol: calculateDiscount
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Risk Classification: MEDIUM

Reason: Used in multiple modules; requires testing and code review.

Validation Steps:
โ€ข Test discount calculation across pricing tiers
โ€ข Verify integration with checkout service
โ€ข Add regression tests if coverage is low

See Risk Assessment Module for setup and usage details.

Project Structure

checkod/
โ”œโ”€โ”€ __init__.py           # Package initialization
โ”œโ”€โ”€ main.py              # CLI entry point (Typer)
โ”œโ”€โ”€ agent.py             # Core orchestrator
โ”œโ”€โ”€ observe.py           # Git diff reading (GitPython)
โ”œโ”€โ”€ understand.py        # Symbol extraction (regex patterns)
โ”œโ”€โ”€ change_type.py       # Change type detection
โ”œโ”€โ”€ assess.py            # Risk assessment (Ollama integration)
โ”œโ”€โ”€ summary.py           # Impact summary generation
โ””โ”€โ”€ guard.py             # Commit guard for HIGH risk โญ

Architecture

Components

  1. main.py - CLI interface using Typer

    • Exposes assess command
    • Handles user input and options
    • Calls the agent orchestrator
  2. agent.py - Orchestrator

    • Coordinates the workflow
    • Calls observe and understand modules
    • Formats and displays results
  3. observe.py - Git integration

    • Uses GitPython to read diffs
    • Gets both staged and unstaged changes
    • Returns raw diff content
  4. understand.py - Symbol extraction

    • Parses diff for changed symbols
    • Uses regex patterns for symbol detection
    • Returns list of modified symbols
  5. change_type.py - Change type detection

    • Identifies what type of change was made
    • Classifies as: added, removed, modified, signature changed
    • Provides confidence scoring
    • Enriches symbols with metadata
  6. assess.py - Risk assessment

    • Integrates with Ollama for AI analysis
    • Builds structured prompts for LLM
    • Provides heuristic fallback when Ollama unavailable
    • Classifies changes as LOW/MEDIUM/HIGH risk

Workflow

User Input โ†’ CLI (main.py)
    โ†“
Agent (agent.py) - Orchestrator
    โ†“
Observe (observe.py) - Read git diff
    โ†“
Understand (understand.py) - Extract symbols
    โ†“
Detect (change_type.py) - Identify change types
    โ†“
Assess (assess.py) - Evaluate risk (optional, requires Ollama)
    โ†“
Display Results

Development

Running Tests

pytest

Code Quality

# Format code
black .

# Check code style
flake8 .

# Type checking
mypy checkod

Development Dependencies

The project includes development tools for testing and code quality:

  • pytest - Testing framework
  • pytest-cov - Coverage reporting
  • black - Code formatter
  • flake8 - Linter
  • mypy - Type checker

Install with:

pip install -e ".[dev]"

Current Limitations

Current Version (0.1.0)

  • Regex-based parsing: Symbol extraction uses regex patterns, not full AST parsing
  • Limited language support: Patterns work best with Python and JavaScript
  • Basic LLM integration: Ollama support available but must be local
  • No usage tracking: Doesn't analyze actual symbol usage in codebase

Future Enhancements

  • Full AST-based parsing for accurate symbol detection
  • Multi-language support (Java, Go, Rust, etc.)
  • Dependency graph analysis for usage tracking
  • Integration with codebase analysis tools
  • Pre-commit hook integration
  • Historical trend analysis
  • Custom risk policies per team

Configuration

Future versions will support configuration via checkod.yaml:

# Planned for future release
symbols:
  min_impact_score: 0.5
languages:
  - python
  - javascript
patterns:
  exclude:
    - test_*
    - __pycache__

Troubleshooting

"Not a valid git repository" error

Ensure you're running checkod assess in a directory that is a git repository:

git init  # If needed

No symbols detected

This can happen if:

  • Changes are only in configuration files
  • Symbols don't match current regex patterns
  • Consider checking the raw diff: git diff

Virtual environment issues

Recreate the environment:

rm -rf venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Documentation

  • README.md - Full user guide, architecture, troubleshooting
  • SETUP.md - Quick start and common tasks
  • CONTRIBUTING.md - How to contribute and develop
  • CHANGE_TYPE_DETECTION.md - Change type identification and usage
  • RISK_ASSESSMENT.md - AI-powered risk assessment setup and usage
  • AI_RISK_ASSESSMENT_SUMMARY.md - Implementation overview
  • IMPACT_SUMMARY.md - Developer-facing impact analysis and recommendations
  • COMMIT_GUARD.md - Commit blocking on HIGH risk changes
  • .github/copilot-instructions.md - Copilot development guidance

Contributing

This is an experimental project. Contributions are welcome!

License

MIT License - See LICENSE file for details

Roadmap

Phase 1 (Current):

  • Basic git diff reading
  • Regex-based symbol extraction
  • CLI interface

Phase 2 (Planned):

  • Full AST parsing
  • Multi-language support
  • Impact scoring

Phase 3 (Future):

  • AI-powered analysis
  • Integration with CI/CD
  • Web-based dashboard

Note: This is an early-stage project. The API and behavior are subject to change.

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

checkod_ai-0.1.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

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

checkod_ai-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for checkod_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f0f56dd2768f1ca00263a5f2f7274b6575db5809dc20fc2334d75685a068e3e0
MD5 44a56ece0d42bdcc8f3a4ca20479706b
BLAKE2b-256 5fa72bb525c41a7960c662b2228f8f156ca38881ad79c8ea43742950847b47ce

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for checkod_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d594f4365d30abff30e1c6e5a1a4eb45c73ac40c8ca175414c3857525b2699fb
MD5 9b1cb819acbd33322312e8b7e23200cd
BLAKE2b-256 5f84c3ff6dece4e5ad1217c8b47c65707a39edf2f218efc789698cb04cd86f67

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