// Automatically applies Drupal coding standards when developing PHP modules, JavaScript, CSS, SQL queries, Twig templates, or YAML configs. Activates when creating/editing .php, .js, .css, .sql, .twig, .yml files or when user mentions "module", "query", "template", "form", or "custom code".
| name | drupal-standards |
| description | Automatically applies Drupal coding standards when developing PHP modules, JavaScript, CSS, SQL queries, Twig templates, or YAML configs. Activates when creating/editing .php, .js, .css, .sql, .twig, .yml files or when user mentions "module", "query", "template", "form", or "custom code". |
Apply Drupal coding standards based on the development context.
From coding_standards/index.md:
When working with PHP code, ALWAYS read these standards FIRST:
coding_standards/php/coding.mdcoding_standards/php/documentation.mdcoding_standards/php/namespaces.mdcoding_standards/php/psr4.mdAdditionally, based on specific needs:
coding_standards/php/naming-services.mdcoding_standards/php/exceptions.mdcoding_standards/php/placeholders-delimiters.mdcoding_standards/php/e_all.mdcoding_standards/php/documentation-examples.mdALWAYS read these standards FIRST:
coding_standards/javascript/coding.mdcoding_standards/javascript/documentation.mdcoding_standards/javascript/best-practice.mdcoding_standards/javascript/eslint.mdIf using jQuery:
coding_standards/javascript/jquery.mdALWAYS read these standards FIRST:
coding_standards/css/coding.mdcoding_standards/css/format.mdcoding_standards/css/file-organization.mdcoding_standards/css/architecture.mdFor tool configuration:
coding_standards/css/csscomb.mdcoding_standards/css/review.mdALWAYS read these standards FIRST:
coding_standards/sql/conventions.mdcoding_standards/sql/keywords.mdcoding_standards/sql/select-from.mdALWAYS read these standards:
coding_standards/twig/coding.mdcoding_standards/markup/style.mdALWAYS read:
coding_standards/yaml/configuration-files.mdALWAYS read:
coding_standards/composer/package-name.mdALWAYS read:
coding_standards/accessibility/accessibility.mdALWAYS apply:
coding_standards/spelling/spelling.md (US English required)1. User requests development task
โ
2. Identify file types/context (PHP, JS, CSS, SQL, etc.)
โ
3. Read ALL relevant standard files from coding_standards/
โ
4. Apply standards while writing code
โ
5. Validate code against standards
โ
6. Complete task with compliant code
For tasks involving multiple file types, load ALL relevant standards:
Example: Creating a custom module
User: "Create a service to handle user notifications"
Actions:
1. Identify: PHP service development
2. Read standards:
- coding_standards/php/coding.md
- coding_standards/php/documentation.md
- coding_standards/php/namespaces.md
- coding_standards/php/naming-services.md
3. Generate code following all standards
4. Include proper docblocks, namespaces, service naming
User: "Write a query to get active users with roles"
Actions:
1. Identify: SQL query
2. Read standards:
- coding_standards/sql/conventions.md
- coding_standards/sql/keywords.md
- coding_standards/sql/select-from.md
3. Write query with proper keyword capitalization and formatting
User: "Create a contact form with validation"
Actions:
1. Identify: Multi-context (PHP form API, JavaScript validation, accessibility)
2. Read standards:
- coding_standards/php/coding.md
- coding_standards/php/documentation.md
- coding_standards/javascript/coding.md
- coding_standards/markup/style.md
- coding_standards/accessibility/accessibility.md
3. Build form with all standards applied
4. Ensure full accessibility compliance