cursorrules / rules
Cursor rule88 starsChanged 13 months agoMITView on GitHub
Standards for PHP and Drupal development
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/accessibility-standards.mdcCursor rule
- .cursor/rules/api-standards.mdcCursor rule
- .cursor/rules/behat-ai-guide.mdcCursor rule
- .cursor/rules/behat-steps.mdcCursor rule
- .cursor/rules/build-optimization.mdcCursor rule
- .cursor/rules/code-generation-standards.mdcCursor rule
- .cursor/rules/confluence-editing-standards.mdcCursor rule
- .cursor/rules/cursor-rules.mdcCursor rule
- .cursor/rules/debugging-standards.mdcCursor rule
- .cursor/rules/docker-compose-standards.mdcCursor rule
- .cursor/rules/drupal-authentication-failures.mdcCursor rule
- .cursor/rules/drupal-broken-access-control.mdcCursor rule
- .cursor/rules/drupal-cryptographic-failures.mdcCursor rule
- .cursor/rules/drupal-database-standards.mdcCursor rule
- .cursor/rules/drupal-file-permissions.mdcCursor rule
- .cursor/rules/drupal-injection.mdcCursor rule
- .cursor/rules/drupal-insecure-design.mdcCursor rule
- .cursor/rules/drupal-integrity-failures.mdcCursor rule
- .cursor/rules/drupal-logging-failures.mdcCursor rule
- .cursor/rules/drupal-security-misconfiguration.mdcCursor rule
- .cursor/rules/drupal-ssrf.mdcCursor rule
- .cursor/rules/drupal-vulnerable-components.mdcCursor rule
- .cursor/rules/generic_bash_style.mdcCursor rule
- .cursor/rules/git-commit-standards.mdcCursor rule
- .cursor/rules/github-actions-standards.mdcCursor rule
- .cursor/rules/improve-cursorrules-efficiency.mdcCursor rule
- .cursor/rules/javascript-broken-access-control.mdcCursor rule
- .cursor/rules/javascript-cryptographic-failures.mdcCursor rule
- .cursor/rules/javascript-identification-authentication-failures.mdcCursor rule
- .cursor/rules/javascript-injection.mdcCursor rule
- .cursor/rules/javascript-insecure-design.mdcCursor rule
- .cursor/rules/javascript-performance.mdcCursor rule
- .cursor/rules/javascript-security-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/javascript-security-misconfiguration.mdcCursor rule
- .cursor/rules/javascript-server-side-request-forgery.mdcCursor rule
- .cursor/rules/javascript-software-data-integrity-failures.mdcCursor rule
- .cursor/rules/javascript-standards.mdcCursor rule
- .cursor/rules/javascript-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/lagoon-docker-compose-standards.mdcCursor rule
- .cursor/rules/lagoon-yml-standards.mdcCursor rule
- .cursor/rules/multi-agent-coordination.mdcCursor rule
- .cursor/rules/new-pull-request.mdcCursor rule
- .cursor/rules/node-dependencies.mdcCursor rule
- .cursor/rules/php-drupal-best-practices.mdcCursor rule
- .cursor/rules/php-memory-optimisation.mdcCursor rule
- .cursor/rules/project-definition-template.mdcCursor rule
- .cursor/rules/pull-request-changelist-instructions.mdcCursor rule
- .cursor/rules/python-authentication-failures.mdcCursor rule
- .cursor/rules/python-broken-access-control.mdcCursor rule
- .cursor/rules/python-cryptographic-failures.mdcCursor rule
- .cursor/rules/python-injection.mdcCursor rule
- .cursor/rules/python-insecure-design.mdcCursor rule
- .cursor/rules/python-integrity-failures.mdcCursor rule
- .cursor/rules/python-logging-monitoring-failures.mdcCursor rule
- .cursor/rules/python-security-misconfiguration.mdcCursor rule
- .cursor/rules/python-ssrf.mdcCursor rule
- .cursor/rules/python-vulnerable-outdated-components.mdcCursor rule
- .cursor/rules/react-patterns.mdcCursor rule
- The first 60 shown.
The file
We split this php-drupal-development-standards.mdc into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 57
File Structure: Place module files in web/modules/custom/[module_name]/ for organization.
- Very specific: line 58
Module Files: Ensure modules include .info.yml, .module, .libraries.yml, .services.yml where applicable.
- Distinctive: line 59
Dependencies: Use hook_requirements() to manage external dependencies.
- Distinctive: line 60
Forms: Use FormBase or ConfigFormBase for creating forms, always include CSRF protection.
- Distinctive: line 64
Dependency Injection: Follow Drupal's dependency injection patterns for better maintainability.
- Distinctive: line 65
Service Container: Use Drupal's service container to manage dependencies.
- Distinctive: line 68
Translation: Use Drupal's t() function for all user-facing strings.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Standards for PHP and Drupal development
globs: *.php, *.module, *.inc, *.install, *.theme
---
# Enhanced PHP and Drupal Development Standards
Ensures adherence to PHP 8.3+ features and Drupal development best practices for improved code quality, security, and maintainability.
<rule>
name: enhanced_php_drupal_development_standards
description: Enforce PHP 8.3+ and Drupal development standards
filters:
- type: file_extension
pattern: "\\.(php|module|inc|install|theme)$"
- type: file_path
pattern: "web/modules/custom/|web/themes/custom/"
actions:
- type: enforce
conditions:
- pattern: "^(?!declare\\(strict_types=1\\);)"
message: "Add 'declare(strict_types=1);' at the beginning of PHP files for type safety."
- pattern: "class\\s+\\w+\\s*(?!\\{[^}]*readonly\\s+\\$)"
message: "Consider using readonly properties where immutability is required for better code safety."
- pattern: "public\\s+function\\s+\\w+\\([^)]*\\)\\s*(?!:)"
message: "Add return type declarations for all methods to enhance type safety."
- pattern: "extends\\s+\\w+\\s*\\{[^}]*public\\s+function\\s+\\w+\\([^)]*\\)\\s*(?!#\\[Override\\])"
message: "Add #[Override] attribute for overridden methods for clear intent."
- pattern: "\\$\\w+\\s*(?!:)"
message: "Use typed properties with proper nullability to improve code readability and prevent errors."
- pattern: "function\\s+hook_\\w+\\([^)]*\\)\\s*(?!:)"
message: "Add type hints and return types for all hooks to leverage PHP's type system."
- pattern: "new\\s+\\w+\\([^)]*\\)\\s*(?!;\\s*//\\s*@inject)"
message: "Use proper dependency injection with services for better testability and modularity."
- pattern: "extends\\s+FormBase\\s*\\{[^}]*validate"
message: "Implement proper form validation in FormBase classes for security."
- pattern: "(?<!\\bTRUE\\b)\\btrue\\b|(?<!\\bFALSE\\b)\\bfalse\\b|(?<!\\bNULL\\b)\\bnull\\b"
message: "Use uppercase for TRUE, FALSE, and NULL constants for consistency."
- pattern: "(?i)\\/\\/\\s[a-z]"
message: "Ensure inline comments begin with a capital letter and end with a period for readability."
- pattern: "\\$this->config\\('\\w+'\\)"
message: "Use ConfigFactory for configuration management to ensure proper dependency injection."
- type: suggest
message: |
**PHP/Drupal Development Best Practices:**
- **File Structure:** Place module files in `web/modules/custom/[module_name]/` for organization.
- **Module Files:** Ensure modules include .info.yml, .module, .libraries.yml, .services.yml where applicable.
- **Dependencies:** Use hook_requirements() to manage external dependencies.
- **Forms:** Use FormBase or ConfigFormBase for creating forms, always include CSRF protection.
- **Caching:** Apply proper cache tags and contexts for performance optimization.
- **Error Handling & Logging:** Implement robust error handling and logging using Drupal's mechanisms.
- **Type Safety:** Leverage type safety in form methods and throughout your code.
- **Dependency Injection:** Follow Drupal's dependency injection patterns for better maintainability.
- **Service Container:** Use Drupal's service container to manage dependencies.
- **Security:** Validate all user inputs, use Drupal's security practices like sanitization and escaping.
- **Schema Updates:** Implement hook_update_N() for database schema changes.
- **Translation:** Use Drupal's t() function for all user-facing strings.
- type: validate
conditions:
- pattern: "web/modules/custom/[^/]+/\\.info\\.yml$"
message: "Ensure each custom module has a required .info.yml file."
- pattern: "web/modules/custom/[^/]+/\\.module$"
message: "Ensure module has .module file if hooks are implemented."
- pattern: "web/modules/custom/[^/]+/src/Form/\\w+Form\\.php$"
message: "Place form classes in the Form directory for consistency."
- pattern: "try\\s*\\{[^}]*\\}\\s*catch\\s*\\([^)]*\\)\\s*\\{\\s*\\}"
message: "Implement proper exception handling in catch blocks for robustness."
metadata:
priority: critical
version: 1.1
</rule>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

