DiffDefender is a privacy‑first, local‑only AI code review bundle built specifically for Symfony developers. It runs entirely on your machine using Ollama, ensuring that your proprietary code never leaves your environment.
Runs on Ollama locally. No API keys, no subscriptions, no cloud.
Understands Symfony internals—including routes, security rules, Doctrine entities, and migrations.
Detects if you modified a Doctrine Entity without generating a Migration.
Flags dump(), dd(), var_dump(), and other debugging leftovers.
Readable terminal output with line numbers and clear fix suggestions.
- PHP 8.1+
- Symfony 6.0 / 7.0 / 8.0+
- Ollama installed and running
ollama pull deepseek-coderOLLAMA_HOST=0.0.0.0 ollama servecomposer require busanstu/diff-defender-bundle:dev-master --devAdd to .env or .env.local:
| Environment | Variable | Value |
|---|---|---|
| Mac/Windows (Docker) | OLLAMA_API_URL |
http://host.docker.internal:11434/api/chat |
| Linux (Docker) | OLLAMA_API_URL |
http://172.17.0.1:11434/api/chat |
| Host machine (no Docker) | OLLAMA_API_URL |
http://localhost:11434/api/chat |
| Any | OLLAMA_MODEL |
deepseek-coder |
php bin/console list diffExpected output:
diff:review
DiffDefender analyzes only staged changes.
git add .php bin/console diff:reviewIf the staged code contains:
dump($data);You may see:
🛡️ DiffDefender: Local AI Code Review
===================================
b/src/Controller/ExampleController.php (+1 / -0)
-----------------------------------------------
🔗 Context Injected: Security & Routing rules applied.
--- Analyzed Code Snippet ---
15 | dump($data);
-----------------------------
[CRITICAL] CLEANLINESS (NO DEBUGGING)
📍 Line: 15
💡 Fix: Remove this debugging function before committing.
Issues detected. Please review before pushing.
| Component | Responsibility |
|---|---|
| GitWrapper | Extracts staged changes (git diff --cached) |
| DiffParser | Converts raw diff text into structured DTOs |
| ContextProvider | Reads config/migration files and enriches prompts |
| OllamaClient | Sends prompts to local Ollama & enforces strict JSON output |
| ReviewCommand | Orchestrates the entire review process |
- Commit your changes:
git commit -m "..."- Push to GitHub:
git push- Create a tag on GitHub (e.g.,
v1.0.1).
Users can update via:
composer update busanstu/diff-defender-bundleThis project is licensed under the MIT License.
See the LICENSE file for details.