Scrut
AST-based static analysis for unstaged Python changes.
---
Table of Contents
- What is Scrut?
- Why AST?
- Features
- Architecture
- Repository Layout
- Installation
- Quick Start
- Example Output
- Review Rules
- Data Model
- Exit Behavior
- Current Limitations
- Roadmap
- Contributing
- License
---
What is Scrut?
Scrut is a CLI tool that analyzes unstaged changes in Git repositories. It parses changed Python files with ast.parse, checks four structural rules, and prints a formatted report — zero dependencies beyond Python 3.10+ and Git.
No configuration files. No plugins. No network access.
It is for Python developers who want lightweight, offline feedback on code structure before opening a pull request.
---
Why AST?
Most review tools use regex to detect code issues. Regex cannot reliably match multi-line function signatures, measure nesting depth, or distinguish definitions from calls.
Python's ast module parses source into a syntax tree. From the tree, Scrut reads:
- Parameter count — len(node.args.args)
- Nesting depth — recursive walk counting only For, If, and While nodes
- Line counts — endlineno - lineno
The tree structure guarantees correct results for every valid Python file. There are no false positives from comment strings, no missed multi-line signatures, no fragile patterns.