Skip to content

Commit 7043b54

Browse files
authored
Update
1 parent aeb99da commit 7043b54

File tree

1 file changed

+93
-126
lines changed

1 file changed

+93
-126
lines changed

.github/copilot-instructions.md

Lines changed: 93 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,106 @@
11
---
22
applyTo: '**'
33
---
4-
Coding standards, domain knowledge, and preferences that AI should follow.
54

6-
# Work Environment
5+
# WordPress Plugin Development Standards
76

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.
7+
## 🎯 Core Principles
98

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.
9+
**Work Environment:** Remote GitHub Codespaces only. Never suggest local Terminal commands.
1110

12-
# Responses
11+
**WordPress First:** Use WordPress APIs, hooks, and standards exclusively. Avoid non-WP frameworks.
1312

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.
13+
**Security Critical:** Sanitize all input, escape all output, use WordPress security functions.
1514

16-
Responses should be delivered only in the chat interface. Formatting and styling should be utilized to enhance readability.
15+
**Thorough Analysis:** Read complete files (minimum 1500 lines) for accurate code review.
1716

18-
Change summaries should never be created in the form of new .md files.
19-
20-
# Code Analysis and Reading Standards
21-
22-
You must read files completely and thoroughly, with a minimum of 1500 lines per read operation when analyzing code. Never truncate files or stop reading at arbitrary limits like 50 or 100 lines. Your analysis must be based on the complete file content, not partial snapshots. 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.
23-
24-
# Coding Standards and Preferences
17+
## 📋 Essential Requirements
2518

26-
## WordPress Focused Design
27-
28-
- Leverage WordPress APIs, hooks (actions and filters), and functions where applicable.
29-
- Ensure compatibility with modern WordPress versions and PHP standards.
30-
- Ensure all code is compatible with the WordPress ecosystem, including themes and plugins.
31-
- Avoid using frameworks, libraries, or non-standard features that are not compatible or commonly used with WordPress.
19+
### WordPress Compatibility
20+
- **WordPress:** 6.5+ minimum
21+
- **PHP:** 7.4+ minimum
22+
- **WooCommerce:** 5.0+ (when applicable)
23+
- Follow [WordPress Coding Standards](https://developer.wordpress.org/coding-standards/) for PHP, JS, CSS, HTML, and accessibility
3224

33-
## WordPress Coding Standards
25+
### Code Quality Standards
26+
1. **Security First:** Always sanitize input (`sanitize_*()`) and escape output (`esc_*()`)
27+
2. **WordPress APIs:** Use WP functions instead of raw PHP/SQL
28+
3. **Hook System:** Proper use of `add_action()` and `add_filter()`
29+
4. **Internationalization:** Use `__()`, `_e()`, `esc_html__()` for all strings
30+
5. **Performance:** Avoid N+1 queries, use WP caching, optimize database calls
3431

35-
- Use WordPress coding standards for PHP, JavaScript, and CSS:
36-
- [PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)
37-
- [JavaScript Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/)
38-
- [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/)
39-
- Use WordPress coding standards for HTML and template files:
40-
- [HTML Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/)
41-
- Use WordPress coding standards for accessibility:
42-
- [Accessibility Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/accessibility/)
43-
- Use WordPress Gutenberg Project Coding Guidelines:
44-
- [Gutenberg Project Coding Guidelines](https://developer.wordpress.org/block-editor/contributors/code/coding-guidelines/)
45-
- Use WordPress JavaScript Documentation Standards:
46-
- [JavaScript Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/javascript/)
47-
- Use WordPress PHP Documentation Standards:
48-
- [PHP Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/)
49-
50-
## Supported Versions
51-
52-
- This project supports modern software versions:
53-
- WordPress 6.5+ (minimum)
54-
- PHP 7.4+ (minimum)
55-
- WooCommerce 5.0+ (if applicable)
56-
- Do not use features or functions that are deprecated or not available in these versions.
57-
58-
## Version Control and Documentation
59-
60-
- 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.
61-
- Version Locations:
62-
- README.md
63-
- readme.txt (for WordPress.org)
64-
- CHANGELOG.md
65-
- plugin header (in the main plugin file)
66-
- plugin section: "// Define plugin constants"
67-
- plugin *.pot files (e.g., languages/plugin-name.pot)
68-
- package.json (if applicable)
69-
- composer.json (if applicable)
70-
- documentation files (e.g., docs/README.md)
71-
- Use semantic versioning (MAJOR.MINOR.PATCH) for all releases.
72-
- Always add new information to the changelog when we make changes to the codebase, even if a new version is not released.
73-
- 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.
74-
- 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.
75-
- When making changes to the codebase, always update the relevant documentation files, including README.md, readme.txt, and CHANGELOG.md, even when a new version is not released.
76-
- 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.
77-
- When the version number is updated, ensure that the new version number is reflected in all relevant files, as outlined in Version Locations above.
78-
- 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.
79-
80-
# General Coding Standards
81-
82-
- The above standards are prioritized over general coding standards.
83-
- 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.
84-
85-
## Accessibility & UX
86-
87-
- Follow accessibility best practices for UI components
88-
- Ensure forms are keyboard-navigable and screen reader friendly
89-
- Validate user-facing labels, tooltips, and messages for clarity
90-
91-
## Performance & Optimization
92-
93-
- Optimize for performance and scalability where applicable
94-
- Avoid premature optimization—focus on correctness first
95-
- Detect and flag performance issues (e.g., unnecessary re-renders, N+1 queries)
96-
- Use lazy loading, memoization, or caching where needed
97-
98-
## Type Safety & Standards
99-
100-
- Use strict typing wherever possible (TypeScript, C#, etc.)
101-
- Avoid using `any` or untyped variables
102-
- Use inferred and narrow types when possible
103-
- Define shared types centrally (e.g., `types/` or `shared/` folders)
104-
105-
## Security & Error Handling
106-
107-
- Sanitize all input and output, especially in forms, APIs, and database interactions
108-
- Escape, validate, and normalize all user-supplied data
109-
- Automatically handle edge cases and error conditions
110-
- Fail securely and log actionable errors
111-
- Avoid leaking sensitive information in error messages or logs
112-
- Use secure coding practices to prevent common vulnerabilities (e.g., XSS, CSRF, SQL injection)
113-
- Use prepared statements for database queries
114-
- Use secure authentication and authorization mechanisms
115-
- When using third-party libraries or APIs, ensure they are well-maintained and secure
116-
- Regularly update dependencies to their latest stable versions
117-
- Use HTTPS for all API requests and data transmission
118-
- When handling sensitive data, ensure it is encrypted both in transit and at rest
119-
- If you suspect a security vulnerability, attempt to identify and fix it automatically. Alert me to the issue and provide a detailed explanation of the vulnerability, how it can be exploited, and the steps taken to mitigate it.
120-
- 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.
121-
- 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.
122-
123-
## Code Quality & Architecture
124-
125-
- Organize code using **feature-sliced architecture** when applicable
126-
- Group code by **feature**, not by type (e.g., keep controller, actions, and helpers together by feature)
127-
- Write clean, readable, and self-explanatory code
128-
- Use meaningful and descriptive names for files, functions, and variables
129-
- Remove unused imports, variables, and dead code automatically
130-
131-
## Task Execution & Automation
132-
133-
- Always proceed to the next task automatically unless confirmation is required
134-
- Only ask for confirmation when an action is destructive (e.g., data loss, deletion)
135-
- Always attempt to identify and fix bugs automatically
136-
- Only ask for manual intervention if domain-specific knowledge is required
137-
- Auto-lint and format code using standard tools (e.g., Prettier, ESLint, dotnet format)
138-
- 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.
139-
- 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.
32+
## 🔒 Security Requirements (Critical)
33+
34+
**Input Handling:**
35+
- Use `sanitize_text_field()`, `sanitize_email()`, `wp_kses()` for user input
36+
- Validate with `is_email()`, `absint()`, `wp_verify_nonce()` for security
37+
- Use prepared statements for database queries (`$wpdb->prepare()`)
38+
39+
**Output Security:**
40+
- Escape all output: `esc_html()`, `esc_attr()`, `esc_url()`, `esc_js()`
41+
- Use `wp_nonce_field()` and `wp_verify_nonce()` for forms
42+
- Check permissions with `current_user_can()` before sensitive operations
43+
44+
**Vulnerability Prevention:**
45+
- Prevent SQL injection, XSS, CSRF, and path traversal
46+
- Follow principle of least privilege
47+
- Auto-identify and fix security issues when found
48+
49+
## 📝 Documentation & Versioning
50+
51+
**Changelog Management:**
52+
- Always update CHANGELOG.md and readme.txt when making code changes
53+
- **Sync both changelogs:** CHANGELOG.md and readme.txt changelog section
54+
- Use "Unreleased" section for ongoing changes
55+
56+
**Version Release Process (only when instructed):**
57+
- Follow semantic versioning (MAJOR.MINOR.PATCH)
58+
- Update version in: plugin header, README.md, readme.txt, CHANGELOG.md
59+
- Update version in: constants section, .pot files, package.json, composer.json
60+
- Move "Unreleased" changes to new version section in both changelogs
61+
- **Never auto-update versions** - wait for explicit instruction
62+
63+
**Code Documentation:**
64+
- Use PHPDoc with `@param`, `@return`, `@since` tags
65+
- Write clear function/class descriptions
66+
- Document security considerations and hooks used
67+
68+
## ⚡ Performance & Quality
69+
70+
**Performance Optimization:**
71+
- Use WordPress caching (`wp_cache_*()`, transients)
72+
- Optimize database queries, avoid N+1 problems
73+
- Proper asset enqueueing with `wp_enqueue_*()` functions
74+
- Focus on correctness first, then optimize
75+
76+
**Code Architecture:**
77+
- Group by feature, not by type
78+
- Use descriptive function/variable names
79+
- Remove unused code automatically
80+
- Follow feature-sliced design when applicable
81+
82+
**Error Handling:**
83+
- Use `WP_Error` for WordPress-specific errors
84+
- Log errors without exposing sensitive data
85+
- Handle edge cases gracefully
86+
- Validate all function parameters
87+
88+
## 🚀 Workflow & Automation
89+
90+
**Task Execution:**
91+
- Make changes directly to existing files (don't create duplicates)
92+
- Proceed automatically unless action is destructive
93+
- Auto-identify and fix bugs when possible
94+
- Only ask confirmation for data loss/deletion scenarios
95+
96+
**File Management:**
97+
- Edit files in place (e.g., modify `admin.php` directly)
98+
- Create new files only when truly necessary
99+
- Avoid file duplication and unnecessary rewrites
100+
- Maintain clean project structure
101+
102+
**Communication:**
103+
- Provide concise, actionable responses
104+
- Use clear formatting for readability
105+
- Never create change summaries as separate .md files
106+
- Focus on specific changes made, not verbose explanations

0 commit comments

Comments
 (0)