Safeguard
AI Security•

How to Scan AI Generated Code: A Four Step Workflow

Scan AI generated code in four steps: secrets, static analysis, dependencies and a human check. Here is what each tool covers and how to run it.

Safeguard Security Team
5 min read

To scan AI generated code, run four checks: a secrets scan, static analysis of the source, a dependency check for known vulnerabilities and invented packages, and a human review of authentication and data access. Run the first three automatically on every commit or pull request so nothing depends on remembering.

Safeguard publishes this guide and sells a competing product, so we describe other tools only from their own documentation.

Key takeaways

  • AI code needs the same scans as human code, plus a check that every dependency really exists.
  • Secrets first, because a leaked key is the cheapest mistake to make and to catch.
  • Scanners find patterns. Reviewers find logic errors.
  • Automate it so it runs without anyone deciding to.

Which tools scan AI generated code?

These tools cover different layers. Details are from each project's own documentation.

ToolWhat it scansHow to run itNotes from its docs
GitleaksSecrets in repos, folders and stdingitleaks git or gitleaks dir, or a pre-commit hookMIT license. README says it is feature complete and receives only security patches
Semgrep CLISource code for security issuessemgrep scan for local codebasessemgrep ci needs login. The page does not state whether source is uploaded
GitHub code scanning with CodeQLRepository codeRuns on events such as push, or on a schedulePrivate repositories need a GitHub Code Security license. Runs on GitHub Actions minutes
GitHub push protectionSecrets at push timeEnabled at repo, org or enterprise levelRequires GitHub Secret Protection and is off by default for repositories
Claude Code security guidance pluginCode Claude writes, in session/plugin install security-guidance@claude-plugins-officialDocs say it is one layer and the review model can miss issues
Safeguard Gold scanDependencies from package.json, requirements.txt, CycloneDX or SPDXgold.safeguard.sh/scanFree, no login, up to 100 dependencies, parsed in your browser

Step 1: How do you scan for secrets?

Run a secrets scanner before code leaves the machine. Gitleaks detects passwords, API keys and tokens, and you can add it as a pre-commit hook with a short .pre-commit-config.yaml. GitHub push protection blocks secrets when you push, if your organization has turned it on.

Step 2: How do you run static analysis?

Run it on every pull request. Semgrep's documentation recommends semgrep scan for local codebases and semgrep ci for Git repositories with organization managed rules. GitHub's CodeQL runs code scanning on a schedule or on events like a push. Static analysis catches injection, unsafe functions and unsafe deserialization patterns that models often write.

Step 3: How do you check the dependencies?

Check each package exists, is the right one, and has no known vulnerabilities. Models sometimes invent names. A study of 16 models reported hallucinated package names averaging at least 5.2 percent for commercial models and 21.7 percent for open source ones.

The free scan at gold.safeguard.sh/scan takes a package.json, requirements.txt, or a CycloneDX or SPDX SBOM. It reports known vulnerabilities for up to 100 dependencies and the file never leaves your browser. Here is a demo of a dependency inventory.

Click through it at your own pace, or open it full screen.

For source that must stay on your machine, Safeguard also offers a CLI and local runner that keeps source local.

Step 4: What does a human need to check?

Read the code that decides who can do what. Check each route that returns user data verifies the caller, each payment path validates amounts on the server, and each delete asks for the right permission. Scanners cannot know your rules.

How to choose your scanning setup: a checklist

  • Does it run automatically, not on request?
  • Does it cover secrets, source and dependencies?
  • Is it fast enough that developers do not skip it?
  • Does it keep source on your machine, if that matters to you?
  • Does anyone own the findings list?
  • Can you export results in a standard format such as SARIF?

Frequently asked questions

Do I need special tools for AI generated code?

No. Standard scanners work on it. The extra step is checking that dependencies are real.

Can the AI scan its own code?

It can review it, and Claude Code's plugin does with a separate model call, but its documentation says to keep CI scanners too.

How often should I scan?

On every commit for secrets and on every pull request for source and dependencies.

What is the free option?

Gitleaks is MIT licensed, and the Gold dependency scan is free with no login. Semgrep and GitHub each have their own terms.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.