OmniscioGuidesClaude Code security guidance
Claude Code security guidance
Security review usually happens after the pull request exists. The security-guidance plugin moves part of that review into the session, where the code is still being written.
This page covers what the plugin checks and when, the two files that extend it, what it costs, how to switch a layer off, and where it sits beside the other security tools rather than replacing them.
Sources read on November 22, 2026. By the Omniscio team. Updated .
What the plugin is
The security guidance plugin makes Claude review its own code changes for common vulnerabilities while it works, and fix what it finds in the same session. It catches issues such as injection, unsafe deserialization and unsafe DOM APIs before the code reaches a pull request, reducing how much security review is left to human reviewers downstream.
Once installed it runs automatically: there is nothing to invoke and no separate command to remember. It is the in-session companion to Code Review, which runs on pull requests — this plugin reduces what reaches the PR, and Code Review catches what does.
Our own code review guide covers the pull-request side of that split.
Before you install
It needs Python 3.7 or later on your PATH, and a git repository for the directory you work in — the end-of-turn and commit reviews diff against git state and skip silently outside a repository, while the per-edit pattern check works anywhere. The agentic commit review needs Python 3.10 or later, as do all model-backed reviews when Claude Code uses a third-party provider such as Amazon Bedrock or Google Cloud's Agent Platform.
On first run the plugin creates a virtual environment under ~/.claude/security/ and installs the Claude Agent SDK into it, which needs pip and network access. If that install fails, or the Python available is older than 3.10, the commit review on first-party authentication falls back to a single-shot review; on a third-party provider the model-backed reviews skip entirely and only the per-edit pattern check runs.
Install it
From a terminal Claude Code session, install from Anthropic's official marketplace:
/plugin install security-guidance@claude-plugins-officialThe install prompts for a scope; choose user scope so the plugin loads in every new local session on that machine. Where /plugin is not available, install from that surface's own interface: the Desktop app tab under Install a plugin in the desktop app, the Manage plugins dialog in VS Code, or your organization's managed-settings rollout in a cloud session.
To turn it on for a whole repository, add "security-guidance@claude-plugins-official": true under enabledPlugins in the project's checked-in .claude/settings.json. Each teammate then runs the install once per clone with --scope project. Administrators can enable it organization-wide by setting enabledPlugins in managed settings.
The three checks, at three depths
On each file edit: a pattern match
When Claude writes to a file, the plugin scans the new content for known risky patterns. It is a string match with no model call, so it adds no usage cost. The built-in categories include dynamic code execution (eval(, new Function, os.system, child_process.exec), unsafe deserialization (pickle), DOM injection (dangerouslySetInnerHTML, .innerHTML =, document.write), and edits under .github/workflows/, which can grant repository-level permissions.
The check runs after the edit lands and appends the warning to Claude's context for the next step. Each warning fires once per pattern per file per session, so repeat matches in one file do not flood the conversation.
At the end of each turn: a background review
After each turn, the plugin computes a git diff of everything that changed in the working tree during it — including changes from Claude's edit tools, Bash commands and subagents — and sends it to a separate Claude review focused on security. The review runs in the background, so Claude's reply is not delayed; if it finds issues, Claude is re-prompted with the findings and addresses them as a follow-up.
This layer catches what a string match cannot: authorization bypass, insecure direct object references, injection, server-side request forgery and weak cryptography. It covers up to 30 changed files per turn and fires at most three times in a row before it yields back to you.
On each commit or push: an agentic review
When Claude runs git commit or git push through its Bash tool, a deeper agentic review runs in the background. It reads surrounding code — callers, sanitizers and related files — to decide whether a finding is real before reporting it, which is what keeps false positives low on patterns that look dangerous in isolation but are safe in your codebase.
This layer fires only on commits and pushes Claude makes through its Bash tool; commits you run from your own shell, including the ! shell escape inside a session, are not reviewed. Commit and push reviews are capped at 20 per rolling hour, and a finding the end-of-turn review already reported is not re-raised, so a clean commit produces no visible output from this layer.
Who is doing the reviewing
The plugin does not ask the same Claude instance that wrote the code to grade itself. The per-edit check involves no model at all, and the end-of-turn and commit reviews run as a separate Claude call with fresh context and a security-focused prompt: the reviewer starts from the diff with no investment in the original approach. None of the layers block a write or a commit; findings reach the writing Claude as instructions, and the review model can miss issues.
Teach it your threat model
There are two extension points, and both are additive: a Markdown guidance file for the model-backed reviews, and a YAML or JSON patterns file for the per-edit match. You can add checks, but neither file can disable a built-in one.
.claude/claude-security-guidance.md takes your threat model and review checklist in plain language, which the model-backed reviews load alongside their built-in checklist. Anthropic's example for a web service:
- Do not log `customer_id` or `account_number` at INFO level or above.
- All routes under `/admin` must call `require_role("admin")` before any database read.
- Use `crypto.timingSafeEqual` for token comparison instead of `===`.These rules guide the reviewer; they are not guardrails. The plugin surfaces violations as findings for Claude to fix, and a rule that says to ignore a vulnerability class does not suppress those findings. For hard enforcement, pair the plugin with a hook that blocks the edit, or with a CI check.
.claude/security-patterns.yaml adds regex or substring rules to the per-edit check, each with a rule_name, a reminder of up to 1 KB, and either regex or substrings, with optional paths and exclude_paths globs. The plugin also reads .claude/security-patterns.yml and .claude/security-patterns.json; the YAML forms need PyYAML importable in the Python the plugin runs, which it does not install for you, so the JSON form is the one that needs nothing extra. Anthropic's example:
patterns:
- rule_name: internal_api_key
substrings: ["sk_live_", "AKIA"]
reminder: "Hardcoded API key prefix. Load credentials from the secret manager."
- rule_name: tenant_unfiltered_query
regex: "\\.objects\\.all\\(\\)"
paths: ["**/src/tenants/**"]
reminder: "Multi-tenant code must filter by org_id."It loads up to 50 custom rules and skips regexes that look prone to catastrophic backtracking.The plugin looks for both files in the same three places and loads every one that exists, concatenated: your user folder at ~/.claude/, the project's .claude/, and a personal override, .claude/claude-security-guidance.local.md, which belongs in your .gitignore. The combined guidance is capped at 8 KB.
What it costs, and how to switch a layer off
The per-edit pattern check is free. The end-of-turn and commit reviews each spend model usage that counts toward your usage like any other Claude request; the commit review is agentic and can take several model turns per commit. Expect roughly one review call per turn that changes files and one deeper review per commit, both within the caps above. Both reviews run on a Claude Opus model by default; SECURITY_REVIEW_MODEL changes the end-of-turn model and SG_AGENTIC_MODEL the commit one. The plugin is available on all plans.
| Variable | Effect |
|---|---|
ENABLE_PATTERN_RULES=0 | Disables the per-edit pattern check |
ENABLE_STOP_REVIEW=0 | Disables the end-of-turn diff review |
ENABLE_COMMIT_REVIEW=0 | Disables the commit and push review |
ENABLE_CODE_SECURITY_REVIEW=0 | Disables every model-backed review at once |
SECURITY_GUIDANCE_DISABLE=1 | Disables the plugin entirely without uninstalling it |
To pause the plugin in your user scope, run /plugin disable security-guidance@claude-plugins-official; to remove it, /plugin uninstall security-guidance@claude-plugins-official. If a project's .claude/settings.json enabled it, the uninstall writes an override to your own .claude/settings.local.json instead of editing the checked-in file, so teammates are unaffected. When managed settings enabled it, /plugin refuses both disable and uninstall.
Where it sits beside the other tools
Anthropic describes the plugin as one layer of a defense-in-depth stack, catching issues earliest but guaranteeing nothing. The stages around it:
| Stage | Tool | What it covers |
|---|---|---|
| In session | Security guidance plugin | Common vulnerabilities in code Claude writes, fixed in the same session |
| On demand, single pass | /security-review | A one-time pass on the current branch |
| On demand, deep scan | Claude Security plugin | A multi-agent scan of a repository or diff, with reviewed findings and patches |
| On pull request | Code Review | Multi-agent correctness and security review with full codebase context, on Team and Enterprise plans |
| In CI | Your own static analysis and dependency scanners | Language rules, supply-chain checks and policy the plugin does not attempt |
To find issues in code you already have rather than in changes Claude is writing, ask Claude in a session to review a specific file or directory, or install the Claude Security plugin for a deeper multi-agent scan of the whole repository. /security-review covers only the changes on your current branch. Either way, the review reads source code in your checkout, not a running site.
The security scan guide covers that deeper, on-demand scan step by step.
When no review appears
The plugin writes runtime diagnostics to ~/.claude/security/log.txt; check there first. The common reasons a layer skips: the directory is not a git repository, so the end-of-turn and commit reviews skip silently; the session has no Anthropic authentication and no third-party provider configured, so only the pattern check runs; or a security-patterns.yaml file is present while PyYAML cannot be imported, in which case that file is ignored and security-patterns.json is the fix.
Where these answers come from
- Everything on this page about the plugin, its prerequisites, its three layers and their caps, the two rule files, usage cost, the switch-off variables and troubleshooting: Catch security issues as Claude writes code, read November 22, 2026.
- The comparison table is that page's own "How this fits with other security tools" table, with its rows kept in its order.
No review was run to write this page: every check, cap and variable is Anthropic's own wording from the page named above.
Common questions
What does the security-guidance plugin do?
It makes Claude review its own code changes for common vulnerabilities while it works, and fix what it finds in the same session. Once installed it runs automatically: there is nothing to invoke and no command to remember.
How many checks does it run, and when?
Three. A fast pattern match runs on each file edit with no model call. A background model review runs at the end of each turn over everything that turn changed. A deeper agentic review runs when Claude commits or pushes through its Bash tool.
Does it cost anything?
The per-edit pattern check makes no model call and adds no cost. The end-of-turn and commit reviews each spend model usage that counts toward your usage like any other Claude request. The plugin is available on all plans.
Does it replace a security scan of the whole repository?
No. It reviews the changes Claude is making. To scan code you already have, use the Claude Security plugin for a deeper multi-agent scan, or /security-review for the changes on your current branch. The plugin is one layer of defense in depth, not a complete security solution.