|
| 1 | +--- |
| 2 | +applyTo: '**' |
| 3 | +--- |
| 4 | +Coding standards, domain knowledge, and preferences that AI should follow. |
| 5 | + |
| 6 | +# Work Environment |
| 7 | + |
| 8 | +This project is coded entirely in a remote development environment using GitHub Codespaces. The AI will never ask me to run Terminal commands or use a local development environment. All code changes, tests, and debugging will be done within remote repositories on GitHub. |
| 9 | + |
| 10 | +Change summaries should be concise and clear, focusing on the specific changes made. The AI should not ask for confirmation before making changes, as all code modifications will be done directly in the remote environment. |
| 11 | + |
| 12 | +# Responses |
| 13 | + |
| 14 | +When delivering responses, the AI should provide clear, concise, and actionable information. Responses should be formatted in a way that is easy to read and understand, with a focus on clarity and precision. The AI should avoid unnecessary verbosity or complexity in its explanations. |
| 15 | + |
| 16 | +Responses, change summaries, and code comments should be written in English. The AI should not use any other languages or dialects, including regional variations of English. All communication should be clear and professional, adhering to standard English grammar and spelling conventions. |
| 17 | + |
| 18 | +Responses should be delivered only in the chat interface. Formatting and styling should be utilized to enhance readability. |
| 19 | + |
| 20 | +Change summaries should never be created in the form of new .md files. |
| 21 | + |
| 22 | +# Code Analysis and Reading Standards |
| 23 | + |
| 24 | +You must read files completely and thoroughly, with a minimum of 1000 lines per read operation when analyzing code. Never truncate files or stop reading at arbitrary limits like 50 or 100 lines - this lazy approach provides incomplete context and leads to poor suggestions. When you encounter any file, read it from the very first line to the absolute last line, processing all functions, classes, variables, imports, exports, and code structures. Your analysis must be based on the complete file content, not partial snapshots. Always read at least 1000 lines minimum per read operation, and if the file is larger, continue reading until you've processed the entire file. Do not use phrases like "showing first X lines" or "truncated for brevity" or "rest of file omitted" - these indicate lazy, incomplete analysis. Instead, demonstrate that you've read the complete file by referencing specific sections throughout the entire codebase, understanding the full context of how functions interact, how variables are used across the entire file, and how the complete code structure works together. Your suggestions and recommendations must reflect knowledge of the entire file, not just the beginning portions. Take the time to read everything properly because thoroughness and accuracy based on complete file knowledge is infinitely more valuable than quick, incomplete reviews that miss critical context and lead to incorrect suggestions. |
| 25 | + |
| 26 | +# Coding Standards and Preferences |
| 27 | + |
| 28 | +## WordPress Focused Design |
| 29 | + |
| 30 | +- This project is focused on WordPress development. |
| 31 | +- Use WordPress coding standards and best practices. |
| 32 | +- Leverage WordPress APIs and functions where applicable. |
| 33 | +- Ensure compatibility with modern WordPress versions and PHP standards. WordPress 6.5+ and PHP 7.4+ are the baseline. |
| 34 | +- Use WordPress hooks (actions and filters) to extend functionality. |
| 35 | +- Follow WordPress theme and plugin development guidelines. |
| 36 | +- Use WordPress REST API for custom endpoints and data retrieval. |
| 37 | +- Ensure all code is compatible with the WordPress ecosystem, including themes and plugins. |
| 38 | +- As this is a WordPress-focused project, avoid using frameworks or libraries that are not compatible with WordPress. |
| 39 | +- Do not use frameworks or libraries that are not commonly used in the WordPress ecosystem. |
| 40 | +- Avoid using non-standard or experimental features that are not widely adopted in the WordPress community. |
| 41 | +- For any project that utilizes WooCommerce, ensure minimum version compatibility with WooCommerce 5.0+. |
| 42 | + |
| 43 | +## WordPress Coding Standards |
| 44 | + |
| 45 | +- Use WordPress coding standards for PHP, JavaScript, and CSS: |
| 46 | + - [PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/) |
| 47 | + - [JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/) |
| 48 | + - [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/) |
| 49 | +- Use WordPress coding standards for HTML and template files: |
| 50 | + - [HTML Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/) |
| 51 | +- Use WordPress coding standards for accessibility: |
| 52 | + - [Accessibility Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/) |
| 53 | +- Use WordPress Gutenberg Project Coding Guidelines: |
| 54 | + - [Gutenberg Project Coding Guidelines](https://developer.wordpress.org/block-editor/contributors/code/coding-guidelines/) |
| 55 | +- Use WordPress JavaScript Documentation Standards: |
| 56 | + - [JavaScript Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/javascript/) |
| 57 | +- Use WordPress PHP Documentation Standards: |
| 58 | + - [PHP Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/) |
| 59 | + |
| 60 | +## Supported Versions |
| 61 | + |
| 62 | +- This project supports modern software versions: |
| 63 | + - WordPress 6.5+ (minimum) |
| 64 | + - PHP 7.4+ (minimum) |
| 65 | + - WooCommerce 5.0+ (if applicable) |
| 66 | +- Do not use features or functions that are not available in these versions. |
| 67 | + |
| 68 | +## Version Control and Documentation |
| 69 | + |
| 70 | +- Release versions, software tested versions, and minimum software supported versions for this project are listed in numerous places, when updating the release version for this project, ensure that all of these locations are updated accordingly. |
| 71 | +- Version Locations: |
| 72 | + - README.md |
| 73 | + - changelog.txt |
| 74 | + - changelog.md |
| 75 | + - plugin header (in the main plugin file) |
| 76 | + - plugin section: "// Define plugin constants" |
| 77 | + - plugin *.pot files (e.g., languages/plugin-name.pot) |
| 78 | + - package.json (if applicable) |
| 79 | + - composer.json (if applicable) |
| 80 | + - documentation files (e.g., docs/README.md) |
| 81 | +- Use semantic versioning (MAJOR.MINOR.PATCH) for all releases. |
| 82 | +- Always add new information to the changelog when we make changes to the codebase, even if a new version is not released. |
| 83 | +- When adding new information to the changelogs, changes will first be added to an "Unreleased" section at the top of the changelog file, and then later moved to a new version section when a new version is released. Be sure to follow this pattern and do not skip any of the changelog files. |
| 84 | +- Do not automatically update the version number in the plugin header or other files. Instead, provide a clear and concise change summary that includes the version number and a brief description of the changes made. |
| 85 | +- When making changes to the codebase, always update the relevant documentation files, including README.md, readme.txt, changelog.txt, and changelog.md, even when a new version is not released. |
| 86 | +- Please do not skip these locations, as all of the changelog files must be in sync with each other, and the version numbers must be consistent across all files. |
| 87 | +- I will instruct you when to update the version number, and you should not do this automatically. Always ask for confirmation before updating the version number. |
| 88 | +- When the version number is updated, ensure that the new version number is reflected in all relevant files, including the plugin header, changelog files, and documentation files. |
| 89 | +- WHen the version number is updated, make special note to update the "Unreleased" section in the changelog files to reflect the new version number and a brief description of the changes made. This ensures that all changes are documented and easily accessible for future reference. |
| 90 | + |
| 91 | +# General Coding Standards |
| 92 | + |
| 93 | +- The above standards are prioritized over general coding standards. |
| 94 | +- The standards below are general coding standards that apply to all code, including WordPress code. Do not apply them if they conflict with WordPress standards. |
| 95 | + |
| 96 | +## Accessibility & UX |
| 97 | + |
| 98 | +- Follow accessibility best practices for UI components |
| 99 | +- Ensure forms are keyboard-navigable and screen reader friendly |
| 100 | +- Validate user-facing labels, tooltips, and messages for clarity |
| 101 | + |
| 102 | +## Performance & Optimization |
| 103 | + |
| 104 | +- Optimize for performance and scalability where applicable |
| 105 | +- Avoid premature optimization—focus on correctness first |
| 106 | +- Detect and flag performance issues (e.g., unnecessary re-renders, N+1 queries) |
| 107 | +- Use lazy loading, memoization, or caching where needed |
| 108 | + |
| 109 | +## Type Safety & Standards |
| 110 | + |
| 111 | +- Use strict typing wherever possible (TypeScript, C#, etc.) |
| 112 | +- Avoid using `any` or untyped variables |
| 113 | +- Use inferred and narrow types when possible |
| 114 | +- Define shared types centrally (e.g., `types/` or `shared/` folders) |
| 115 | + |
| 116 | +## Security & Error Handling |
| 117 | + |
| 118 | +- Sanitize all input and output, especially in forms, APIs, and database interactions |
| 119 | +- Escape, validate, and normalize all user-supplied data |
| 120 | +- Automatically handle edge cases and error conditions |
| 121 | +- Fail securely and log actionable errors |
| 122 | +- Avoid leaking sensitive information in error messages or logs |
| 123 | +- Use secure coding practices to prevent common vulnerabilities (e.g., XSS, CSRF, SQL injection) |
| 124 | +- Use prepared statements for database queries |
| 125 | +- Use secure authentication and authorization mechanisms |
| 126 | +- When using third-party libraries or APIs, ensure they are well-maintained and secure |
| 127 | +- Regularly update dependencies to their latest stable versions |
| 128 | +- Use HTTPS for all API requests and data transmission |
| 129 | +- When handling sensitive data, ensure it is encrypted both in transit and at rest |
| 130 | +- If you suspect a security vulnerability, immediately notify the project maintainers and provide details for investigation |
| 131 | +- If you encounter a security vulnerability in the codebase, do not disclose it publicly. Instead, report it privately to the project maintainers or through a responsible disclosure process. |
| 132 | +- If you are unsure about the security implications of a specific code change, ask for clarification or guidance before proceeding. |
| 133 | +- Always follow the principle of least privilege when implementing security features, ensuring that users and processes have only the permissions they need to perform their tasks. |
| 134 | +- If you encounter a security vulnerability in a third-party library or dependency, check if there is an updated version that addresses the issue. If not, consider alternatives or report the vulnerability to the library maintainers. |
| 135 | +- If there is a possible security vulnerability in the codebase, you should always ask for confirmation before proceeding with any changes. This ensures that the project maintainers are aware of the potential risk and can provide guidance on how to address it safely. |
| 136 | +- If I ask you to make changes that could potentially introduce security vulnerabilities, you should always ask for confirmation before proceeding. This ensures that the project maintainers are aware of the potential risk and can provide guidance on how to address it safely. |
| 137 | + |
| 138 | +## Code Quality & Architecture |
| 139 | + |
| 140 | +- Organize code using **feature-sliced architecture** when applicable |
| 141 | +- Group code by **feature**, not by type (e.g., keep controller, actions, and helpers together by feature) |
| 142 | +- Write clean, readable, and self-explanatory code |
| 143 | +- Use meaningful and descriptive names for files, functions, and variables |
| 144 | +- Remove unused imports, variables, and dead code automatically |
| 145 | + |
| 146 | +## Task Execution & Automation |
| 147 | + |
| 148 | +- Always proceed to the next task automatically unless confirmation is required |
| 149 | +- Only ask for confirmation when an action is destructive (e.g., data loss, deletion) |
| 150 | +- Always attempt to identify and fix bugs automatically |
| 151 | +- Only ask for manual intervention if domain-specific knowledge is required |
| 152 | +- Auto-generate missing files, boilerplate, and tests when possible |
| 153 | +- Auto-lint and format code using standard tools (e.g., Prettier, ESLint, dotnet format) |
| 154 | +- Changes should be made directly to the file in question. Example: admin.php should be modified directly, not by creating a new file like admin-changes.php. |
| 155 | +- New files may be created when appropriate, but they should be relevant to the task at hand, so long as they are not a rewrite of an existing file. We want to avoid unnecessary duplication of files. |
0 commit comments