Review before you deploy.
CodeGuard is a local-first code review agent. Point it at a project folder and it checks the code for selected security risks and quality problems, runs available tests, asks an AI model to review suspicious code, and creates an audit report.
It is designed to be an extra reviewer for code written by people or AI coding tools. It does not replace a developer, a professional security audit, or a complete test strategy.
In simple words: Your coding tool writes the code. CodeGuard checks it again and tells you what may be wrong.
A project can appear to work and still contain problems:
- A password or API key may have been committed.
- An endpoint may accept unsafe input.
- A function may hide errors instead of handling them.
- A dependency may have a known security issue.
- Important edge cases may not have tests.
- A code change may fix one bug but break another.
- AI-generated code may contain unfinished or incorrect logic.
Checking every file manually takes time. CodeGuard adds another review step to help find these problems earlier.
- Looks through the selected project folder.
- Runs its built-in code and security checks.
- Uses optional external tools when installed.
- Runs supported project tests when enabled.
- Uses an AI model to review selected code and suggest improvements.
- Can prepare proposed fixes in a temporary working copy.
- Checks proposed changes and can reject changes that make checks or tests worse.
- Creates Markdown, HTML and JSON reports.
The exact checks depend on the project language, installed tools, configuration and available tests.
| Benefit | Why it is useful |
|---|---|
| Extra review layer | Gives your code another check before you ship it. |
| Local AI option | Can use Qwen through Ollama without a paid AI API. |
| Lower running cost | Local inference does not charge per request; your computer still uses power and memory. |
| Project-folder workflow | Review an existing project without rewriting it for CodeGuard. |
| Security checks | Looks for selected risky code patterns and exposed secrets. |
| Test execution | Runs supported tests to catch some regressions. |
| Fix review | Checks proposed fixes before offering them for application. |
| Reports | Saves findings in formats that are easy to read or process. |
| Optional CI use | Can be added to a GitHub Actions workflow. |
- Students checking college and final-year projects.
- Developers reviewing personal or client projects.
- People using AI coding tools such as Antigravity, Cursor or other code generators.
- Small teams that want an additional automated review step.
- Hackathon participants who want to check a project before submission.
The current version has built-in checks that are strongest for Python, plus a smaller set of general and JavaScript-oriented checks.
| Area | Examples |
|---|---|
| Security | Risky eval/exec, shell command use, SQL patterns, unsafe YAML or pickle use, weak hashes, disabled TLS verification |
| Secrets | Possible hardcoded API keys, tokens, passwords and private keys |
| Code quality | Mutable defaults, unfinished stubs, TODO markers, swallowed exceptions and high-complexity code |
| JavaScript | Selected risky patterns such as possible unsafe HTML injection |
| Project workflow | Missing README or .gitignore, committed .env, risky GitHub Actions patterns and Dockerfile hygiene |
| Dependencies | Unpinned Python requirements and known vulnerable packages when pip-audit is installed |
| Tests | Runs supported test commands and records pass/fail results |
Optional tools include:
- Bandit — additional Python security checks.
- Ruff — Python linting.
- pip-audit — Python dependency vulnerability checks.
Install the optional tools with:
python -m pip install -e ".[tools]"CodeGuard only reports what its rules and tools can detect. It does not understand every possible application-specific risk.
CodeGuard automatically detects whichever model you have downloaded in Ollama (e.g. qwen2.5-coder:1.5b, qwen2.5-coder:3b, etc.), so you never have to worry about manual model mismatches.
- CLI Flag:
codeguard review . --model qwen2.5-coder:1.5b - Configuration file:
codeguard.toml(model = "...") - Environment file:
.env(CODEGUARD_MODEL=...auto-loaded from project root) - Dynamic local auto-detection: Probes Ollama and uses the best locally installed coding model.
- Default:
qwen2.5-coder:3b
- Ollama runs the model on your own computer.
- Local inference does not require a paid API key.
- After the model is downloaded, local review can work without internet access.
- Your code is not sent to a third-party AI inference provider when you use local Ollama.
- You can choose a smaller or larger model based on your machine.
The first model download requires internet. Hardware, electricity and storage are still required.
Approximate model download sizes are shown below. Actual RAM use depends on context length, quantization, operating system and other running applications.
| Model | Approx. download | Practical guidance |
|---|---|---|
| Qwen2.5-Coder 0.5B | 0.4 GB | Very limited hardware; weaker reasoning |
| Qwen2.5-Coder 1.5B | 1 GB | Good starting point for low-memory computers |
| Qwen2.5-Coder 3B | 1.9 GB | Better starting point when more memory is available |
| Qwen2.5-Coder 7B | 4.7 GB | Prefer a computer with substantially more RAM |
| Qwen2.5-Coder 14B | 9 GB | High-memory computer recommended |
These are approximate model-file sizes, not total system RAM requirements.
| Resource | Basic local use | More comfortable use |
|---|---|---|
| RAM | 8 GB, with a small model | 16 GB or more |
| Free storage | 5 GB | 15–20 GB |
| GPU | Not required | Helpful, but not compulsory |
| Python | 3.10+ | 3.11+ |
| Internet | Needed for initial downloads | Needed for updates and online tools |
An 8 GB laptop can run a small model, but Windows, the IDE, the project and Ollama all share system memory. Large projects or test suites may make the computer slow. Start with the 1.5B model and close other heavy applications.
- Download Ollama: https://ollama.com/download
- Open PowerShell or Terminal.
- Download the smaller model:
ollama pull qwen2.5-coder:1.5b- Test that it works:
ollama run qwen2.5-coder:1.5bTo use the 1.5B model with CodeGuard in the current PowerShell window:
$env:CODEGUARD_MODEL="qwen2.5-coder:1.5b"For the default 3B model instead:
ollama pull qwen2.5-coder:3bThe default provider settings are:
Provider: Ollama
Model: qwen2.5-coder:3b
URL: http://localhost:11434
API key: Not required
Keep Ollama running while CodeGuard performs AI review. If Ollama or the selected model is unavailable, CodeGuard can still perform its non-AI checks.
- Python 3.10 or newer.
- Windows, Linux or macOS.
- Ollama only if you want local AI reasoning.
- Git is recommended so you can review and undo changes.
Download and extract the CodeGuard ZIP. Open a terminal in the extracted codeguard-agent folder.
Check Python:
python --versionInstall CodeGuard in editable mode:
python -m pip install -e .Check the command:
codeguard --versionIf the codeguard command is not found, try running it as a Python module from the project directory:
python -m codeguard --helpYou do not need to copy your application source code into the CodeGuard repository.
For example, imagine your project looks like this:
MyProject/
├── backend/
├── frontend/
├── package.json
├── requirements.txt
└── README.md
Open a terminal in MyProject and run:
codeguard review .To review another folder, provide its path:
codeguard review "C:\Projects\MyProject"Run a normal review:
codeguard review .Specify a custom model (e.g. 1.5B or 3B):
codeguard review . --model qwen2.5-coder:1.5bLaunch the interactive single-page web UI:
codeguard uiInitialize CodeGuard in any project (drops .codeguard/ config, git pre-commit hook, and GitHub Action):
codeguard initRun calibration benchmark (Precision, Recall, F1 against ground truth):
python benchmarks/runner.pyCreate reports in Markdown, JSON and HTML:
codeguard review . --format md,json,htmlTry fixes in a temporary copy and create a patch:
codeguard review . --fixApply accepted, verified fixes to the project:
codeguard review . --applyRun without AI:
codeguard review . --no-llmSkip tests:
codeguard review . --no-testsSkip optional external tools:
codeguard review . --no-externalUse Docker for test execution:
codeguard review . --sandbox dockerSet a minimum score for a CI quality gate:
codeguard review . --fail-under 70--fixtries changes in a temporary copy and creates a patch. It does not directly overwrite your project files.--applyalso writes accepted fixes into your project.
Always commit your work or make a backup before applying changes. Review the patch yourself.
By default, reports are saved in:
codeguard-report/
├── report.md
├── report.html
└── report.json
The exact generated filenames are printed by the CLI after a scan.
- Markdown — easy to read in GitHub or a text editor.
- HTML — convenient for viewing a report in a browser.
- JSON — useful for scripts and integrations.
The report includes findings, severity counts, scorecard information, test results and fix details where available.
This is an important question. CodeGuard is an assistant for finding problems, not a guarantee that a project is secure.
It uses several kinds of checks:
| Check type | What it can tell you | Limitation |
|---|---|---|
| Built-in rules | Whether code matches known risky patterns | Cannot detect every vulnerability |
| External scanners | Additional issues covered by those tools | Depends on tool coverage and configuration |
| AI review | Possible logic issues and explanations | AI can be wrong or miss issues |
| Tests | Whether tested behaviour passed | Untested behaviour can still be broken |
| Fix verification | Whether certain checks or tests got worse after a fix | Passing checks does not prove the fix is perfect |
CodeGuard combines rule-based findings, optional scanner output, AI reasoning and test results. An AI suspicion by itself should not be treated as proof.
For important findings, a developer should inspect:
- The affected file and line.
- The explanation and evidence.
- Whether the issue can be reproduced.
- The result from relevant tests or security tools.
- Whether the suggested fix is correct for the application.
No. No automated tool can honestly promise that.
It may miss complex business-logic bugs, runtime issues, race conditions, access-control mistakes, problems in external services and vulnerabilities that are not covered by its rules or tests.
Use CodeGuard as an extra reviewer. Do not use its score as a security certification or as the only approval before production deployment.
When you use Ollama locally, model inference happens on your computer. CodeGuard does not need to upload your source code to a third-party AI provider for that local inference.
If you configure an external OpenAI-compatible or Anthropic provider, the code sent for review goes to that provider and is subject to its terms and data policies.
Tests execute project code. Do not run unknown projects casually on your main machine.
- Prefer Docker sandbox mode for untrusted code.
- Review Docker and sandbox settings before use.
- Do not run untrusted code with administrator privileges.
- Keep secrets out of test environments.
- Do not expose the local HTTP server publicly without production security work.
CodeGuard also includes a local HTTP API and upload dashboard.
Start the server:
python -m codeguard serveBy default, it listens at:
http://127.0.0.1:8080
Open that address in your browser to try the local dashboard.
The API includes scan and report endpoints, API-key support and plan/billing hooks. This is a development capability, not a claim that a production multi-tenant SaaS deployment is ready. Read docs/DEPLOYMENT.md before exposing it beyond localhost.
The repository includes an example GitHub workflow and an action definition.
See:
examples/github-workflow.ymlaction.yml
These can be used as a starting point for adding CodeGuard checks to a repository workflow. Review and configure the workflow for your own project and CI environment before enabling it on important repositories.
codeguard-agent/
├── codeguard/
│ ├── pipeline.py # Review pipeline
│ ├── llm.py # Ollama and optional provider adapters
│ ├── scanner.py # Built-in scanning
│ ├── fixer.py # Fix proposal and verification
│ ├── testrunner.py # Test execution
│ ├── report.py # Report generation
│ ├── scoring.py # Scorecard
│ ├── server.py # HTTP API and dashboard
│ └── ...
├── tests/ # Automated tests
├── examples/ # Example project and workflow
├── docs/
│ ├── LOCAL_LLM.md
│ ├── RULES.md
│ ├── ARCHITECTURE.md
│ └── DEPLOYMENT.md
├── action.yml
├── Dockerfile
├── pyproject.toml
└── README.md
Please read these before relying on CodeGuard:
- Built-in analysis is currently strongest for Python. JavaScript/TypeScript checks are more limited.
- It is not a replacement for a full enterprise SAST platform or a professional penetration test.
- Smaller local models can give weaker or incorrect reasoning.
- AI review depends on model availability and context limits.
- Test-based verification is only as useful as the project's tests.
- If a project has no tests, verification is weaker; syntax checks and rescanning cannot prove behaviour is correct.
- Running arbitrary project tests is risky without isolation.
- Cloud deployment, production authentication, billing operations and multi-tenant hardening require additional work.
Potential future improvements:
- Better JavaScript, TypeScript, Java, Go and C/C++ analysis.
- Hardware detection and automatic model recommendations.
- More built-in security rules.
- Better evidence and reproducibility for findings.
- Test generation for changed code.
- Improved false-positive handling.
- Richer dashboard and scan history.
- GitHub pull-request review automation.
- Cloud-hosted dashboard and orchestration.
- Team controls and audit history.
Roadmap items are plans, not features promised by the current release.
Contributions, bug reports and suggestions are welcome.
Helpful contributions include:
- New detection rules with tests.
- Fixes for false positives and false negatives.
- Better language support.
- Improved model prompts and provider compatibility.
- Test-runner improvements.
- Documentation and installation fixes.
For security rules, include examples that should trigger the rule and examples that should not.
See the LICENSE file in this repository for license terms.
CodeGuard is an extra pair of eyes for your code.
Use it after generating code, before opening a pull request, or before deploying a project. Let it identify suspicious areas, explain possible risks, run available checks and prepare fixes for your review.
Review before you deploy.