Prism CodeLens reviews your code right from the terminal. Point it at a file, a folder or your git changes and it finds security holes, bugs and code smells, explains each one, suggests a fix, gives your code a score from 0 to 100 and can export a clean Markdown report.
- ๐ง AI mode. Uses Gemini, Groq, OpenRouter, OpenAI, a local Ollama model or any OpenAI-compatible API
- ๐ Offline mode. A built-in rule engine with 17 rules works with no key and no internet
- ๐งฌ Best of both. In AI mode the offline findings are merged in, so obvious problems are never missed
- ๐ Git aware.
codelens diffreviews only the lines you changed, perfect before a commit or PR - ๐ฆ CI ready.
--jsonand--fail-onturn it into a quality gate - ๐ฆ Zero dependencies. Plain Node.js, nothing to install except the tool itself

codelens demo: offline review of the bundled example files
![]() AI review (example output, rendered with a sample model response) |
![]() codelens --help |
# Option 1: clone and link (gives you the `codelens` command)
git clone https://github.com/krishyaa06/prism-codelens.git
cd prism-codelens
npm link
# Option 2: run straight from GitHub
npx github:krishyaa06/prism-codelens demoRequires Node.js 18.17 or newer. Try it instantly with no key:
codelens democodelens review # review the current folder
codelens review src app.py --offline # specific paths, rule engine only
codelens review src --focus security # ask the AI to focus on something
codelens review src --out review.md # save a Markdown report
codelens diff # only lines changed vs HEAD
codelens diff main # only lines changed vs a branch
codelens diff --staged --fail-on critical
codelens providers # list AI providers| Command | Description |
|---|---|
review [paths...] |
Review files or folders (default: current folder) |
diff [ref] [--staged] |
Review only lines changed in git (vs HEAD, a ref or the staging area) |
demo |
Review the bundled example files (offline unless you pass --provider) |
providers |
List supported AI providers and their default models |
| Flag | Description |
|---|---|
--offline |
Use the built-in rule engine only |
--provider <name> |
gemini ยท groq ยท openrouter ยท openai ยท ollama ยท custom |
--model <id> |
Override the model |
--base-url <url> |
Custom OpenAI-compatible endpoint |
--api-key <key> |
Pass a key directly (env vars are safer) |
--focus <text> |
Extra instruction for the AI, e.g. "performance" |
--max-files <n> |
Max files to review (default 25) |
--out <file.md> |
Save a Markdown report |
--json |
Print raw JSON for scripts and CI |
--fail-on <level> |
Exit with code 1 if there are issues at critical, warning or suggestion level |
-h, --help / -v, --version |
Help and version |
| Provider | Default model | Key env var | Free tier |
|---|---|---|---|
gemini |
gemini-2.5-flash |
GEMINI_API_KEY |
โ aistudio.google.com |
groq |
llama-3.3-70b-versatile |
GROQ_API_KEY |
โ console.groq.com |
openrouter |
meta-llama/llama-3.3-70b-instruct:free |
OPENROUTER_API_KEY |
โ openrouter.ai |
openai |
gpt-4o-mini |
OPENAI_API_KEY |
|
ollama |
qwen2.5-coder |
none (runs locally) | โ |
custom |
your choice | CODELENS_API_KEY + --base-url |
You can also use the generic variables CODELENS_API_KEY, CODELENS_PROVIDER, CODELENS_MODEL and CODELENS_BASE_URL.
If only CODELENS_API_KEY is set, the provider is detected from the key format (gsk_ โ Groq, sk-or- โ OpenRouter, sk- โ OpenAI, otherwise Gemini).
If no key is found at all, CodeLens falls back to the offline engine and tells you so.
export GROQ_API_KEY=your_key
codelens review src| Rule | Severity | Catches |
|---|---|---|
hardcoded-secret |
๐ด critical | Passwords, API keys and tokens written in code |
known-token-format |
๐ด critical | OpenAI, GitHub, Google, Slack and Discord token patterns |
eval |
๐ด critical | eval() / exec() calls |
sql-concat |
๐ด critical | SQL built with string concatenation or templates |
innerhtml |
๐ warning | Unescaped innerHTML (XSS risk) |
loose-equality |
๐ warning | == / != instead of === / !== |
empty-catch |
๐ warning | Errors silently swallowed |
bare-except |
๐ warning | Python except: with no type |
http-url |
๐ warning | Insecure http:// URLs (localhost and XML namespaces are ignored) |
async-foreach |
๐ warning | async callbacks inside forEach |
var |
๐ต suggestion | var instead of let / const |
console-log |
๐ต suggestion | Leftover console.log (CLI files are skipped) |
print-debug |
๐ต suggestion | Leftover Python print() debugging |
todo |
๐ต suggestion | TODO / FIXME / HACK / XXX comments |
parseint-radix |
๐ต suggestion | parseInt without a radix |
long-line |
๐ต suggestion | Lines over 180 characters |
long-function |
๐ต suggestion | Functions longer than 60 lines |
Silence a finding on purpose with a comment:
const html = trustedTemplate; el.innerHTML = html; // codelens-ignore
// codelens-ignore-next-line
eval(sandboxedCode);Languages: JavaScript, TypeScript, Python, Java, Kotlin, Go, Rust, Ruby, PHP, C, C++, C#, Swift, Dart, Solidity, Shell, SQL, HTML, CSS/SCSS, Vue and Svelte. node_modules, build folders, hidden folders, minified files, lock files and files over 200 KB are skipped.
Each issue has a weight (critical 15, warning 6, suggestion 2) and the penalty is scaled by how many lines were reviewed, so a big project is not punished just for being big.
| Score | Grade |
|---|---|
| 90 to 100 | A+ |
| 80 to 89 | A |
| 70 to 79 | B |
| 60 to 69 | C |
| 45 to 59 | D |
| below 45 | F |
Code with any critical finding is capped (69 in offline mode, 60 when merged with an AI review), so a security hole can never get an A.
flowchart LR
A[๐ paths or git diff] --> B[๐งน Collect files<br/>skip node_modules, builds, minified]
B --> C[๐ Offline rule engine]
B --> D{API key?}
D -- yes --> E[๐ค AI review<br/>JSON response]
D -- no --> F[Offline only]
C --> G[๐งฌ Merge + de-duplicate]
E --> G
F --> G
G --> H[๐ฅ๏ธ Colored terminal report]
G --> I[๐ Markdown / JSON]
G --> J[๐ฆ Exit code]
Exit codes: 0 = ok, 1 = issues found at the --fail-on level, 2 = error (bad arguments, network, etc.).
# .github/workflows/codelens.yml
name: CodeLens
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npx github:krishyaa06/prism-codelens diff origin/${{ github.base_ref }} --fail-on critical --out codelens.md
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }} # optional, runs offline without itThis repo dogfoods itself: its own CI runs the tests on Node 20 and 22 and then runs codelens review src bin --offline --fail-on warning.
prism-codelens/
โโโ bin/codelens.js # executable entry
โโโ src/
โ โโโ cli.js # argument parsing, commands, exit codes
โ โโโ collect.js # file walker + git diff parser
โ โโโ rules.js # 17 offline rules + scoring
โ โโโ providers.js # provider presets + chat client
โ โโโ review.js # AI prompt, response parsing, merge
โ โโโ render.js # colored terminal output
โ โโโ report.js # Markdown report
โ โโโ colors.js
โ โโโ index.js # programmatic API
โโโ examples/ # intentionally buggy files for the demo
โโโ test/codelens.test.js
โโโ .github/workflows/ci.yml
The files in
examples/contain fake secrets and bad patterns on purpose. They are not real keys.
npm test # rules, scoring, ignore comments, diff parsing, providers, CLI, Markdown
npm run demo # offline review of examples/- Offline rule engine + AI review merge
- Git diff mode, Markdown and JSON output
- CI quality gate
- Post review comments directly on GitHub PRs
-
.codelensrcconfig file for rules and thresholds - Auto-fix for simple rules
- VS Code extension
- Fork the repo
- Create a branch:
git checkout -b feature/new-rule - Add your rule in
src/rules.jswith a test intest/codelens.test.js - Run
npm testand open a Pull Request
![]() Soumya Bhandare Founder @ Prism Protocol |
|
Released under the MIT License.
If you like this project, consider giving it a โญ
"Build. Create. Compete." ยท Made with โก by Prism Protocol




