Guide
Is your AI-generated code safe to ship?
Treat generated code like a pull request from a stranger: read it, then scan it. openaudit scans your repository and your deployed site for the mistakes worth catching in AI-written code, from leaked keys to hidden Unicode.
What goes wrong in AI-written code
The bugs aren't new. They're the classic ones, accepted in bulk:
- An API key pasted into a config file or a committed
.env. Deleting it later doesn't remove it from git history. - SQL or shell commands built from strings, and user input rendered as raw HTML.
- Permissive CORS, or TLS and JWT verification switched off to make an error go away.
- A dependency with known vulnerabilities, or a package name the assistant made up that someone else has since registered.
- A deployed app with no Content-Security-Policy or HSTS header.
- Invisible characters copied in from a prompt, a pasted snippet or an agent rules file.
What openaudit checks
- Secrets.
code.secretsfinds committed credentials and tracked.envfiles. The opt-incode.secrets-historyruns gitleaks over the full git history for secrets that were committed and later removed. - Injection and XSS.
code.securitylooks for injection, XSS, weak crypto, disabled TLS or JWT checks, permissive CORS, open redirects and path traversal in JS/TS, Python, Go, PHP, Ruby, Java and C#.code.semgrepadds Semgrep when it's installed. - Dependencies.
code.dependencieschecks every pinned version against OSV.dev.code.lockfilesflags lockfiles out of date withpackage.json, missing integrity hashes, unexpected registries and install scripts. The opt-incode.dependency-healthflags deprecated, yanked and archived packages. The opt-incode.guarddogchecks npm and PyPI packages for malware and typosquatting. - Headers.
web.headerschecks CSP, HSTS, framing, CORS and cookie flags on your live URL. - Hidden Unicode.
code.unicodefinds Trojan Source bidi controls, zero-width characters, hidden text in Unicode tag characters and look-alike identifiers. - Agent setup.
code.agent-configfinds hidden instructions in AGENTS.md and Cursor or Copilot rules, unpinned MCP servers and over-broad agent permissions.
Audit, fix, verify
Audit the code and the deployed site, and check git history once:
bunx @openaudit/cli . -f html -o report
bunx @openaudit/cli https://your-app.example
bunx @openaudit/cli . --only code.secrets-historySave a JSON report, fix the findings, then rerun against it. Exit code 0 means the fix added no new findings:
bunx @openaudit/cli . --json > before.json
bunx @openaudit/cli . --baseline before.json --fail-on lowOn pull requests, report only the changed files and fail the build on serious findings:
bunx @openaudit/cli . --diff origin/main --fail-on highYour coding agent can also check its own work. Add the MCP server and it gets run_audit, get_finding and compare_reports, plus playbooks such as agent.injection and agent.authz that it runs with its own tools. No extra API key is needed.
claude mcp add openaudit -- bunx @openaudit/cli mcpWhat it doesn't cover
- Rules match patterns. They can't tell whether your business logic is right or every route checks who's calling. The
agent.authzplaybook has an agent review that, but read its result yourself. - openaudit can't tell whether a package is the one you meant. Check unfamiliar names yourself.
- It never builds, installs or runs your code, so it doesn't replace your tests.
- Scanners that aren't installed are skipped and listed in the report. Run
bunx @openaudit/cli doctorto see what's missing.
Next steps
Start with the CLI reference, add the gate to your pipeline with the CI guide, and set up your coding agent with the agents guide. Or open openaudit's report on itself to see a finished one.