code-review

A command for reviewing code changes linked to a branch, pull request, or Jira ticket. A pull request is a proposed code change for review; Jira is a tool for tracking development work.

In plain words
What is it for?
Use it with a Jira ticket, branch name, or pull request number—or with no argument to review the current branch—and run static analysis, PHPCS, PHPStan, and Drupal checks.
Why use it?
It gathers the right changed files and checks them for bugs, security issues, coding-standard violations, and Drupal best practices before or during review.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/edutrul/drupal-ai/code-review
Clone the repo
git clone --depth 1 https://github.com/edutrul/drupal-ai

Made for: Claude Code.

Per session 63 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,208 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00063 $0.01208
Opus 5 $0.00032 $0.00604
Sonnet 5 $0.00013 $0.00242
Haiku 4.5 $0.00006 $0.00121

Measured 2d ago against content hash f0e3e2c0c272, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-review scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/code-review.md · 211 lines

How it starts

The opening of the file, as written. The whole thing — 211 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Code Review

Run a full code review against changed files — static analysis, PHPCS, PHPStan, and best-practice checks.

Purpose

Use this command to review work before a PR or during a PR — whether you have a Jira ticket, a branch name, a PR number, or nothing at all.


Input

Optional. One of:

  • Jira ticket ID — e.g. TICKET-123
  • Branch name — e.g. my-feature-branch
  • PR number — e.g. 612 or #612
  • Nothing → defaults to current branch

Step 1 — Resolve input to a branch

No input

git branch --show-current

Use the result as the branch.

Jira ticket (e.g. TICKET-123)

gh pr list --search "TICKET-123" --json number,headRefName,title

If a PR is found → use its branch. If no PR → search local/remote branches for the ticket ID:

git branch -a | grep -i TICKET-123

Use the first match. If nothing found → tell the user and stop.

PR number (e.g. 612)

gh pr view 612 --json headRefName,title,files

Use the headRefName as the branch.

Branch name

Use it directly. Verify it exists:

git fetch origin
git log origin/<branch> -1

If not found → tell the user and stop.


Step 2 — Get changed files

Get the diff between the resolved branch and the base branch (as defined in workflow.md — typically develop or main):

git fetch origin
git diff origin/<base-branch>...origin/<branch> --name-only

If on current branch (no remote yet):

git diff origin/<base-branch>...HEAD --name-only

Show the list of changed files to the user.

If no changed files → tell the user and stop.


Step 3 — Run PHPCS on changed PHP files

Filter changed files to those in PHPCS scope:

  • docroot/modules/custom/
  • docroot/themes/custom/
  • docroot/sites/default/settings.php

For each matching file, run:

phpcs <file-path>

Collect all output. Store raw results — use them as-is in the report.

If no in-scope PHP files → note "PHPCS: no in-scope files" and skip.

Read the full file on GitHub · 211 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 211 lines · 63 tokens per session scan A f0e3e2c0c272

Subscribe to this mod's changes

code-review is a command published in the GitHub repository edutrul/drupal-ai (71 stars, last pushed 2mo ago), licensed MIT. It adds 63 tokens to every session and 1,208 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.