|
| 1 | +Guidelines for Using GitHub Copilot in Code Generation |
| 2 | + |
| 3 | +Clear and Readable Code: |
| 4 | + |
| 5 | +Code must be generated according to strict conventions, such as camelCase or snake_case, depending on the programming language. This is crucial for ensuring consistency, facilitating comprehension, and improving the maintainability of the code, particularly in large-scale projects. |
| 6 | + |
| 7 | +Detailed and informative annotations are mandatory, with a focus on explaining complex logic and algorithms. These annotations should strike an ideal balance between completeness and conciseness, enabling team members to collaborate efficiently and onboard new team members quickly. |
| 8 | + |
| 9 | +Functions and methods must be designed to maximize modularity. Each module should serve a specific responsibility, enhancing reusability and significantly simplifying bug fixes or extensions. Avoiding overly nested functions or methods helps to limit cyclomatic complexity. |
| 10 | + |
| 11 | +Security Measures: |
| 12 | + |
| 13 | +Generated code must not contain known vulnerabilities, such as SQL injection, buffer overflows, or hardcoded credentials. Proactively applying security measures, such as using prepared statements and avoiding vulnerable APIs, is mandatory. |
| 14 | + |
| 15 | +All inputs must be thoroughly validated before being processed within the application. This includes both server-side and client-side validation. Additionally, error handling must be robust, providing clear messages and logging mechanisms that enable developers to quickly locate and resolve issues. |
| 16 | + |
| 17 | +Use frameworks and libraries that enforce security automatically, such as ORMs for database interactions and modern cryptographic libraries. This minimizes the risk of human errors and promotes best practices. |
| 18 | + |
| 19 | +Performance Optimization: |
| 20 | + |
| 21 | +Code should be written with algorithmic efficiency in mind. This includes avoiding redundant iterations and using efficient data structures like hashmaps or balanced trees, depending on the situation. |
| 22 | + |
| 23 | +Balancing readability and optimization is crucial, especially in critical applications such as real-time systems. Code must remain understandable for human reviewers without compromising performance. |
| 24 | + |
| 25 | +Future scalability should be considered when making design decisions. This includes anticipating peak loads, efficiently managing system resources, and integrating load-balancing solutions when necessary. |
| 26 | + |
| 27 | +Adherence to Best Practices: |
| 28 | + |
| 29 | +Consistency in style and implementation within a project is essential. This includes following language-specific conventions, using linting tools to prevent stylistic errors, and avoiding unconventional coding practices that could cause confusion. |
| 30 | + |
| 31 | +Applying proven principles such as SOLID (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) and DRY (Don't Repeat Yourself) is mandatory. These principles ensure robust and maintainable designs. |
| 32 | + |
| 33 | +Avoid implementing inefficient or outdated methodologies, as these limit the flexibility and expandability of future development cycles. |
| 34 | + |
| 35 | +Copyright and Licensing: |
| 36 | + |
| 37 | +Copilot must not generate code that infringes on copyrights. All generated code must fall under a permissive license unless stated otherwise. This prevents legal conflicts and ensures the integrity of the project. |
| 38 | + |
| 39 | +All dependencies and libraries used must be thoroughly documented. This includes specifying licensing requirements and ensuring compliance with these licenses to avoid legal risks. |
| 40 | + |
| 41 | +Usability: |
| 42 | + |
| 43 | +User interfaces, both CLI and GUI, must be intuitive and easy to use. Unnecessary complexity should be avoided, focusing on clear navigation and accessible features. |
| 44 | + |
| 45 | +Error handling in user interfaces should aim for user-friendly messages that inform the user about the nature of the error and provide practical solutions. This significantly enhances the overall user experience. |
| 46 | + |
| 47 | +Systematic implementation of internationalization (i18n) is essential to make the application accessible to a global audience. This includes supporting multiple languages and respecting regional differences in date formats, currencies, and other cultural norms. |
| 48 | + |
| 49 | +Compatibility and Sustainability: |
| 50 | + |
| 51 | +Generated code must remain up-to-date with the latest versions of programming languages and frameworks while maintaining backward compatibility. This promotes the sustainability of the codebase. |
| 52 | + |
| 53 | +Modularity should be central to the design, allowing future changes or extensions to be implemented easily without requiring significant refactoring. |
| 54 | + |
| 55 | +Version control using tools like Git, combined with automated CI/CD pipelines, must be applied to ensure a consistent and reliable codebase. |
| 56 | + |
| 57 | +Documentation and Educational Value: |
| 58 | + |
| 59 | +Each function must be accompanied by clear and concise documentation describing its functionality and limitations. This includes adding example implementations for practical application. |
| 60 | + |
| 61 | +Project documentation, such as README files, must be detailed and provide clear guidelines for installation, usage, and troubleshooting. This facilitates adoption by new users and developers. |
| 62 | + |
| 63 | +Regular updates and maintenance of documentation are essential to keep it synchronized with the evolution of the project. |
| 64 | + |
| 65 | +Minimization of Dependencies: |
| 66 | + |
| 67 | +External libraries should only be used when absolutely necessary. Overuse of dependencies increases the risk of security vulnerabilities and compatibility issues. |
| 68 | + |
| 69 | +Core functionality must remain independent of external resources, ensuring the application’s robustness in various environments. |
| 70 | + |
| 71 | +Ethical Responsibility: |
| 72 | + |
| 73 | +Code must not be generated for applications that are unethical or harmful, such as malware or invasive surveillance. |
| 74 | + |
| 75 | +Risky patterns and potential security issues must be explicitly flagged with warning annotations to ensure developers are aware of the implications. |
| 76 | + |
| 77 | +Promoting ethics and social responsibility must be an integral part of the development culture, with attention to minimizing harmful impacts and maximizing positive societal contributions. |
| 78 | + |
| 79 | +### Guidelines for Using GitHub Copilot in Code Generation |
| 80 | + |
| 81 | +1. **Clear and Readable Code:** |
| 82 | + - Code must be generated according to strict conventions, such as camelCase or snake_case, depending on the programming language. This is crucial for ensuring consistency, facilitating comprehension, and improving the maintainability of the code, particularly in large-scale projects. |
| 83 | + - Detailed and informative annotations are mandatory, with a focus on explaining complex logic and algorithms. These annotations should strike an ideal balance between completeness and conciseness, enabling team members to collaborate efficiently and onboard new team members quickly. |
| 84 | + - Functions and methods must be designed to maximize modularity. Each module should serve a specific responsibility, enhancing reusability and significantly simplifying bug fixes or extensions. Avoiding overly nested functions or methods helps to limit cyclomatic complexity. |
| 85 | + |
| 86 | +2. **Security Measures:** |
| 87 | + - Generated code must not contain known vulnerabilities, such as SQL injection, buffer overflows, or hardcoded credentials. Proactively applying security measures, such as using prepared statements and avoiding vulnerable APIs, is mandatory. |
| 88 | + - All inputs must be thoroughly validated before being processed within the application. This includes both server-side and client-side validation. Additionally, error handling must be robust, providing clear messages and logging mechanisms that enable developers to quickly locate and resolve issues. |
| 89 | + - Use frameworks and libraries that enforce security automatically, such as ORMs for database interactions and modern cryptographic libraries. This minimizes the risk of human errors and promotes best practices. |
| 90 | + |
| 91 | +3. **Performance Optimization:** |
| 92 | + - Code should be written with algorithmic efficiency in mind. This includes avoiding redundant iterations and using efficient data structures like hashmaps or balanced trees, depending on the situation. |
| 93 | + - Balancing readability and optimization is crucial, especially in critical applications such as real-time systems. Code must remain understandable for human reviewers without compromising performance. |
| 94 | + - Future scalability should be considered when making design decisions. This includes anticipating peak loads, efficiently managing system resources, and integrating load-balancing solutions when necessary. |
| 95 | + |
| 96 | +4. **Adherence to Best Practices:** |
| 97 | + - Consistency in style and implementation within a project is essential. This includes following language-specific conventions, using linting tools to prevent stylistic errors, and avoiding unconventional coding practices that could cause confusion. |
| 98 | + - Applying proven principles such as SOLID (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) and DRY (Don't Repeat Yourself) is mandatory. These principles ensure robust and maintainable designs. |
| 99 | + - Avoid implementing inefficient or outdated methodologies, as these limit the flexibility and expandability of future development cycles. |
| 100 | + |
| 101 | +5. **Copyright and Licensing:** |
| 102 | + - Copilot must not generate code that infringes on copyrights. All generated code must fall under a permissive license unless stated otherwise. This prevents legal conflicts and ensures the integrity of the project. |
| 103 | + - All dependencies and libraries used must be thoroughly documented. This includes specifying licensing requirements and ensuring compliance with these licenses to avoid legal risks. |
| 104 | + |
| 105 | +6. **Usability:** |
| 106 | + - User interfaces, both CLI and GUI, must be intuitive and easy to use. Unnecessary complexity should be avoided, focusing on clear navigation and accessible features. |
| 107 | + - Error handling in user interfaces should aim for user-friendly messages that inform the user about the nature of the error and provide practical solutions. This significantly enhances the overall user experience. |
| 108 | + - Systematic implementation of internationalization (i18n) is essential to make the application accessible to a global audience. This includes supporting multiple languages and respecting regional differences in date formats, currencies, and other cultural norms. |
| 109 | + |
| 110 | +7. **Compatibility and Sustainability:** |
| 111 | + - Generated code must remain up-to-date with the latest versions of programming languages and frameworks while maintaining backward compatibility. This promotes the sustainability of the codebase. |
| 112 | + - Modularity should be central to the design, allowing future changes or extensions to be implemented easily without requiring significant refactoring. |
| 113 | + - Version control using tools like Git, combined with automated CI/CD pipelines, must be applied to ensure a consistent and reliable codebase. |
| 114 | + |
| 115 | +8. **Documentation and Educational Value:** |
| 116 | + - Each function must be accompanied by clear and concise documentation describing its functionality and limitations. This includes adding example implementations for practical application. |
| 117 | + - Project documentation, such as README files, must be detailed and provide clear guidelines for installation, usage, and troubleshooting. This facilitates adoption by new users and developers. |
| 118 | + - Regular updates and maintenance of documentation are essential to keep it synchronized with the evolution of the project. |
| 119 | + |
| 120 | +9. **Minimization of Dependencies:** |
| 121 | + - External libraries should only be used when absolutely necessary. Overuse of dependencies increases the risk of security vulnerabilities and compatibility issues. |
| 122 | + - Core functionality must remain independent of external resources, ensuring the application’s robustness in various environments. |
| 123 | + |
| 124 | +10. **Ethical Responsibility:** |
| 125 | + - Code must not be generated for applications that are unethical or harmful, such as malware or invasive surveillance. |
| 126 | + - Risky patterns and potential security issues must be explicitly flagged with warning annotations to ensure developers are aware of the implications. |
| 127 | + - Promoting ethics and social responsibility must be an integral part of the development culture, with attention to minimizing harmful impacts and maximizing positive societal contributions. |
| 128 | + |
0 commit comments