Your agent has finished making a change. The tests pass, and the code looks plausible, but you don't have the time to closely review every line. How do you know what you're shipping is secure?
AI agents are accelerating software development, but they can also unintentionally introduce vulnerable code, expose secrets, or suggest nonexistent dependencies. As AI-generated code scales across repositories and languages, security becomes increasingly critical. From January to October 2026, GitHub detected over 200 million vulnerabilities, based on internal data. This represents a 100% increase year over year, underscoring the growing need to secure code at scale.
Keeping your application secure means checking code as you build, reviewing changes before they merge, and looking for risks across the wider project. That's why GitHub combines built-in security checks with different kinds of analysis and gives you ways to investigate findings and apply fixes where you're already coding.
Let's follow a change from the agent session to the pull request and the wider codebase. Along the way, you'll see how to build security into your own development workflow on GitHub. These aren't one-time checks or growing backlogs of findings. Instead, it's an ongoing process of finding vulnerabilities followed by evaluating and applying suggested fixes, without switching between disconnected tools.
The agent says it's done. What did it miss?
Just because an agent says it's finished the work doesn't mean it's safe. Your change can pass every test and still carry a security risk.
Consider an example where your agent updates a PHP search endpoint and builds the database query by inserting the search text directly into the SQL. Ordinary searches still work, so you'd only catch the problem by reading the code closely and asking why the agent built the query that way. But that search text could change the SQL itself and give attackers a way to access your data.
Reading every line to find a problem like this is slow, and these kinds of errors are easy to miss. A local security review can do that first pass for you. Before you open a pull request, run /security-review in the Copilot app, Copilot CLI, or Copilot Chat in VS Code on your active changes.
The review returns prioritized findings and remediation suggestions. It's focused on your local changes, not a full repository audit, and the review itself doesn't edit your code. You can ask Copilot to explain a finding or try a fix in your working copy.
For your PHP endpoint, the review could flag SQL injection. As a fix, it might suggest a parameterized query, which keeps the SQL instructions separate from the user's search value. You can then apply the fix and test that ordinary searches still work and crafted input can no longer alter the query.
Your pull request is open. What could still slip through?
While a local review is valuable, the pull request is the next checkpoint, and it has its own weak spot: reviewers can suggest and commit changes of their own, and any one of them could introduce a new risk. Your team still needs a check that runs on every pull request before code gets merged.
CodeQL is the foundation of GitHub Code Security's pull request checks. Complementary AI-powered scanning builds on that base, extending coverage to additional languages and vulnerability patterns.
These two kinds of analysis work in different ways:
- CodeQL builds a database representing the code, then runs queries over that representation to identify potential problems. Its default query suite is designed for high precision and few false positives.
- AI Scanning uses agents to explore the repository and reason about how the code works. Rather than relying only on predefined queries, it can investigate unfamiliar attack patterns and vulnerabilities in business logic, including in additional languages outside CodeQL's coverage.
In our example, PHP is one of those additional languages outside of CodeQL's coverage. AI Scanning checks the endpoint on the pull request and any findings come with suggested fixes for you or your reviewers to evaluate.
What about the code you didn't touch?
Pull request checks examine code that's new or changing, but they don't scan what's already there. Older code can go unchecked for months or years, and even code that appeared to be safe when it shipped may not hold up as attackers find new techniques.
In our example, an older part of the application builds database queries too, and nobody has changed it in months. It may carry the same kind of risk as the endpoint you just fixed, and no pull request will ever bring it up for review.
To look at code like that, if you have write access to a repository, you can run Standard AI Scan on its default branch.
The scan uses a proprietary harness with multiple models when available. Rather than reading every file in full, its agent searches the project and selects files and functions to examine within a time budget. It can examine languages CodeQL supports as well as those outside its coverage.
When the scan finishes, findings from the repository AI Scan appear alongside CodeQL alerts in the code scanning backlog. When CodeQL alerts already cover the same issue, AI Scan suppresses the duplicate findings.
From there, you can assign these alerts, link issues, include them in security campaigns, and use supported autofix workflows.
If you're working in the Copilot app, the GitHub security extension brings all code scanning alerts into a security canvas. You can find alerts, ask Copilot to explain them, and work on fixes without leaving the app. The same canvas supports the local security review we used earlier, so you can check new changes and act on existing alerts in one place.

Your critical project warrants another look
For most work, the checks you've seen so far are enough. But regular scanning is built to work within practical limits, such as time and scope. In some situations, such as a major release or an audit, you can't afford to leave any stone unturned.
Suppose the example application is approaching a critical release. You've checked the endpoint and scanned the wider codebase, but the stakes of this release call for the most thorough investigation possible before shipping.
Deep Scan, which is powered by Microsoft's Codename MDASH and currently in private preview, is intended for higher-attention situations such as release testing and audits. Like Standard AI Scan, you run it on a repository with a click.
CodeQL, Standard AI Scan, and Deep Scan alerts all share the same backlog and come with fix suggestions. Agentic autofix works across all three, as well as partner tools, helping you turn findings into fixes within a shared workflow.
Build with security in the loop
Whether you're writing code yourself or working with an agent, these security checks help you evaluate what you're building from your first local change through to the codebase you maintain. You can use focused, local reviews while you build, complementary CodeQL and AI-powered analysis on pull requests, and broader, hybrid scans to look beyond what's recently changed, all within the same GitHub workflow.
No single green check certifies the whole codebase, but together, these approaches give you more chances to find issues and provide a clearer path from a finding to a fix you have reviewed.
| Feature | When to use it |
|---|---|
Local security review (/security-review) | Review your active changes for vulnerabilities before opening a pull request. |
| CodeQL and AI Scanning | Check pull requests for vulnerabilities in new or changed code before merging. |
| Standard AI Scan | Scan your repository's default branch for risks in code that hasn't changed recently. |
| Deep Scan | Run a more thorough scan for higher-attention situations, such as release testing or an audit. |
Put security into your next change
Next time you work with an agent, run /security-review in the Copilot app, Copilot CLI, or Copilot Chat in VS Code to check your changes for vulnerabilities before opening a pull request.
The post How do you build securely when AI is writing more of the code? appeared first on The GitHub Blog.
💬 Community discussion & comments
Start the discussion in the Social Chat broadcast stream or submit an expert contribution via the supplement form above.