MegaLinter for coding agents
Coding agents write code faster than anyone can review it. Linters are the checks they can not argue with: the same rules every time, on every file. MegaLinter brings 135 of them to your agent, in a few seconds, with a fix guide for each one.
Why linters matter more with agents
- Volume: an agent changes dozens of files in one task, and the time to review them does not grow with it
- Plausible mistakes: generated code looks right and passes its tests, and can still carry a secret, a vulnerable version or an insecure default
- A feedback loop: an agent improves its code when it gets precise findings (file, line, rule, message), which is exactly what a linter gives
- No shortcuts: an agent pushed to get a green build may silence a rule. The MegaLinter skills ask you first
Recommended setup
| Step | What it does |
|---|---|
| 1. The plugin | Your agent gets the MegaLinter skills: set up, check, fix in a loop (Coding agents) |
| 2. Native linters | The fast linters run on your machine, without Docker, after each change (native mode, beta) |
| 3. CI | Every linter runs again on each pull request, in the MegaLinter Docker image, including the slow ones and the security scanners |
With Claude Code:
claude plugin marketplace add oxsecurity/megalinter
claude plugin install megalinter@megalinter
Then ask your agent to "setup megalinter": it asks whether you want MegaLinter in your CI, on your machine without Docker, or both, sets it up and runs it. Without the agent, the same setup is:
npx mega-linter-runner --install
npx mega-linter-runner@beta --native-setup
The plugin also exists for Cursor, GitHub Copilot, Codex, Gemini CLI and Antigravity: see Coding Agents (Plugins). Other agents can copy the skills in the repository.
The agent loop
flowchart LR
W["Your agent writes code"] --> C["MegaLinter checks<br/>native mode, seconds"]
C --> F["Findings<br/>file, line, rule, message"]
F --> X["The agent fixes<br/>fix guide of each linter"]
X -->|"until clean"| C
C -->|"clean"| PR["Pull request<br/>CI runs every linter"]
- Fast: native mode installs only the linters you list in
NATIVE_LINTERS, and runs them in parallel. On the demo repository, 7 linters run in 8 seconds - Readable by agents:
--jsonwritesmegalinter-reports/mega-linter-report.json, with each finding and the status of each linter (details). Sub-agents read the long logs, so they stay out of your agent's context - Guided: the
megalinter-fixskill loads the fix guide of each failing linter (how to auto-fix, the rules documentation, how to disable a rule when it is not relevant), and fixes the linters in parallel - Checked again: a green native run is not a green CI. The linters left out of
NATIVE_LINTERSstill run in CI, on every pull request
Linters to enable for code written by agents
These linters catch what agents slip in. They are active by default, unless your ENABLE or ENABLE_LINTERS lists leave them out. Most of them scan the whole repository, so they are usually left to CI, where they check every pull request.
| Risk | Linters | Where |
|---|---|---|
| Secrets | betterleaks, secretlint, trufflehog | CI |
| Vulnerable dependencies | trivy, osv-scanner, grype | CI |
| Insecure infrastructure | checkov, trivy, hadolint | CI, hadolint also native |
| Insecure code patterns | semgrep, bandit, devskim | CI, bandit also native |
| Copy-pasted code | jscpd | CI |
All of them can also run without Docker: add one to NATIVE_LINTERS when you want your agent to run it on each change. npx mega-linter-runner@beta --native --prerun proposes the linters that are fast enough.
Tell your agent to use it
The plugin teaches your agent how to run MegaLinter. To make it a rule of your repository, for any agent, add this to your AGENTS.md (or CLAUDE.md, .github/copilot-instructions.md):
## Linting
- Before saying a change is done, run MegaLinter (`npx mega-linter-runner@beta --native --json`) and fix every error it reports
- Never add inline suppressions (`# noqa`, `eslint-disable`...) and never disable a linter or a rule without asking me
Safety rules
- Safe fixes are applied automatically; ambiguous ones are asked to you
- Disabling a linter or a rule always requires your confirmation
- Commits are never pushed to the default branch
- Native mode runs the linters on your machine: on code you do not fully trust, use Docker (security model)