AI code reviewer that learns from your preferences through reinforcement learning.
Cortex is a privacy-first code reviewer that runs entirely on your machine. Unlike cloud-based tools, it learns YOUR coding style through reinforcement learning and gets smarter with every commit.
- ๐ Privacy-First: All analysis happens locally, code never leaves your machine
- ๐ง Adaptive Learning: Uses RL to learn from your accept/reject decisions
- โก Fast: Sub-2-second reviews with quantized local models
- ๐ฏ Context-Aware: Understands your project structure and patterns
- ๐ ๏ธ Git Integration: Seamlessly works with your existing workflow
- ๐ Multi-Language: Supports Go, Python, JavaScript, TypeScript, and more
# Clone repository
git clone https://github.com/AdeshDeshmukh/cortex.git
cd cortex
# Build
make build
# Install system-wide (optional)
make install# Navigate to your project
cd ~/projects/myapp
# Install git hook
cortex install
# Make code changes
echo "func test() {}" >> main.go
git add main.go
# Commit (Cortex reviews automatically)
git commit -m "Add test function"Output:
๐ง Cortex Review
๐ Summary:
Files changed: 1
Lines added: +1
Lines removed: -0
Languages: go (1)
๐ Files:
1. main.go (go)
+1 -0 lines
โณ Analysis pipeline:
โ
Diff parsing complete
โน๏ธ Static analysis (coming soon)
โน๏ธ LLM suggestions (coming soon)
| Command | Description |
|---|---|
cortex install |
Install pre-commit hook in current repo |
cortex install --force |
Overwrite existing hook |
cortex install --uninstall |
Remove hook |
cortex review |
Manually review staged changes |
cortex review --hook |
Run in hook mode (internal) |
cortex --help |
Show all commands |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ USER COMMITS CODE โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GIT PRE-COMMIT HOOK โ
โ Triggers: cortex review --hook โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DIFF PARSER (Go) โ
โ Converts git diff โ structured data โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ANALYZER PIPELINE โ
โ 1. Static analysis (regex, AST) โ
โ 2. LLM inference (local model) โ
โ 3. Ranking (RL policy) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INTERACTIVE UI โ
โ User accepts/rejects suggestions โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FEEDBACK LOOP (Python) โ
โ Trains model on user preferences โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Go 1.21+
- Git
- Python 3.10+ (for ML features)
# Clone repo
git clone https://github.com/AdeshDeshmukh/cortex.git
cd cortex
# Install dependencies
go mod download
# Run tests
make test
# Build
make build
# Run locally
./cortex --help# Run all tests
make test
# Run with coverage
make coverage
# Run specific package
go test ./internal/git/cortex/
โโโ cmd/cortex/ # CLI entry point
โ โโโ main.go
โ โโโ commands/ # Cobra commands
โ โโโ root.go
โ โโโ install.go
โ โโโ review.go
โโโ internal/ # Private application code
โ โโโ git/ # Git integration
โ โโโ hooks.go # Hook management
โ โโโ diff.go # Diff parsing
โ โโโ *_test.go # Tests
โโโ pkg/ # Public libraries
โ โโโ types/ # Type definitions
โ โโโ types.go
โโโ go.mod # Go dependencies
โโโ Makefile # Build automation
โโโ README.md # This file
- Git hook installation
- Diff parsing
- CLI framework
- Test infrastructure
- Static code analysis
- LLM integration (local inference)
- Prompt engineering
- Suggestion generation
- Feedback collection system
- SQLite storage
- RL training pipeline (DPO)
- Model personalization
- Multi-language support expansion
- IDE integration (VS Code, IntelliJ)
- Team-wide model sharing
- Custom rule definitions
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
We follow Conventional Commits:
feat: New feature
fix: Bug fix
docs: Documentation changes
test: Test additions/changes
refactor: Code refactoring
chore: Maintenance tasks
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Cobra for CLI
- Inspired by first-principles thinking
- Part of ongoing learning journey in AI/ML systems
Adesh Deshmukh
- GitHub: @AdeshDeshmukh
- Project: github.com/AdeshDeshmukh/cortex
โญ If you find this project useful, please consider giving it a star! // test hook