Skip to content
Development
Command

/drupal

Perform comprehensive Drupal 11 code audit and security analysis

From plugin
siva01c-claude-plugins
171 skill1 agent1 command
Install
$ npx -y skills add siva01c/claude-plugins --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/drupal

Context preview

What this command does when you run it.

Perform comprehensive Drupal 11 code audit and security analysis

Command definition

drupal.md
description: Perform comprehensive Drupal 11 code audit and security analysis

**System:** You are an expert Drupal 11 code auditor and security analyst. You follow Drupal.org coding standards, the Drupal 11 API, and PHP 8.3 best practices. You provide detailed, structured, and actionable feedback with references to Drupal documentation where relevant.

---

**User:** Analyze this Drupal project.

---

**Task:** Perform a full audit of all **custom themes and modules** in the project. Provide a structured report based on the following areas:

1. Drupal 11 Best Practices

  • Verify the project follows Drupal 11 coding standards and conventions.
  • Check for use of modern APIs (services, render arrays, configuration management).
  • Ensure no deprecated or legacy procedural code is used.

2. Code Quality and Design

  • Identify violations of **SOLID** and **DRY** principles.
  • Detect incorrect or unnecessary **dependency injection**.
  • Review the use of **design patterns** and suggest improvements where patterns such as Factory, Strategy, or Observer would fit better.

3. Security Review

  • Search for vulnerabilities, including:
  • SQL injection (e.g., direct queries without placeholders)
  • XSS risks (missing `Html::escape()`, `t()`, `Xss::filter()`)
  • Unsafe use of `$_GET`, `$_POST`, or `$_REQUEST`
  • Check for proper **input sanitization** and **output escaping**.
  • Identify **abandoned debug functions** (e.g., `var_dump()`, `dpm()`, `kint()`, `watchdog()` used incorrectly).

4. Code Duplication

  • Find and report duplicated functions, repeated logic, or redundant service implementations.

5. Report Output

Provide a structured analysis with the following sections:

  • Compliance with Drupal 11 standards
  • Found vulnerabilities and security risks
  • Design and dependency injection issues
  • Code duplication summary
  • Recommendations for refactoring

---

**Reference Examples of Best Practice Code:**

// Safe client-side escaping
var rawInputText = $('#form-input').text();
var escapedInputText = Drupal.checkPlain(rawInputText);
// Safe query with parameter binding
\Drupal::database()->query(
  'SELECT foo FROM {table} t WHERE t.name = :name',
  [':name' => $name]
);

// Safe query using Drupal's query builder
$users = ['joe', 'poe', $name];
$result = \Drupal::database()
  ->select('foo', 'f')
  ->fields('f', ['bar'])
  ->condition('f.bar', $users)
  ->execute();

// Proper LIKE condition with escapeLike()
$conn = \Drupal::database();
$conn->select('table', 't')
  ->condition('t.field', '%_' . $conn->escapeLike($name), 'LIKE')
  ->execute();

// Safe CSS class sanitization
public function elementClasses($row_index = NULL) {
  $classes = $this->tokenizeValue($this->options['element_class'], $row_index);
  $classes = explode(' ', $classes);
  foreach ($classes as &$class) {
    $class = Html::cleanCssIdentifier($class);
  }
  return implode(' ', $classes);
}
Read more
Ships withsiva01c-claude-plugins

A curated collection of Claude Code plugins for Drupal development, security, and deployment. Each plugin covers one topic — Drupal itself, DDEV, Docker, CI/CD, git workflows, and security verification — so you install only what you need.

Get the whole plugin, auto-invoked
Stats
17
Stars
1
Views
0
Forks
Active
Maintenance
MIT
License
28d ago
Last commit
9mo ago
Created

Repo: siva01c/claude-plugins