AI-powered code analysis that watches your changes
CodeWatch uses AI (Cerebras) to check your code changes against customizable rules. Violations are automatically copied to clipboard so you can paste to AI for instant fixes.
- 🔍 Check uncommitted changes, commits, or commit ranges
- 🤖 AI-powered analysis using Cerebras
- 📋 Simple rule groups (security, performance, ui, style)
- 📋 Auto-copy to clipboard - paste to AI for fixes
- 🎨 Beautiful terminal output
- 📊 Multiple formats: console, JSON, markdown
- 🚀 CI/CD ready
pip install -e .# 1. Initialize
codewatch init
# 2. Set API key
export CEREBRAS_API_KEY="your-key"
# 3. Create rules
cp default-rules.json rules.json# Check uncommitted changes
codewatch
# Check specific commit
codewatch -c abc123
# Check commit range
codewatch -r main..feature
# Filter by group
codewatch -g security
# JSON output
codewatch -f json -o report.json
# Don't copy to clipboard
codewatch --no-copyRules are simple:
{
"id": 1,
"name": "No hardcoded secrets",
"prompt": "Check for hardcoded API keys",
"group": "security"
}Groups: security, performance, ui, style, etc.
# Interactive
codewatch setup
# With AI
codewatch add-rule "Check for SQL injection"
# Generate multiple
# (in setup menu, option 4)# Generate new examples
codewatch generate "Python API code"
# Modify existing file
codewatch generate "add hardcoded password" myfile.pycodewatch install-hookWhat happens:
- Try to commit
- CodeWatch runs
- Violations found → auto-copied to clipboard
- Paste to Claude/AI to get fixes
- Apply fixes and commit
Location: ~/.codewatch/config.json
{
"cerebras": {
"api_key": "your-key",
"model": "llama3.1-8b",
"endpoint": "https://api.cerebras.ai/v1"
},
"rules": {
"path": "./rules.json"
}
}Update:
codewatch config --set cerebras.api_key=sk-xxxexample.py:10 (2 violations)
password = "admin123"
☐ Rule 1: Hardcoded password
☐ Rule 16: Sensitive credential
✓ Copied to clipboard
Paste violations to AI → get fixes → apply → done!
codewatch # Check changes
codewatch setup # Interactive setup
codewatch add-rule # Add rule with AI
codewatch generate # Generate code
codewatch install-hook # Install pre-commit hook
codewatch config # View/edit config-ccommit-rrange-bbranch-fformat-ooutput-vverbose-ggroup-hhelp
0= Pass1= Fail (violations)2= Error
- name: CodeWatch
run: codewatch -r ${{ github.base }}..${{ github.head }}
env:
CEREBRAS_API_KEY: ${{ secrets.CEREBRAS_API_KEY }}"API key not configured"
export CEREBRAS_API_KEY="your-key""Rules file not found"
cp default-rules.json rules.jsonMIT