Overview
CodeProof AI is a local-first Python CLI and reusable GitHub Action for verifying Python repositories. It runs deterministic checks — Ruff, mypy, pytest, Bandit, Semgrep and an import-smoke check — normalizes the evidence from each tool, and calculates a transparent weighted confidence score. Reports are exported as JSON, Markdown and HTML, and stored under .codeproof/reports/.
It exists because "the tests pass" is not the same as "the change is safe." AI-generated and human-written Python alike can compile, type-check silently wrong, or ship with untested public symbols. CodeProof does not claim code is correct — it reports whether configured checks passed, which failing evidence drove the score down, and what to fix first.
It is built for Python developers and maintainers who want a single, scriptable gate locally and in CI: solo developers checking AI-assisted pull requests, teams enforcing a weighted policy on every merge, and reviewers who want an offline HTML report with expandable evidence instead of scrolling raw tool logs.
Use cases
- Gate AI-generated pull requests — run
codeproof scan . --fail-under 70 so generated code must clear your policy before merge. - CI quality gate — drop the composite GitHub Action into a workflow and fail the build when required tools or weights don't pass.
- Pre-merge self-check — run a syntax-only scan (
--checks syntax) for a fast execution-free sanity pass. - Test-gap triage — use
codeproof inventory . to list public symbols with no detected tests, then generate reviewable smoke tests. - Dependency auditing — opt in to pip-audit (install
codeproof-ai[audit]) to flag known-vulnerable requirements. - Local review workspace — run
codeproof serve . for a browser UI with durable history, findings search and report comparison. - SARIF for code scanning — export
--format sarif to feed findings into GitHub code scanning. - Policy enforcement across repos — commit a shared
.codeproof.yml and enforce the same required tools and weights everywhere.
How to work with it
A typical day looks like this. You push a branch; CI runs codeproof scan . --format all --fail-under 70 --jobs 3. The job exits 0 (policy passed), 1 (policy failed) or 2 (invalid usage or configuration). You open codeproof-report.html from .codeproof/reports/ — offline search, status filters and expandable evidence show you which check dragged the score down. You fix the mypy errors, re-run the scan locally, watch the confidence score climb past your threshold, and merge. Locally, codeproof doctor tells you which tools are missing and how to install them before you ever push.
codeproof doctor # are ruff/mypy/pytest/bandit/semgrep available?
codeproof scan . --fail-under 70
open .codeproof/reports/codeproof-report.html
Features
- Six checker adapters — Ruff (lint), mypy (types), pytest (tests), Bandit (security), Semgrep (static analysis) and an import-smoke check, all normalized to one evidence model.
- Weighted policy and required-tool gates — partial policies overlay the six default checks; a selected or configured check cannot bypass a required tool gate.
- AST test-gap inventory —
codeproof inventory . lists public symbols (not coverage) so you can see what is untested. - Reviewable smoke-test generation —
codeproof generate-tests . --output tests/generated writes import/exposure tests; existing files are preserved unless --force is passed. - CI-friendly exit codes — 0 policy passed, 1 policy failed, 2 invalid usage or configuration.
- GitHub composite Action — the same scan runs locally and in CI with one configuration.
- Local-first scanning — no code leaves your machine; reports stay under
.codeproof/reports/. - Local developer workspace —
codeproof serve . opens a responsive browser UI on http://127.0.0.1:8765/ with four presets, durable history (latest 50 runs), findings search, report comparison, tool readiness and policy inspection. Export JSON, Markdown, HTML or SARIF. - Optional pip-audit — dependency auditing is opt-in; unsupported manifests are reported unavailable, never audited as a fallback.
Installation
Requires Python. Use a virtual environment (recommended) or install into your pip environment:
python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux/macOS: source .venv/bin/activate
pip install -e ".[checkers]"
codeproof scan .
Or with plain pip:
pip install -e ".[checkers]"
For dependency auditing, install the extra and add pip-audit: {enabled: true, weight: 15} under checks with a root requirements.txt:
pip install 'codeproof-ai[audit]'
For development (pytest and tooling):
pip install -e ".[dev]"
pytest
Quickstart (30 seconds)
$ codeproof init
# writes a default .codeproof.yml policy
$ codeproof scan .
ruff pass weight 20
mypy pass weight 20
pytest pass weight 25
bandit pass weight 15
semgrep pass weight 15
imports pass weight 5
confidence: 100 / policy: PASS (exit 0)
reports: .codeproof/reports/codeproof-report.html
One command writes a policy, one command scans, and you get an offline HTML report with expandable evidence. Open the report, or wire the same command into CI.
Workflow & architecture
CodeProof follows a pipeline: it loads your policy (.codeproof.yml — partial overlays on the six defaults), resolves which checks are enabled, executes each adapter (serially by default; --jobs 2 through --jobs 8 for concurrency), normalizes every tool's output into uniform evidence records, computes the weighted confidence score, then applies required-tool and --fail-under gates before writing reports.
policy → check adapters → normalized evidence → weighted score → policy gate → JSON / Markdown / HTML / SARIF
Invalid thresholds, negative or non-finite weights, unknown tools and unknown policy keys are rejected up front. A passing report is evidence that configured checks passed — not proof of correctness. A syntax-only, execution-free scan is one policy away: set required_tools: [] with syntax: {enabled: true, weight: 10} under checks.
Troubleshooting
- "Tool unavailable" for a required tool — run
codeproof doctor; it prints availability and install guidance. Missing required tools fail policy; optional ones are marked unavailable and excluded from the denominator. - Policy failed but I don't know why — open
codeproof-report.html; filter by status and expand the check evidence to see the exact tool output. - Semgrep auto wants the network —
auto can retrieve rules; point Semgrep at a local rules directory for offline operation. - pytest or import checks hang or mutate state — they execute repository code; scan untrusted repos only in an isolated container or ephemeral runner.
- Exit code 2 — invalid usage or configuration: check your policy keys, weights (finite, non-negative) and that tool names are known.
- Generated tests overwrote my files — they don't; existing files are preserved unless you pass
--force. Review generated tests before running them.
Release & license
CodeProof AI is local-first and under active development. Version history, compatibility notes and follow-up work are tracked in the repository's docs/roadmap.md; the workspace setup and workflows are in docs/developer-workspace.md. Licensed under MIT.
Need help? Visit the PeaBox Lab help page or go straight to the source: