isitAI is a multi-language, AST-driven detection engine that analyzes source code repositories to detect whether they were generated by AI models (such as ChatGPT, Gemini, Claude, or Copilot) or written by human developers.
It leverages Abstract Syntax Tree (AST) structural metrics, token distributions, and ensemble XGBoost classifiers to perform repository-level evaluation across single projects or batch directories.
- Multi-Language Support: AST feature extraction engine built for Python (native AST) and Java (
javalang). - Distribution-Based Analysis: Aggregates per-file AST metrics using Statistical Distributions (
mean,std,p90) to prevent feature dilution. - Sub-Repository Detection: Automatically identifies container folders containing up to 50 sub-projects and analyzes each repo independently.
- Provider Attribution: Multi-class classification to attribute detected AI code to specific LLM providers (Gemini, ChatGPT, Claude, Copilot).
- Lightweight Deployment: Pre-trained model weights are stored in compact JSON schemas (< 5 MB), requiring zero dataset overhead for inference.
# Clone the repository
git clone https://github.com/Akmal-Esmat/isitAI.git
cd isitAI
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtpython scan.py path/to/your/projectYou can scan any public GitHub repository directly by passing its HTTPS URL:
python scan.py https://github.com/spring-projects/spring-petclinicTo scan a parent directory containing up to 50 sub-projects:
python scan.py dataset/python/ai/============================================================
isitAI - Enterprise Code & Model Detector
============================================================
Cloning remote repository: [https://github.com/spring-projects/spring-petclinic](https://github.com/spring-projects/spring-petclinic) ...
--- Scan Results ---
Target Directory : /tmp/isitai_scan_8x9a2b
Primary Language : JAVA
Files Analyzed : 32 Java files (~2,400 LOC)
Overall AI Score : 2.14%
AI Provider Attribution Breakdown:
• CHATGPT : 1.02% confidence
• GEMINI : 0.65% confidence
• COPILOT : 0.47% confidence
------------------------------------------------------------
VERDICT: [ PASS ] Codebase appears predominantly human-written.
------------------------------------------------------------
To scan a specific Python or Java project:
python scan.py path/to/your/projectTo scan a container folder holding multiple distinct projects:
python scan.py dataset/python/ai/============================================================
isitAI - Enterprise Code & Model Detector
============================================================
--- Scan Results ---
Target Directory : dataset/ai/gemini/api_wrapper
Overall AI Score : 97.81%
AI Provider Attribution Breakdown:
• GEMINI : 85.13% confidence
• CHATGPT : 5.93% confidence
• COPILOT : 4.47% confidence
------------------------------------------------------------
VERDICT: [ HIGH RISK ] Codebase closely matches GEMINI signatures.
------------------------------------------------------------
If you wish to retrain the models with custom data:
-
Collect Human Codebases:
python collect_human.py python --count 20 python collect_human.py java --count 20
-
Add AI Codebases: Place AI-generated sample projects inside
dataset/{language}/ai/{provider_name}/{project_name}/. -
Train XGBoost Models:
python train.py
isitAI/
├── extractors/
│ ├── python_extractor.py # Python AST Extractor
│ └── java_extractor.py # Java AST Extractor
├── models/
│ ├── python_ast_model.json # Pre-trained Python XGBoost weights
│ ├── java_ast_model.json # Pre-trained Java XGBoost weights
│ └── ...
├── base_extractor.py # Extractor Contract Interface
├── registry.py # Multi-Language Model & Extractor Registry
├── repo_analyzer.py # Multi-Repo Feature Aggregator & Inference Engine
├── scan.py # CLI Entry Point
├── collect_human.py # Automated GitHub Repo Collector
├── train.py # Multi-Language Model Trainer
└── requirements.txt
You can run isitAI instantly using the pre-built image from Docker Hub—no Python installation required.
docker pull akmall123/isitai:latest- Scan a Remote GitHub Repository:
docker run --rm akmall123/isitai:latest <github-repo-url>(Example: docker run --rm akmall123/isitai:latest https://github.com/spring-projects/spring-petclinic)
- Scan Current Working Directory:
docker run --rm -v $(pwd):/code akmall123/isitai:latest /code- Scan Any Specific Local Directory:
docker run --rm -v /path/to/your/project:/code akmall123/isitai:latest /codedocker build -t isitai .
docker run --rm isitai <github-repo-url>isitAI uses a modular extractor pipeline, making it easy to add support for additional programming languages (e.g., Go, C++, JavaScript, Rust).
Create a new file in the extractors/ directory (for example, extractors/go_extractor.py) that inherits from BaseExtractor:
from base_extractor import BaseExtractor
class GoExtractor(BaseExtractor):
def extract_features(self, file_path: str) -> dict:
"""
Parse the source file and return structural/AST metrics.
Returns a dictionary of numerical feature names to float values.
"""
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
code = f.read()
# Parse AST or extract structural metrics here
return {
"ast_node_count": 0.0,
"max_nesting_depth": 0.0,
"avg_identifier_length": 0.0,
# Return dictionary of numeric features
}Update registry.py to map the new file extension and language keyword to your extractor:
from extractors.go_extractor import GoExtractor
EXTRACTOR_REGISTRY = {
"python": PythonExtractor,
"java": JavaExtractor,
"go": GoExtractor, # Add new extractor here
}
FILE_EXTENSIONS = {
".py": "python",
".java": "java",
".go": "go", # Map file extensions
}- Add search keywords for your new language to
LANG_CONFIGSincollect_human.py. - Place corresponding AI-generated code samples in
dataset/<language>/ai/<provider>/. - Run the training script to generate the model artifact (
<language>_ast_model.jsoninmodels/):
python train.py