Run Claude Security scans automatically every week with GitHub Actions

This article has been automatically translated.
Loading article...
Merry Christmas & Happy New Year!
Loading article...

This article has been automatically translated.
Running a security scan manually once a week sounds simple, but in practice it always gets skipped. Code merges faster and faster, and more and more of it is AI-generated, yet the problems that really require "reading the code and tracing the data flow"—missing authorization, tenant isolation gaps, injection, information leaks in error logs—are exactly what rule-based scanners like gitleaks and trivy can't catch.
Anthropic's official Claude Code plugin claude-security is built for this kind of problem: it has Claude read the code and produce security findings with severity and confidence levels. Yutong CHEN, an engineer at Exawizards, wired it into GitHub Actions to automatically scan the week's changes every Monday and send the results to Slack and GitHub issues. This article covers their approach and the part most worth copying: not how to tune the prompt, but how to scope the AI's permissions.
The authors' repository already has a set of rule-based checks: gitleaks finds secrets committed to the repo, pnpm audit and trivy find known vulnerabilities in dependencies and container images, and other scripts check whether runtime versions have reached end of support. These tools return the same result for the same input every time, so they're used as required checks that block PR merges.
AI scanning is deliberately kept on a separate track: it only reports, it doesn't block merges. The reason is straightforward—AI output can differ from run to run, and the authors haven't measured how large that variation is, so using it to decide "can this merge" isn't appropriate.
This positioning drives every design decision that follows. Since it doesn't block, the scan job doesn't need write permissions; since the results are only reports, the output must be treated as untrusted data and validated. If you start out thinking "let's make AI scanning a required status check," the whole architecture immediately becomes awkward.
The plugin is pulled from the official marketplace on every run, so its version can't be pinned, and internally it calls git and python3 through Bash. The authors therefore designed on the assumption that "the scan job may execute arbitrary code."
It's split into three jobs:
Results are passed between the two jobs via an artifact. Before doing anything, report checks the JSON structure: whether severity is within the allowed values, whether required fields are strings, whether the commit SHA is correctly formatted. The repository the issue is created in comes from report's own github.repository, not from a value in the AI output. The Slack webhook is passed only to the step that actually sends.
An analogy: the AI is like a contractor locked in a room, who can only slip envelopes out through the gap under the door; outside, someone opens them, checks the format, and files them. The limit of this analogy is that the contents of the envelope are still text an attacker can influence, so escaping and validation can't be skipped.
Scanning the whole repository every week is slow and re-reports the same things. So the script uses git rev-list -1 --before="7 days ago" HEAD to find the commit from seven days ago as the starting point, and scans only the base..head range. workflow_dispatch lets you manually change the number of days and the effort level, so you can widen the range for a first run when onboarding.
Diff scanning brings a subtle pitfall: if the scan crashes midway, the result file is likewise missing, and if that's treated as an empty result, it reports "0 findings this week," which looks like everything is fine. The authors' fix is to require both the JSONL result file and the run log to exist; if either is missing, the run is marked failed and neither the issue nor the Slack message is sent.
The report also states how much was read this week: number of changed files, number of lines, and how many researchers started and completed. It also always lists what wasn't covered—existing code unrelated to this week's changes, cloud account configuration, deployed images. Half of a security report's credibility comes from its findings, and half from whether it dares to state clearly what it looked at and what it didn't.
Two thresholds together decide whether an issue is created: severity MEDIUM or above, and confidence medium or above. Low-confidence findings go into the report but not into an issue, even if severity is high. Each run creates at most 5 new issues.
Deduplication relies on a fingerprint: take the ID the plugin gives each finding, strip whitespace, lowercase it, SHA-256 it, and take the first 16 hex characters, embedded as an HTML comment at the start of the issue body. When looking up issues with the dedicated label each week, it searches closed ones too—so findings the team decided not to fix aren't recreated the following week.
One detail worth noting here: if the AI-written body contains a comment in the same format, it could forge a fingerprint. So before embedding the body, a zero-width space is inserted into <!-- and @; the latter also prevents accidentally @-mentioning someone. Issue titles are truncated to 200 characters to avoid repeated creation failures from overly long titles.
Incomplete log redaction. The transcript artifact kept for debugging failures isn't protected by GitHub's secret masking, and values that have been JSON-escaped or base64-encoded may not be recognized. The authors manually mask the raw value, the JSON-escaped form, and the base64 form used for git Basic auth; if anything remains after replacement, the whole artifact is discarded, and artifacts are kept for only 7 days.
Concurrency causing duplicate issues. They use concurrency with cancel-in-progress: false to ensure only one run at a time; later runs queue and wait rather than canceling the one in progress.
Silent failures. GitHub's scheduled-task failure notifications go only to the last person to edit the cron, so they added a separate notify-failure job. Another more typical bug: the workflow showed success but Slack received nothing, and it was eventually found via the workflow builder's activity log that the webhook URL had been set to another workflow's. The fix was to record the HTTP status code and treat non-2xx as failure—curl --fail doesn't error on 3xx.
To be clear: at the time the article was published, the scheduled task had run only twice, and both times the AI found 0 findings. The second week read about 290 changed files and about 12,000 lines, and all 13 researchers completed. In other words, the issue-creation and deduplication path has not yet been validated in production.
The author's comparison of effort levels (low uses 1 researcher; medium uses 13 and takes about 10 minutes) was tried only once each, with no measurement of run-to-run variation. The plugin version can't be pinned, so the output format may change from week to week; the conversion step is designed to fail outright on a format mismatch rather than misreport. The Japanese translation was only checked for matching counts and fields, not for semantic drift; the original text is kept in the artifact.
There's also an easily overlooked takeaway: the first scheduled run found 0 AI findings, but the same report listed vulnerability exception approvals that were about to expire, alerting the team that one dependency update had only 8 days left.
If you're already using Claude Code, the part of this pattern worth copying first is the permission architecture: a read-only job, a separate reporting job, and treating output as untrusted input. Thresholds and effort can be tuned once findings of MEDIUM or above actually start appearing. According to the author, the deduplication logic is still untested.