npx skills add ...
npx skills add bitwarden/ai-plugins --skill perform-security-review
npx skills add bitwarden/ai-plugins --skill perform-security-review
Performs a security-focused code review by launching multiple specialized agents and a verification agent to ensure comprehensive coverage and accurate findings. Use this skill when the user asks for a "perform-security-review", "bitwarden-security-review", "execute a security review", "run a comprehensive security audit", "perform an end-to-end security assessment", or needs to coordinate multiple security checks across code, dependencies, secrets, and configurations. The skill manages the workflow, delegates tasks to specialized agents, and presents final findings to the user.
--output-dir <path>: When using --output file, write the report to <path>/security-review-YYYY-MM-DD-{identifier}.md instead of the current working directory. Tip: use --output-dir ~/.claude/security-reviews/ to keep reports outside git repos.
Determine review mode from the invocation:
gh pr view <number> for context, gh pr diff <number> for the diff.git diff <sha>..HEAD — reviews all changes after that commit.git log --since="<duration>" --reverse --format=%H | head -1, then git diff <sha>^..HEAD to include it.git diff HEAD for staged + unstaged changes.git diff main...HEAD — changes since the branch diverged from main.Model selection: If --model is specified, use that model for all agents. Otherwise, default to opus.
Execute these steps in order. Do not skip, reorder, or combine steps.
Gather context. Run all of these before launching any agents.
** A.) Resolve repo identity.** Run as two separate Bash calls — do NOT chain with &&, ||, ;, or pipes:
git remote get-url origin — parse owner and repo from the output. Handle both HTTPS (https://github.com/owner/repo.git) and SSH (git@github.com:owner/repo.git) formats.git branch --show-current — capture the current branch name.B.) Fetch and save the diff. Using the review mode determined above, run exactly one of these commands as a single Bash call — no &&, ;, or pipes. Shell redirection (>) is required and allowed:
gh pr diff <number> > /tmp/security-review-<identifier>.diffgit diff <sha>..HEAD > /tmp/security-review-<identifier>.diffgit diff <oldest-sha>^..HEAD > /tmp/security-review-<identifier>.diffgit diff HEAD > /tmp/security-review-<identifier>.diffgit diff main...HEAD > /tmp/security-review-<identifier>.diffChoose a descriptive <identifier> (e.g., PR123, 5days, local). Store the full path as DIFF_FILE and include it in every agent prompt in steps 2 and 4 so they can Read the diff directly.
C.) Fetch scan evidence. All calls are best-effort — silently skip any that fail (403, 404, empty response, GHAS not enabled). Use gh api --jq for all formatting — DO NOT pipe to jq. All calls MUST use --method GET and -H "X-GitHub-Api-Version: 2026-03-10".
gh api --method GET -H "X-GitHub-Api-Version: 2026-03-10" "repos/{owner}/{repo}/code-scanning/alerts?pr={number}&state=open&per_page=100" --jq '.[] | "\(.rule.security_severity_level | ascii_upcase) | \(.most_recent_instance.message.text) | \(.most_recent_instance.location.path)\n \(.rule.full_description | .[0:150])\n"'gh api --method GET -H "X-GitHub-Api-Version: 2026-03-10" "repos/{owner}/{repo}/code-scanning/alerts?ref=refs/heads/{branch}&state=open&per_page=100" --jq '.[] | "\(.rule.security_severity_level | ascii_upcase) | \(.most_recent_instance.message.text) | \(.most_recent_instance.location.path)\n \(.rule.full_description | .[0:150])\n"'gh api --method GET -H "X-GitHub-Api-Version: 2026-03-10" "repos/{owner}/{repo}/secret-scanning/alerts?state=open" --jq '.[] | "\(.secret_type_display_name) | \(.state) | \(.resolution // "open")"'gh api --method GET -H "X-GitHub-Api-Version: 2026-03-10" "repos/{owner}/{repo}/dependabot/alerts?state=open&per_page=100" --jq '.[] | "\(.security_advisory.severity | ascii_upcase) | \(.dependency.package.name) | \(.security_advisory.cve_id // .security_advisory.ghsa_id) | \(.security_advisory.summary)"'Collect results into a SCAN_EVIDENCE block for use in steps 2 and 4:
Launch these four (4) subagent_type: "bitwarden-security-engineer:bitwarden-security-engineer" agents in parallel. Each agent has a specific domain — you MUST instruct it to stay within that domain. The agent MUST read references/security-review-rubric.md before starting AND before evaluating findings.
Agent 1 — Code Security: Focus exclusively on injection flaws (SQL, XSS, command), cryptographic weaknesses, insecure coding patterns, and OWASP A01–A05. Invoke Skill(bitwarden-security-context) and Skill(analyzing-code-security) to guide your analysis. Do not evaluate secrets, dependencies, architecture, or threat modeling.
Agent 2 — Secrets & Dependencies: Focus exclusively on hardcoded credentials, exposed secrets, vulnerable packages, and supply chain risk. Invoke Skill(bitwarden-security-context), Skill(detecting-secrets), and Skill(reviewing-dependencies) to guide your analysis. Do not evaluate code patterns, architecture, or threat modeling.
Agent 3 — Security Architecture: Focus exclusively on authentication, authorization, encryption implementation, trust boundaries, and Bitwarden's zero-knowledge invariant (encryption and decryption happen client-side only — the server must never have access to plaintext vault data). Invoke Skill(reviewing-security-architecture) and Skill(bitwarden-security-context) to guide your analysis. Do not evaluate injection flaws, secrets, or threat modeling.
Agent 4 — Threat Perspective: Focus exclusively on attacker-oriented analysis — trace user input through data flows to dangerous sinks, business logic flaws, privilege escalation paths, data exposure, and API abuse patterns. Invoke Skill(bitwarden-security-context), Skill(analyzing-code-security), and Skill(threat-modeling) to guide your analysis. Do not evaluate architecture patterns, secrets, or dependency versions.
For all four agents:
{DIFF_FILE} — read it using the Read tool. DO NOT execute gh pr diff, git diff, or any other diff commands. NEVER use WebFetch, WebSearch, or any gh api endpoints — scan evidence has been pre-fetched and is provided below."SCAN_EVIDENCE block gathered in step 1.After all four agents return, rate each finding using the two-axis model defined in references/security-review-rubric.md:
Launch a verification agent subagent_type: "bitwarden-security-engineer:bitwarden-security-engineer" with all combined findings, their severity/confidence ratings, the triage matrix, the DIFF_FILE path, and the full SCAN_EVIDENCE block from step 1.
{DIFF_FILE} — read it using the Read tool. Do NOT run gh pr diff, git diff, or any other diff commands. NEVER use WebFetch, WebSearch, or any gh api endpoints — scan evidence has been pre-fetched and is provided above."Format the summary report.
First, set the report header based on review mode:
PR: (#{number}) - {PR title} — {YYYY-MM-DD}Code Review: {short SHA}..HEAD — {YYYY-MM-DD}Code Review: Changes since {duration} — {YYYY-MM-DD}Code Review: Local Changes — {YYYY-MM-DD}Code Review: {branch} vs main — {YYYY-MM-DD}Then format the report:
Omit any section with zero findings entirely — do not render an empty heading. For <details> sections, omit them entirely if the count is zero.
Check the --output argument to determine the output destination. If --output is omitted, check for the $GITHUB_ACTIONS environment variable — if set, default to github; otherwise default to chat.
chatDefault when --output is omitted and not running in CI.
file--output-dir <path> is specified, write to <path>/security-review-YYYY-MM-DD-{identifier}.md. Otherwise write to the current working directory.{identifier} is the PR number (e.g., PR123), commit SHA (short), or local.gh pr comment, gh api, or any MCP posting tool.githubDefault when --output is omitted and $GITHUB_ACTIONS is set.
/tmp/review-summary.md using the Write tool.\n\n<!-- bitwarden-security-code-review --> at the end of the file content.gh pr comment, gh api, or any MCP posting tool./tmp/review-summary.md for workflow pickup."The workflow post-step will read this file and update the placeholder comment automatically.
Delete the temporary diff file. Run rm -f {DIFF_FILE} to securely remove the diff written in step 1B. This step is unconditional — run it in every output mode, whether or not findings were reported. Use the -f flag to suppress errors silently if the file no longer exists. Do not report this step to the user.