AI Contribution Detection Engine for Git Repositories (CLI + Web)
Sniff is an AI detection system designed to analyze Git repositories and estimate the likelihood that commits or code contributions were generated or heavily assisted by AI tools.
It combines deterministic structural analysis with a local Large Language Model (GPT-2 via HuggingFace) to provide explainable AI-likelihood scoring.
You can use Sniff in two ways:
- Python CLI (
sniff) for interactive terminal workflows and local/remote repo analysis - Web App (JavaScript) (
sniff_web_js) for browser-based demos and deployment
The core detection approach is shared conceptually across both experiences.
AI-Generated Code Transparency & Governance in Modern Development
With the rapid rise of AI coding assistants such as GitHub Copilot and ChatGPT, developers are increasingly committing AI-generated code without fully understanding it.
This creates several risks:
- Technical debt accumulation
- Security vulnerabilities
- Loss of code ownership accountability
- Academic integrity violations
- Reduced code quality over time
Currently, Git platforms provide no structured transparency layer to detect or analyze AI-assisted contributions.
- DevSecOps Teams
- Enterprise Engineering Managers
- Academic Institutions
- Open Source Maintainers
- Security Auditors
- No repository-level AI usage analytics
- No explainable AI-likelihood scoring for commits
- No structured governance tools for AI contribution transparency
AI-generated code often exhibits:
- Highly structured and formal commit messages with low linguistic entropy
- Boilerplate-heavy code patterns with repetitive variable naming
- Large bursts of code additions in physically impossible time windows
- Consistent function scaffolding (docstrings, uniform indentation, predictable naming)
Existing approaches rely on simple keyword matching (fragile) or fully black-box cloud APIs (non-transparent). Sniff is the first offline, explainable alternative.
Sniff uses a hybrid detection pipeline consisting of 6 deterministic and statistical offline engines, combined with an optional prompt-engineered Claude API tie-breaker.
- Uses a local HuggingFace GPT-2 model to calculate the log-probability perplexity of commit messages.
- LLMs produce mathematically "perfect" text (low perplexity). Human writing is chaotic and bursty.
- Flag: Perplexity < 30 β Score: 0.9
- Parses code additions into a Python Abstract Syntax Tree (AST) to analyze structural complexity.
- Detects AI signatures: high docstring density, low lexical entropy, uniform scaffold patterns.
- Falls back to raw diff heuristics for non-Python code (React/JS/Go), detecting patterns like
useState + useEffectbursts. - Flag: Low variable uniqueness ratio β Score: 0.3β0.4
- Cross-references Lines of Code added per minute by parsing GitPython commit timestamps.
- Flags physically impossible typing speeds (> 50 LPM).
- Uses Sentence Transformers (
all-MiniLM-L6-v2) to measure the cosine similarity between the commit text and the raw code diff. - AI often perfectly describes exactly what the code does (high similarity). Humans are notoriously lazy (low similarity).
- Dynamically calculates the historical commit size for the current author.
- Flags massive multi-file PRs that break their own standard deviation (z > 3.0Ο).
- Computes highly optimized, locality-sensitive hashes of the code diff.
- Flags developers who are committing code that is mathematically identical (85%+) to previous diffsβa strong signal of AI template copy-pasting.
If the 6 local engines return a "Borderline" score (0.35 to 0.50), Sniff will securely package the commit and send it to Anthropic Claude 4.6 Sonnet for a deterministic tie-breaker verification.
final_score = weighted_average(text, code, structural, semantic, baseline, simhash) + velocity_boost
- Results in a deterministic, explainable AI-likelihood band: Likely Human / Mixed / Likely AI-Assisted
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β Your Terminal β β Sniff ML Engines β β Claude Model β
β (Sniff CLI) β β (Offline) β β (Anthropic API) β
ββββββββββ¬ββββββββββ ββββββββββ¬ββββββββββ ββββββββββ¬ββββββββββ
β β β
β 1. Run `scan` command β β
ββββββββββββββββββββββββββββββββββ>β β
β Payload: [Git Commits + Diffs] β β
β β 2. Sequence Offline Analyzers β
β βββ β
β β<β β
β β 3. Score Evaluated (e.g. 0.45) β
β βββ β
β β<β β
β β 4. Ask: "Is this AI or Human?" β
β ββββββββββββββββββββββββββββββββββ>β
β β β
β β 5. "Verdict: AI-Assisted" β
β β<ββββββββββββββββββββββββββββββββββ
β 6. Display Dashboard Result β β
β<ββββββββββββββββββββββββββββββββββ β
β β β
ββββββββββ΄ββββββββββ ββββββββββ΄ββββββββββ ββββββββββ΄ββββββββββ
β Your Terminal β β Sniff ML Engines β β Claude Model β
β (Sniff CLI) β β (Offline) β β (Anthropic API) β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
Sniff is stateless and requires no external database. All analysis runs in-memory.
| Layer | Technology |
|---|---|
| Core ML / CLI Language | Python 3.9+ |
| Web App Language | Node.js (JavaScript, Node 18+) |
| CLI Framework | Typer / Questionary |
| CLI UI & Layout | Rich (Tables/Panels) |
| Web UI/API | Express + Vanilla JS + HTML/CSS |
| ASCII Charts | Plotille / PyFiglet |
| Git Data | GitPython |
| NLP Model | HuggingFace Transformers (GPT-2) |
| Semantic Engine | Sentence Transformers |
| ML Backend | PyTorch |
| Verification API | Anthropic API |
Top-level folders:
sniff_cli/- Python CLI implementation and detection enginessniff_web_js/- JavaScript web interface for browser usage and deploymentdemo_repo/- Sample repository for testing
The easiest way to globally install the Sniff engine is via PyPI:
pip install sniff-cli(Optional) To enable the LLM tie-breaker protocol, export your Anthropic key:
export ANTHROPIC_API_KEY="sk-ant-..."cd sniff_web_js
npm installOptional environment variables:
GITHUB_TOKEN(recommended for higher GitHub API rate limits)ANTHROPIC_API_KEY(only needed for LLM tie-breaker mode)
Sniff operates purely inside a unified, persistent terminal session. Start the engine by typing:
sniffDuring startup, Sniff will prompt you to select your LLM settings, and then ask for the target repository. You can pass a local filepath (.) or a Remote GitHub URL (https://github.com/mrgear111/sniff).
Once inside the sniff> REPL shell, type these commands natively:
| Command | Description |
|---|---|
scan [count] |
Analyze the N most recent commits (Default: 10). Pass --no-llm to bypass Anthropic for this run. |
stats [count] |
Analyze codebase and view the AI-Density Contributor Leaderboard. |
cd <path/url> |
Dynamically switch to a new local directory or remote GitHub URL workspace. |
clear |
Clear the terminal screen |
exit |
Quit the active session |
Sniff now also includes a browser-based interface that reuses the same detection engines.
Start the web app:
cd sniff_web_js
npm run devThen open:
http://localhost:8080
In the web UI, you can:
- Enter a public GitHub repository URL
- Set commit count to analyze
- Optionally enable LLM tie-breaker mode
- View commit-level scores and an author leaderboard in the browser
For production-style local run:
npm startThe web app in sniff_web_js is designed to be deployable (for example on Render or Railway):
- Build command:
npm install - Start command:
npm start - Root directory:
sniff_web_js - Recommended env var:
GITHUB_TOKEN - Optional env var:
ANTHROPIC_API_KEY
Sniff relies on statistical ML models and behavioral heuristics. It is a powerful auditing signal, not a definitive legal claim of AI generation. Results should always be reviewed by a human auditor before action is taken.