{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"code-review-generic","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Generic code review instructions that can be customized for any project using GitHub Copilot'\napplyTo: '**'\nexcludeAgent: [\"coding-agent\"]\n---\n\n# Generic Code Review Instructions\n\nComprehensive code review guidelines for GitHub Copilot that can be adapted to any project. These instructions follow best practices from prompt engineering and provide a structured approach to code quality, security, testing, and architecture review.\n\n## Review Language\n\nWhen performing a code review, respond in **English** (or specify your preferred language).\n\n\u003e **Customization Tip**: Change to your preferred language by replacing \"English\" with \"Portuguese (Brazilian)\", \"Spanish\", \"French\", etc.\n\n## Review Priorities\n\nWhen performing a code review, prioritize issues in the following order:\n\n### 🔴 CRITICAL (Block merge)\n- **Security**: Vulnerabilities, exposed secrets, authentication/authorization issues\n- **Correctness**: Logic errors, data corruption risks, race conditions\n- **Breaking Changes**: API contract changes without versioning\n- **Data Loss**: Risk of data loss or corruption\n\n### 🟡 IMPORTANT (Requires discussion)\n- **Code Quality**: Severe violations of SOLID principles, excessive duplication\n- **Test Coverage**: Missing tests for critical paths or new functionality\n- **Performance**: Obvious performance bottlenecks (N+1 queries, memory leaks)\n- **Architecture**: Significant deviations from established patterns\n\n### 🟢 SUGGESTION (Non-blocking improvements)\n- **Readability**: Poor naming, complex logic that could be simplified\n- **Optimization**: Performance improvements without functional impact\n- **Best Practices**: Minor deviations from conventions\n- **Documentation**: Missing or incomplete comments/documentation\n\n## General Review Principles\n\nWhen performing a code review, follow these principles:\n\n1. **Be specific**: Reference exact lines, files, and provide concrete examples\n2. **Provide context**: Explain WHY something is an issue and the potential impact\n3. **Suggest solutions**: Show corrected code when applicable, not just what's wrong\n4. **Be constructive**: Focus on improving the code, not criticizing the author\n5. **Recognize good practices**: Acknowledge well-written code and smart solutions\n6. **Be pragmatic**: Not every suggestion needs immediate implementation\n7. **Group related comments**: Avoid multiple comments about the same topic\n\n## Code Quality Standards\n\nWhen performing a code review, check for:\n\n### Clean Code\n- Descriptive and meaningful names for variables, functions, and classes\n- Single Responsibility Principle: each function/class does one thing well\n- DRY (Don't Repeat Yourself): no code duplication\n- Functions should be small and focused (ideally \u003c 20-30 lines)\n- Avoid deeply nested code (max 3-4 levels)\n- Avoid magic numbers and strings (use constants)\n- Code should be self-documenting; comments only when necessary\n\n### Examples\n```javascript\n// ❌ BAD: Poor naming and magic numbers\nfunction calc(x, y) {\n    if (x \u003e 100) return y * 0.15;\n    return y * 0.10;\n}\n\n// ✅ GOOD: Clear naming and constants\nconst PREMIUM_THRESHOLD = 100;\nconst PREMIUM_DISCOUNT_RATE = 0.15;\nconst STANDARD_DISCOUNT_RATE = 0.10;\n\nfunction calculateDiscount(orderTotal, itemPrice) {\n    const isPremiumOrder = orderTotal \u003e PREMIUM_THRESHOLD;\n    const discountRate = isPremiumOrder ? PREMIUM_DISCOUNT_RATE : STANDARD_DISCOUNT_RATE;\n    return itemPrice * discountRate;\n}\n```\n\n### Error Handling\n- Proper error handling at appropriate levels\n- Meaningful error messages\n- No silent failures or ignored exceptions\n- Fail fast: validate inputs early\n- Use appropriate error types/exceptions\n\n### Examples\n```python\n# ❌ BAD: Silent failure and generic error\ndef process_user(user_id):\n    try:\n        user = db.get(user_id)\n        user.process()\n    except:\n        pass\n\n# ✅ GOOD: Explicit error handling\ndef process_user(user_id):\n    if not user_id or user_id \u003c= 0:\n        raise ValueError(f\"Invalid user_id: {user_id}\")\n\n    try:\n        user = db.get(user_id)\n    except UserNotFoundError:\n        raise UserNotFoundError(f\"User {user_id} not found in database\")\n    except DatabaseError as e:\n        raise ProcessingError(f\"Failed to retrieve user {user_id}: {e}\")\n\n    return user.process()\n```\n\n## Security Review\n\nWhen performing a code review, check for security issues:\n\n- **Sensitive Data**: No passwords, API keys, tokens, or PII in code or logs\n- **Input Validation**: All user inputs are validated and sanitized\n- **SQL Injection**: Use parameterized queries, never string concatenation\n- **Authentication**: Proper authentication checks before accessing resources\n- **Authorization**: Verify user has permission to perform action\n- **Cryptography**: Use established libraries, never roll your own crypto\n- **Dependency Security**: Check for known vulnerabilities in dependencies\n\n### Examples\n```java\n// ❌ BAD: SQL injection vulnerability\nString query = \"SELECT * FROM users WHERE email = '\" + email + \"'\";\n\n// ✅ GOOD: Parameterized query\nPreparedStatement stmt = conn.prepareStatement(\n    \"SELECT * FROM users WHERE email = ?\"\n);\nstmt.setString(1, email);\n```\n\n```javascript\n// ❌ BAD: Exposed secret in code\nconst API_KEY = \"sk_live_abc123xyz789\";\n\n// ✅ GOOD: Use environment variables\nconst API_KEY = process.env.API_KEY;\n```\n\n## Testing Standards\n\nWhen performing a code review, verify test quality:\n\n- **Coverage**: Critical paths and new functionality must have tests\n- **Test Names**: Descriptive names that explain what is being tested\n- **Test Structure**: Clear Arrange-Act-Assert or Given-When-Then pattern\n- **Independence**: Tests should not depend on each other or external state\n- **Assertions**: Use specific assertions, avoid generic assertTrue/assertFalse\n- **Edge Cases**: Test boundary conditions, null values, empty collections\n- **Mock Appropriately**: Mock external dependencies, not domain logic\n\n### Examples\n```typescript\n// ❌ BAD: Vague name and assertion\ntest('test1', () =\u003e {\n    const result = calc(5, 10);\n    expect(result).toBeTruthy();\n});\n\n// ✅ GOOD: Descriptive name and specific assertion\ntest('should calculate 10% discount for orders under $100', () =\u003e {\n    const orderTotal = 50;\n    const itemPrice = 20;\n\n    const discount = calculateDiscount(orderTotal, itemPrice);\n\n    expect(discount).toBe(2.00);\n});\n```\n\n## Performance Considerations\n\nWhen performing a code review, check for performance issues:\n\n- **Database Queries**: Avoid N+1 queries, use proper indexing\n- **Algorithms**: Appropriate time/space complexity for the use case\n- **Caching**: Utilize caching for expensive or repeated operations\n- **Resource Management**: Proper cleanup of connections, files, streams\n- **Pagination**: Large result sets should be paginated\n- **Lazy Loading**: Load data only when needed\n\n### Examples\n```python\n# ❌ BAD: N+1 query problem\nusers = User.query.all()\nfor user in users:\n    orders = Order.query.filter_by(user_id=user.id).all()  # N+1!\n\n# ✅ GOOD: Use JOIN or eager loading\nusers = User.query.options(joinedload(User.orders)).all()\nfor user in users:\n    orders = user.orders\n```\n\n## Architecture and Design\n\nWhen performing a code review, verify architectural principles:\n\n- **Separation of Concerns**: Clear boundaries between layers/modules\n- **Dependency Direction**: High-level modules don't depend on low-level details\n- **Interface Segregation**: Prefer small, focused interfaces\n- **Loose Coupling**: Components should be independently testable\n- **High Cohesion**: Related functionality grouped together\n- **Consistent Patterns**: Follow established patterns in the codebase\n\n## Documentation Standards\n\nWhen performing a code review, check documentation:\n\n- **API Documentation**: Public APIs must be documented (purpose, parameters, returns)\n- **Complex Logic**: Non-obvious logic should have explanatory comments\n- **README Updates**: Update README when adding features or changing setup\n- **Breaking Changes**: Document any breaking changes clearly\n- **Examples**: Provide usage examples for complex features\n\n## Comment Format Template\n\nWhen performing a code review, use this format for comments:\n\n```markdown\n**[PRIORITY] Category: Brief title**\n\nDetailed description of the issue or suggestion.\n\n**Why this matters:**\nExplanation of the impact or reason for the suggestion.\n\n**Suggested fix:**\n[code example if applicable]\n\n**Reference:** [link to relevant documentation or standard]\n```\n\n### Example Comments\n\n#### Critical Issue\n````markdown\n**🔴 CRITICAL - Security: SQL Injection Vulnerability**\n\nThe query on line 45 concatenates user input directly into the SQL string,\ncreating a SQL injection vulnerability.\n\n**Why this matters:**\nAn attacker could manipulate the email parameter to execute arbitrary SQL commands,\npotentially exposing or deleting all database data.\n\n**Suggested fix:**\n```sql\n-- Instead of:\nquery = \"SELECT * FROM users WHERE email = '\" + email + \"'\"\n\n-- Use:\nPreparedStatement stmt = conn.prepareStatement(\n    \"SELECT * FROM users WHERE email = ?\"\n);\nstmt.setString(1, email);\n```\n\n**Reference:** OWASP SQL Injection Prevention Cheat Sheet\n````\n\n#### Important Issue\n````markdown\n**🟡 IMPORTANT - Testing: Missing test coverage for critical path**\n\nThe `processPayment()` function handles financial transactions but has no tests\nfor the refund scenario.\n\n**Why this matters:**\nRefunds involve money movement and should be thoroughly tested to prevent\nfinancial errors or data inconsistencies.\n\n**Suggested fix:**\nAdd test case:\n```javascript\ntest('should process full refund when order is cancelled', () =\u003e {\n    const order = createOrder({ total: 100, status: 'cancelled' });\n\n    const result = processPayment(order, { type: 'refund' });\n\n    expect(result.refundAmount).toBe(100);\n    expect(result.status).toBe('refunded');\n});\n```\n````\n\n#### Suggestion\n````markdown\n**🟢 SUGGESTION - Readability: Simplify nested conditionals**\n\nThe nested if statements on lines 30-40 make the logic hard to follow.\n\n**Why this matters:**\nSimpler code is easier to maintain, debug, and test.\n\n**Suggested fix:**\n```javascript\n// Instead of nested ifs:\nif (user) {\n    if (user.isActive) {\n        if (user.hasPermission('write')) {\n            // do something\n        }\n    }\n}\n\n// Consider guard clauses:\nif (!user || !user.isActive || !user.hasPermission('write')) {\n    return;\n}\n// do something\n```\n````\n\n## Review Checklist\n\nWhen performing a code review, systematically verify:\n\n### Code Quality\n- [ ] Code follows consistent style and conventions\n- [ ] Names are descriptive and follow naming conventions\n- [ ] Functions/methods are small and focused\n- [ ] No code duplication\n- [ ] Complex logic is broken into simpler parts\n- [ ] Error handling is appropriate\n- [ ] No commented-out code or TODO without tickets\n\n### Security\n- [ ] No sensitive data in code or logs\n- [ ] Input validation on all user inputs\n- [ ] No SQL injection vulnerabilities\n- [ ] Authentication and authorization properly implemented\n- [ ] Dependencies are up-to-date and secure\n\n### Testing\n- [ ] New code has appropriate test coverage\n- [ ] Tests are well-named and focused\n- [ ] Tests cover edge cases and error scenarios\n- [ ] Tests are independent and deterministic\n- [ ] No tests that always pass or are commented out\n\n### Performance\n- [ ] No obvious performance issues (N+1, memory leaks)\n- [ ] Appropriate use of caching\n- [ ] Efficient algorithms and data structures\n- [ ] Proper resource cleanup\n\n### Architecture\n- [ ] Follows established patterns and conventions\n- [ ] Proper separation of concerns\n- [ ] No architectural violations\n- [ ] Dependencies flow in correct direction\n\n### Documentation\n- [ ] Public APIs are documented\n- [ ] Complex logic has explanatory comments\n- [ ] README is updated if needed\n- [ ] Breaking changes are documented\n\n## Project-Specific Customizations\n\nTo customize this template for your project, add sections for:\n\n1. **Language/Framework specific checks**\n   - Example: \"When performing a code review, verify React hooks follow rules of hooks\"\n   - Example: \"When performing a code review, check Spring Boot controllers use proper annotations\"\n\n2. **Build and deployment**\n   - Example: \"When performing a code review, verify CI/CD pipeline configuration is correct\"\n   - Example: \"When performing a code review, check database migrations are reversible\"\n\n3. **Business logic rules**\n   - Example: \"When performing a code review, verify pricing calculations include all applicable taxes\"\n   - Example: \"When performing a code review, check user consent is obtained before data processing\"\n\n4. **Team conventions**\n   - Example: \"When performing a code review, verify commit messages follow conventional commits format\"\n   - Example: \"When performing a code review, check branch names follow pattern: type/ticket-description\"\n\n## Additional Resources\n\nFor more information on effective code reviews and GitHub Copilot customization:\n\n- [GitHub Copilot Prompt Engineering](https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering)\n- [GitHub Copilot Custom Instructions](https://code.visualstudio.com/docs/copilot/customization/custom-instructions)\n- [Awesome GitHub Copilot Repository](https://github.com/github/awesome-copilot)\n- [GitHub Code Review Guidelines](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests)\n- [Google Engineering Practices - Code Review](https://google.github.io/eng-practices/review/)\n- [OWASP Security Guidelines](https://owasp.org/)\n\n## Prompt Engineering Tips\n\nWhen performing a code review, apply these prompt engineering principles from the [GitHub Copilot documentation](https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering):\n\n1. **Start General, Then Get Specific**: Begin with high-level architecture review, then drill into implementation details\n2. **Give Examples**: Reference similar patterns in the codebase when suggesting changes\n3. **Break Complex Tasks**: Review large PRs in logical chunks (security → tests → logic → style)\n4. **Avoid Ambiguity**: Be specific about which file, line, and issue you're addressing\n5. **Indicate Relevant Code**: Reference related code that might be affected by changes\n6. **Experiment and Iterate**: If initial review misses something, review again with focused questions\n\n## Project Context\n\nThis is a generic template. Customize this section with your project-specific information:\n\n- **Tech Stack**: [e.g., Java 17, Spring Boot 3.x, PostgreSQL]\n- **Architecture**: [e.g., Hexagonal/Clean Architecture, Microservices]\n- **Build Tool**: [e.g., Gradle, Maven, npm, pip]\n- **Testing**: [e.g., JUnit 5, Jest, pytest]\n- **Code Style**: [e.g., follows Google Style Guide]\n","description":"Generic code review instructions that can be customized for any project using GitHub Copilot","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/code-review-generic.instructions.md"},"manifest":{}},"content_hash":[90,202,60,156,3,217,219,222,30,39,117,200,189,124,204,45,118,159,60,153,161,237,190,22,30,164,228,18,119,8,93,22],"trust_level":"unsigned","yanked":false}
