| name | using-openlens |
| description | Guide for using openlens to review code. Triggers on: "review my code", "check for bugs", "security scan", "run openlens", "set up code review", "openlens". |
What openlens is
openlens is an AI code review tool. It runs four agents (security, bugs, performance, style) in parallel against git diffs. Each agent reads the full codebase, not just the diff. Results include file, line, severity, confidence, and suggested fixes.
When to use which command
Someone asks you to review code:
openlens run --staged
openlens run --unstaged
openlens run --branch main
Pick based on what they have. If unsure, --staged is the default. Add --no-verify for speed (skips the false-positive filter).
Someone asks for a quick security check:
openlens run --staged --agents security --no-verify --no-context
Fast. Only runs the security agent. No full file context, no verification pass.
Someone wants to test a single agent they're building:
openlens agent test my-agent --staged --verbose
Someone wants to set up openlens in their project:
openlens setup
openlens setup --yes
Someone wants a dry run (no API calls):
openlens run --dry-run --staged
Shows which agents would run, which files changed, what settings are active. No model calls.
How to read the output
Each issue has:
- severity:
critical (must fix), warning (should fix), info (suggestion)
- confidence:
high, medium, low (how sure the agent is)
- file:line: exact location
- title: one-line summary
- message: detailed explanation
- fix: how to resolve it
- patch: suggested diff (if available)
Exit codes matter:
0 = no critical issues (or no issues at all)
1 = critical issues found
2 = runtime error (openlens itself failed)
What to do when issues are found
- Show the user the full output
- For critical issues: offer to fix them. Use the
fix field and patch field as guidance
- For warnings: mention them but don't block. Ask if the user wants to address them
- For info: note them briefly. These are style suggestions, not problems
If the output includes a patch field, you can apply that diff directly.
Output formats
openlens run --staged --format text
openlens run --staged --format json
openlens run --staged --format sarif
openlens run --staged --format markdown
Use --format json when you need to parse the results. Use --format text when showing to the user.
Setting up a new project
Full interactive setup (config, agents, hooks, plugins, CI/CD):
openlens setup
Or individual pieces:
openlens setup --config
openlens setup --agents
openlens setup --hooks
openlens setup --plugins
openlens setup --ci
Managing agents
openlens agent list
openlens agent validate
openlens agent create api-review
openlens agent test security --staged
openlens agent disable performance
openlens agent enable performance
Agents are markdown files in agents/. Edit the markdown to change what the agent looks for.
Hooks
Git hooks block commits/pushes with critical issues:
openlens hooks install
openlens hooks remove
Skip when needed:
OPENLENS_SKIP=1 git commit -m "wip"
OPENLENS_AGENTS=security git commit -m "fix"
Checking the environment
openlens doctor
Run this first if something isn't working.
Common patterns
Pre-commit review (fast):
openlens run --staged --agents security,bugs --no-verify
Full branch review before PR:
openlens run --branch main
CI pipeline:
openlens run --branch $BASE_BRANCH --format sarif > results.sarif
Check if setup is correct:
openlens doctor && openlens agent validate