Sanity - Pre-commit Risk Checker
Sanity acts as a pre-commit risk checker for AI-generated code changes. It evaluates code additions for dangerous statements, exposed secrets, and scope drift, and safely blocks risky commits.
Safety Nets & Snapshots
Whenever a commit is allowed (whether deemed safe, or overridden via --force), Sanity automatically creates a lightweight local git tag (e.g. sanity-snapshot-20260823-153012) pointing to the commit before the new changes. This ensures that even if an AI agent makes a destructive commit, you can easily view your history and roll it back using sanity rollback <number>.
Note:
sanity-snapshot-*tags are intended strictly as local safety nets. Git naturally keeps tags local during a standardgit push, so they won't clutter your remote repository unless you explicitly rungit push --tags.
What it catches
- Mass deletions -- flags commits that delete far more code than they add
- Leaked secrets -- detects API keys, AWS credentials, private keys
- Dangerous commands -- catches
rm -rf,DROP TABLE, force-push scripts - Scope creep -- uses LLM analysis to verify changes match the stated task
- Auto-snapshots -- every commit gets a safety snapshot for easy rollback
Quick start
# Install
pip install -e .
# Set up your Groq API key (free tier)
cp .env.example .env
# Edit .env with your key from https://console.groq.com
# Install the pre-commit hook in your repo
sanity init
# Manually check staged changes
sanity check
# Rollback to a previous safe state
sanity rollback
Commands
| Command | Description |
|---|---|
sanity init |
Install pre-commit hook in current repo |
sanity check |
Run safety checks on staged diff |
sanity rollback |
Revert to a previous safe snapshot |
sanity config |
Configure thresholds and toggle checks |
Requirements
- Python 3.11+
- Git
- Groq API key (free, no credit card needed)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanity_guard-0.1.0.tar.gz.
File metadata
- Download URL: sanity_guard-0.1.0.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11e94a4b1d7d5838e69fa59b73d8833c64430f40e53fa3b7d4ae55f790dc98ba
|
|
| MD5 |
776de70924e664b401559e6fc97db655
|
|
| BLAKE2b-256 |
529d9fbc261bd6895537995e3858d371b70a142b9f030bb0f6080aa58d88a380
|
File details
Details for the file sanity_guard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sanity_guard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032e5149b9eff25205ff1e9a1c8624b5c13e00d335e4470208024431eb71aeaa
|
|
| MD5 |
547c8756c04cc61309cb7d00099b5a3b
|
|
| BLAKE2b-256 |
8ffae8993fff1727b8c5cb47c533472b326d29609d574a0ec8d508f7445769bc
|