AI Patch Inspector is a lightweight Python CLI that analyzes your current Git diff and estimates change risk (0-100), with extra focus on AI/Codex-assisted edits.
When patches are generated quickly, it is easy to miss risky patterns:
- production code changes without test updates
- risky CLI/API edits
- dependency/config/CI changes
- very large diffs
- deleted tests
- new TODO/FIXME markers
- dangerous Python additions (
eval,exec,subprocess) - broad exception catches
This tool gives a fast pre-commit safety signal.
pip install -e .ai-patch-inspector
python -m ai_patch_inspectorai-patch-inspector --staged-only
ai-patch-inspector --since HEAD~1
ai-patch-inspector --jsonNotes:
- default mode analyzes both staged and unstaged changes
--staged-onlyand--sincecannot be combined
Terminal report includes:
- risk score
- changed files by category
- findings
- suggestions
JSON mode (--json) returns machine-readable report for CI or automation.
The score (0-100) increases when:
- production code changed but tests did not
- CLI/API files changed
- dependency/config/CI files changed
- diff size is large
- test files were deleted
- TODO/FIXME added
eval/exec/subprocessadded in Python- broad
excepthandlers added in Python
pip install -e .[dev]
pytestAI Patch Inspector анализирует git diff и показывает риск изменений от 0 до 100.
Запуск:
ai-patch-inspector
python -m ai_patch_inspectorФлаги:
--staged-only
--since HEAD~1
--jsonСигналы риска:
- изменён прод-код без изменений тестов
- изменены CLI/API, config, CI, lock/deps
- большой diff
- удалены тесты
- добавлены TODO/FIXME
- добавлены
eval/exec/subprocess - добавлены broad exception catches
MIT (see LICENSE).