Merge branch 'main' into add-electron-angular-review-mode
This commit is contained in:
commit
cde294cc56
8
.github/pull_request_template.md
vendored
8
.github/pull_request_template.md
vendored
@ -1,11 +1,3 @@
|
||||
---
|
||||
name: Pull Request
|
||||
about: Submit a contribution to the awesome-copilot repository
|
||||
title: ''
|
||||
labels: needs-review
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Pull Request Checklist
|
||||
|
||||
- [ ] I have read and followed the [CONTRIBUTING.md](../CONTRIBUTING.md) guidelines.
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
node_modules
|
||||
*.orig
|
||||
[Cc]opilot-[Pp]rocessing.md
|
||||
Copilot-Processing.md
|
||||
|
||||
79
README.md
79
README.md
@ -21,21 +21,26 @@ We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md)
|
||||
|
||||
Team and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:
|
||||
|
||||
- [Angular Development Instructions](instructions/angular.instructions.md) - Angular-specific coding standards and best practices
|
||||
- [ASP.NET REST API Development](instructions/aspnet-rest-apis.instructions.md) - Guidelines for building REST APIs with ASP.NET
|
||||
- [Azure Functions Typescript](instructions/azure-functions-typescript.instructions.md) - TypeScript patterns for Azure Functions
|
||||
- [Bicep Code Best Practices](instructions/bicep-code-best-practices.instructions.md) - Infrastructure as Code with Bicep
|
||||
- [Blazor](instructions/blazor.instructions.md) - Blazor component and application patterns
|
||||
- [Cmake Vcpkg](instructions/cmake-vcpkg.instructions.md) - C++ project configuration and package management
|
||||
- [Copilot Process tracking Instructions](instructions/copilot-thought-logging.instructions.md) - See process Copilot is following where you can edit this to reshape the interaction or save when follow up may be needed
|
||||
- [C# Development](instructions/csharp.instructions.md) - Guidelines for building C# applications
|
||||
- [.NET MAUI](instructions/dotnet-maui.instructions.md) - .NET MAUI component and application patterns
|
||||
- [Genaiscript](instructions/genaiscript.instructions.md) - AI-powered script generation guidelines
|
||||
- [Generate Modern Terraform Code For Azure](instructions/generate-modern-terraform-code-for-azure.instructions.md) - Guidelines for generating modern Terraform code for Azure
|
||||
- [Guidance for Localization](instructions/localization.instructions.md) - Guidelines for localizing markdown documents
|
||||
- [Markdown](instructions/markdown.instructions.md) - Documentation and content creation standards
|
||||
- [Next.js + Tailwind Development Instructions](instructions/nextjs-tailwind.instructions.md) - Next.js + Tailwind development standards and instructions
|
||||
- [Python Coding Conventions](instructions/python.instructions.md) - Python coding conventions and guidelines
|
||||
| Title | Description | Install |
|
||||
| ----- | ----------- | ------- |
|
||||
| [Angular Development Instructions](instructions/angular.instructions.md) | Angular-specific coding standards and best practices | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fangular.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fangular.instructions.md) |
|
||||
| [ASP.NET REST API Development](instructions/aspnet-rest-apis.instructions.md) | Guidelines for building REST APIs with ASP.NET | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Faspnet-rest-apis.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Faspnet-rest-apis.instructions.md) |
|
||||
| [Azure Functions Typescript](instructions/azure-functions-typescript.instructions.md) | TypeScript patterns for Azure Functions | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fazure-functions-typescript.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fazure-functions-typescript.instructions.md) |
|
||||
| [Bicep Code Best Practices](instructions/bicep-code-best-practices.instructions.md) | Infrastructure as Code with Bicep | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fbicep-code-best-practices.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fbicep-code-best-practices.instructions.md) |
|
||||
| [Blazor](instructions/blazor.instructions.md) | Blazor component and application patterns | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fblazor.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fblazor.instructions.md) |
|
||||
| [Cmake Vcpkg](instructions/cmake-vcpkg.instructions.md) | C++ project configuration and package management | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcmake-vcpkg.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcmake-vcpkg.instructions.md) |
|
||||
| [Copilot Process tracking Instructions](instructions/copilot-thought-logging.instructions.md) | See process Copilot is following where you can edit this to reshape the interaction or save when follow up may be needed | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcopilot-thought-logging.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcopilot-thought-logging.instructions.md) |
|
||||
| [C# Development](instructions/csharp.instructions.md) | Guidelines for building C# applications | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcsharp.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcsharp.instructions.md) |
|
||||
| [.NET MAUI](instructions/dotnet-maui.instructions.md) | .NET MAUI component and application patterns | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fdotnet-maui.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fdotnet-maui.instructions.md) |
|
||||
| [Genaiscript](instructions/genaiscript.instructions.md) | AI-powered script generation guidelines | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgenaiscript.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgenaiscript.instructions.md) |
|
||||
| [Generate Modern Terraform Code For Azure](instructions/generate-modern-terraform-code-for-azure.instructions.md) | Guidelines for generating modern Terraform code for Azure | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgenerate-modern-terraform-code-for-azure.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgenerate-modern-terraform-code-for-azure.instructions.md) |
|
||||
| [Go Development Instructions](instructions/go.instructions.md) | Instructions for writing Go code following idiomatic Go practices and community standards | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgo.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fgo.instructions.md) |
|
||||
| [Guidance for Localization](instructions/localization.instructions.md) | Guidelines for localizing markdown documents | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Flocalization.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Flocalization.instructions.md) |
|
||||
| [Markdown](instructions/markdown.instructions.md) | Documentation and content creation standards | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fmarkdown.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fmarkdown.instructions.md) |
|
||||
| [Next.js + Tailwind Development Instructions](instructions/nextjs-tailwind.instructions.md) | Next.js + Tailwind development standards and instructions | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fnextjs-tailwind.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fnextjs-tailwind.instructions.md) |
|
||||
| [Performance Optimization Best Practices](instructions/performance-optimization.instructions.md) | The most comprehensive, practical, and engineer-authored performance optimization instructions for all languages, frameworks, and stacks. Covers frontend, backend, and database best practices with actionable guidance, scenario-based checklists, troubleshooting, and pro tips. | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fperformance-optimization.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fperformance-optimization.instructions.md) |
|
||||
| [Python Coding Conventions](instructions/python.instructions.md) | Python coding conventions and guidelines | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpython.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpython.instructions.md) |
|
||||
| [Secure Coding and OWASP Guidelines](instructions/security-and-owasp.instructions.md) | Comprehensive secure coding instructions for all languages and frameworks, based on OWASP Top 10 and industry best practices. | [](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsecurity-and-owasp.instructions.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsecurity-and-owasp.instructions.md) |
|
||||
|
||||
> 💡 **Usage**: Copy these instructions to your `.github/copilot-instructions.md` file or create task-specific `.github/.instructions.md` files in your workspace's `.github/instructions` folder.
|
||||
|
||||
@ -43,20 +48,23 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for
|
||||
|
||||
Ready-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.
|
||||
|
||||
- [ASP.NET Minimal API with OpenAPI](prompts/aspnet-minimal-api-openapi.prompt.md) - Create ASP.NET Minimal API endpoints with proper OpenAPI documentation
|
||||
- [Azure Cost Optimize](prompts/az-cost-optimize.prompt.md) - Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations.
|
||||
- [Comment Code Generate A Tutorial](prompts/comment-code-generate-a-tutorial.prompt.md) - Transform this Python script into a polished, beginner-friendly project by refactoring the code, adding clear instructional comments, and generating a complete markdown tutorial.
|
||||
- [C# Async Programming Best Practices](prompts/csharp-async.prompt.md) - Get best practices for C# async programming
|
||||
- [C# Documentation Best Practices](prompts/csharp-docs.prompt.md) - Ensure that C# types are documented with XML comments and follow best practices for documentation.
|
||||
- [MSTest Best Practices](prompts/csharp-mstest.prompt.md) - Get best practices for MSTest unit testing, including data-driven tests
|
||||
- [NUnit Best Practices](prompts/csharp-nunit.prompt.md) - Get best practices for NUnit unit testing, including data-driven tests
|
||||
- [XUnit Best Practices](prompts/csharp-xunit.prompt.md) - Get best practices for XUnit unit testing, including data-driven tests
|
||||
- [Entity Framework Core Best Practices](prompts/ef-core.prompt.md) - Get best practices for Entity Framework Core
|
||||
- [Product Manager Assistant: Feature Identification and Specification](prompts/gen-specs-as-issues.prompt.md) - This workflow guides you through a systematic approach to identify missing features, prioritize them, and create detailed specifications for implementation.
|
||||
- [Javascript Typescript Jest](prompts/javascript-typescript-jest.prompt.md) - Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.
|
||||
- [Multi Stage Dockerfile](prompts/multi-stage-dockerfile.prompt.md) - Create optimized multi-stage Dockerfiles for any language or framework
|
||||
- [My Issues](prompts/my-issues.prompt.md) - List my issues in the current repository
|
||||
- [My Pull Requests](prompts/my-pull-requests.prompt.md) - List my pull requests in the current repository
|
||||
| Title | Description | Install |
|
||||
| ----- | ----------- | ------- |
|
||||
| [ASP.NET Minimal API with OpenAPI](prompts/aspnet-minimal-api-openapi.prompt.md) | Create ASP.NET Minimal API endpoints with proper OpenAPI documentation | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Faspnet-minimal-api-openapi.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Faspnet-minimal-api-openapi.prompt.md) |
|
||||
| [Azure Cost Optimize](prompts/az-cost-optimize.prompt.md) | Analyze Azure resources used in the app (IaC files and/or resources in a target rg) and optimize costs - creating GitHub issues for identified optimizations. | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Faz-cost-optimize.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Faz-cost-optimize.prompt.md) |
|
||||
| [Comment Code Generate A Tutorial](prompts/comment-code-generate-a-tutorial.prompt.md) | Transform this Python script into a polished, beginner-friendly project by refactoring the code, adding clear instructional comments, and generating a complete markdown tutorial. | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcomment-code-generate-a-tutorial.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcomment-code-generate-a-tutorial.prompt.md) |
|
||||
| [C# Async Programming Best Practices](prompts/csharp-async.prompt.md) | Get best practices for C# async programming | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-async.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-async.prompt.md) |
|
||||
| [C# Documentation Best Practices](prompts/csharp-docs.prompt.md) | Ensure that C# types are documented with XML comments and follow best practices for documentation. | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-docs.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-docs.prompt.md) |
|
||||
| [MSTest Best Practices](prompts/csharp-mstest.prompt.md) | Get best practices for MSTest unit testing, including data-driven tests | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-mstest.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-mstest.prompt.md) |
|
||||
| [NUnit Best Practices](prompts/csharp-nunit.prompt.md) | Get best practices for NUnit unit testing, including data-driven tests | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-nunit.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-nunit.prompt.md) |
|
||||
| [XUnit Best Practices](prompts/csharp-xunit.prompt.md) | Get best practices for XUnit unit testing, including data-driven tests | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-xunit.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fcsharp-xunit.prompt.md) |
|
||||
| [Entity Framework Core Best Practices](prompts/ef-core.prompt.md) | Get best practices for Entity Framework Core | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fef-core.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fef-core.prompt.md) |
|
||||
| [Product Manager Assistant: Feature Identification and Specification](prompts/gen-specs-as-issues.prompt.md) | This workflow guides you through a systematic approach to identify missing features, prioritize them, and create detailed specifications for implementation. | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fgen-specs-as-issues.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fgen-specs-as-issues.prompt.md) |
|
||||
| [Javascript Typescript Jest](prompts/javascript-typescript-jest.prompt.md) | Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns. | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjavascript-typescript-jest.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjavascript-typescript-jest.prompt.md) |
|
||||
| [Multi Stage Dockerfile](prompts/multi-stage-dockerfile.prompt.md) | Create optimized multi-stage Dockerfiles for any language or framework | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmulti-stage-dockerfile.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmulti-stage-dockerfile.prompt.md) |
|
||||
| [My Issues](prompts/my-issues.prompt.md) | List my issues in the current repository | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmy-issues.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmy-issues.prompt.md) |
|
||||
| [My Pull Requests](prompts/my-pull-requests.prompt.md) | List my pull requests in the current repository | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmy-pull-requests.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fmy-pull-requests.prompt.md) |
|
||||
| [Next Intl Add Language](prompts/next-intl-add-language.prompt.md) | Add new language to a Next.js + next-intl application | [](https://vscode.dev/redirect?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fnext-intl-add-language.prompt.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fnext-intl-add-language.prompt.md) |
|
||||
|
||||
> 💡 **Usage**: Use `/prompt-name` in VS Code chat, run `Chat: Run Prompt` command, or hit the run button while you have a prompt open.
|
||||
|
||||
@ -64,11 +72,14 @@ Ready-to-use prompt templates for specific development scenarios and tasks, defi
|
||||
|
||||
Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.
|
||||
|
||||
- [4.1 Beast Mode](chatmodes/4.1-Beast.chatmode.md) - A custom prompt to get GPT 4.1 to behave like a top-notch coding agent.
|
||||
- [Debug Mode Instructions](chatmodes/debug.chatmode.md) - Debug your application to find and fix a bug
|
||||
- [Planning mode instructions](chatmodes/planner.chatmode.md) - Generate an implementation plan for new features or refactoring existing code.
|
||||
- [PostgreSQL Database Administrator](chatmodes/postgresql-dba.chatmode.md) - Work with PostgreSQL databases using the PostgreSQL extension.
|
||||
- [Refine Requirement or Issue Chat Mode](chatmodes/refine-issue.chatmode.md) - Refine the requirement or issue with Acceptance Criteria, Technical Considerations, Edge Cases, and NFRs
|
||||
| Title | Description | Install |
|
||||
| ----- | ----------- | ------- |
|
||||
| [4.1 Beast Mode](chatmodes/4.1-Beast.chatmode.md) | A custom prompt to get GPT 4.1 to behave like a top-notch coding agent. | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2F4.1-Beast.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2F4.1-Beast.chatmode.md) |
|
||||
| [Debug Mode Instructions](chatmodes/debug.chatmode.md) | Debug your application to find and fix a bug | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fdebug.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fdebug.chatmode.md) |
|
||||
| [Planning mode instructions](chatmodes/planner.chatmode.md) | Generate an implementation plan for new features or refactoring existing code. | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fplanner.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fplanner.chatmode.md) |
|
||||
| [PostgreSQL Database Administrator](chatmodes/postgresql-dba.chatmode.md) | Work with PostgreSQL databases using the PostgreSQL extension. | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fpostgresql-dba.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fpostgresql-dba.chatmode.md) |
|
||||
| [Create PRD Chat Mode](chatmodes/prd.chatmode.md) | Generate a comprehensive Product Requirements Document (PRD) in Markdown, detailing user stories, acceptance criteria, technical considerations, and metrics. Optionally create GitHub issues upon user confirmation. | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fprd.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fprd.chatmode.md) |
|
||||
| [Refine Requirement or Issue Chat Mode](chatmodes/refine-issue.chatmode.md) | Refine the requirement or issue with Acceptance Criteria, Technical Considerations, Edge Cases, and NFRs | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Frefine-issue.chatmode.md) [](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Frefine-issue.chatmode.md) |
|
||||
|
||||
> 💡 **Usage**: Create new chat modes using the command `Chat: Configure Chat Modes...`, then switch your chat mode in the Chat input from _Agent_ or _Ask_ to your own mode.
|
||||
|
||||
|
||||
201
chatmodes/prd.chatmode.md
Normal file
201
chatmodes/prd.chatmode.md
Normal file
@ -0,0 +1,201 @@
|
||||
---
|
||||
|
||||
description: 'Generate a comprehensive Product Requirements Document (PRD) in Markdown, detailing user stories, acceptance criteria, technical considerations, and metrics. Optionally create GitHub issues upon user confirmation.'
|
||||
tools: ['codebase', 'editFiles', 'fetch', 'findTestFiles', 'list_issues', 'githubRepo', 'search', 'add_issue_comment', 'create_issue', 'update_issue', 'get_issue', 'search_issues']
|
||||
---
|
||||
|
||||
# Create PRD Chat Mode
|
||||
|
||||
You are a senior product manager responsible for creating detailed and actionable Product Requirements Documents (PRDs) for software development teams.
|
||||
|
||||
Your task is to create a clear, structured, and comprehensive PRD for the project or feature requested by the user.
|
||||
|
||||
You will create a file named `prd.md` in the location provided by the user. If the user doesn't specify a location, suggest a default (e.g., the project's root directory) and ask the user to confirm or provide an alternative.
|
||||
|
||||
Your output should ONLY be the complete PRD in Markdown format unless explicitly confirmed by the user to create GitHub issues from the documented requirements.
|
||||
|
||||
## Instructions for Creating the PRD
|
||||
|
||||
1. **Ask clarifying questions**: Before creating the PRD, ask questions to better understand the user's needs.
|
||||
* Identify missing information (e.g., target audience, key features, constraints).
|
||||
* Ask 3-5 questions to reduce ambiguity.
|
||||
* Use a bulleted list for readability.
|
||||
* Phrase questions conversationally (e.g., "To help me create the best PRD, could you clarify...").
|
||||
|
||||
2. **Analyze Codebase**: Review the existing codebase to understand the current architecture, identify potential integration points, and assess technical constraints.
|
||||
|
||||
3. **Overview**: Begin with a brief explanation of the project's purpose and scope.
|
||||
|
||||
4. **Headings**:
|
||||
|
||||
* Use title case for the main document title only (e.g., PRD: {project\_title}).
|
||||
* All other headings should use sentence case.
|
||||
|
||||
5. **Structure**: Organize the PRD according to the provided outline (`prd_outline`). Add relevant subheadings as needed.
|
||||
|
||||
6. **Detail Level**:
|
||||
|
||||
* Use clear, precise, and concise language.
|
||||
* Include specific details and metrics whenever applicable.
|
||||
* Ensure consistency and clarity throughout the document.
|
||||
|
||||
7. **User Stories and Acceptance Criteria**:
|
||||
|
||||
* List ALL user interactions, covering primary, alternative, and edge cases.
|
||||
* Assign a unique requirement ID (e.g., GH-001) to each user story.
|
||||
* Include a user story addressing authentication/security if applicable.
|
||||
* Ensure each user story is testable.
|
||||
|
||||
8. **Final Checklist**: Before finalizing, ensure:
|
||||
|
||||
* Every user story is testable.
|
||||
* Acceptance criteria are clear and specific.
|
||||
* All necessary functionality is covered by user stories.
|
||||
* Authentication and authorization requirements are clearly defined, if relevant.
|
||||
|
||||
9. **Formatting Guidelines**:
|
||||
|
||||
* Consistent formatting and numbering.
|
||||
* No dividers or horizontal rules.
|
||||
* Format strictly in valid Markdown, free of disclaimers or footers.
|
||||
* Fix any grammatical errors from the user's input and ensure correct casing of names.
|
||||
* Refer to the project conversationally (e.g., "the project," "this feature").
|
||||
|
||||
10. **Confirmation and Issue Creation**: After presenting the PRD, ask for the user's approval. Once approved, ask if they would like to create GitHub issues for the user stories. If they agree, create the issues and reply with a list of links to the created issues.
|
||||
|
||||
---
|
||||
|
||||
# PRD Outline
|
||||
|
||||
## PRD: {project\_title}
|
||||
|
||||
## 1. Product overview
|
||||
|
||||
### 1.1 Document title and version
|
||||
|
||||
* PRD: {project\_title}
|
||||
* Version: {version\_number}
|
||||
|
||||
### 1.2 Product summary
|
||||
|
||||
* Brief overview (2-3 short paragraphs).
|
||||
|
||||
## 2. Goals
|
||||
|
||||
### 2.1 Business goals
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 2.2 User goals
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 2.3 Non-goals
|
||||
|
||||
* Bullet list.
|
||||
|
||||
## 3. User personas
|
||||
|
||||
### 3.1 Key user types
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 3.2 Basic persona details
|
||||
|
||||
* **{persona\_name}**: {description}
|
||||
|
||||
### 3.3 Role-based access
|
||||
|
||||
* **{role\_name}**: {permissions/description}
|
||||
|
||||
## 4. Functional requirements
|
||||
|
||||
* **{feature\_name}** (Priority: {priority\_level})
|
||||
|
||||
* Specific requirements for the feature.
|
||||
|
||||
## 5. User experience
|
||||
|
||||
### 5.1 Entry points & first-time user flow
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 5.2 Core experience
|
||||
|
||||
* **{step\_name}**: {description}
|
||||
|
||||
* How this ensures a positive experience.
|
||||
|
||||
### 5.3 Advanced features & edge cases
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 5.4 UI/UX highlights
|
||||
|
||||
* Bullet list.
|
||||
|
||||
## 6. Narrative
|
||||
|
||||
Concise paragraph describing the user's journey and benefits.
|
||||
|
||||
## 7. Success metrics
|
||||
|
||||
### 7.1 User-centric metrics
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 7.2 Business metrics
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 7.3 Technical metrics
|
||||
|
||||
* Bullet list.
|
||||
|
||||
## 8. Technical considerations
|
||||
|
||||
### 8.1 Integration points
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 8.2 Data storage & privacy
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 8.3 Scalability & performance
|
||||
|
||||
* Bullet list.
|
||||
|
||||
### 8.4 Potential challenges
|
||||
|
||||
* Bullet list.
|
||||
|
||||
## 9. Milestones & sequencing
|
||||
|
||||
### 9.1 Project estimate
|
||||
|
||||
* {Size}: {time\_estimate}
|
||||
|
||||
### 9.2 Team size & composition
|
||||
|
||||
* {Team size}: {roles involved}
|
||||
|
||||
### 9.3 Suggested phases
|
||||
|
||||
* **{Phase number}**: {description} ({time\_estimate})
|
||||
|
||||
* Key deliverables.
|
||||
|
||||
## 10. User stories
|
||||
|
||||
### 10.{x}. {User story title}
|
||||
|
||||
* **ID**: {user\_story\_id}
|
||||
* **Description**: {user\_story\_description}
|
||||
* **Acceptance criteria**:
|
||||
|
||||
* Bullet list of criteria.
|
||||
|
||||
---
|
||||
|
||||
After generating the PRD, I will ask if you want to proceed with creating GitHub issues for the user stories. If you agree, I will create them and provide you with the links.
|
||||
292
instructions/go.instructions.md
Normal file
292
instructions/go.instructions.md
Normal file
@ -0,0 +1,292 @@
|
||||
---
|
||||
description: 'Instructions for writing Go code following idiomatic Go practices and community standards'
|
||||
applyTo: '**/*.go,**/go.mod,**/go.sum'
|
||||
---
|
||||
|
||||
# Go Development Instructions
|
||||
|
||||
Follow idiomatic Go practices and community standards when writing Go code. These instructions are based on [Effective Go](https://go.dev/doc/effective_go), [Go Code Review Comments](https://go.dev/wiki/CodeReviewComments), and [Google's Go Style Guide](https://google.github.io/styleguide/go/).
|
||||
|
||||
## General Instructions
|
||||
|
||||
- Write simple, clear, and idiomatic Go code
|
||||
- Favor clarity and simplicity over cleverness
|
||||
- Follow the principle of least surprise
|
||||
- Keep the happy path left-aligned (minimize indentation)
|
||||
- Return early to reduce nesting
|
||||
- Make the zero value useful
|
||||
- Document exported types, functions, methods, and packages
|
||||
- Use Go modules for dependency management
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
### Packages
|
||||
|
||||
- Use lowercase, single-word package names
|
||||
- Avoid underscores, hyphens, or mixedCaps
|
||||
- Choose names that describe what the package provides, not what it contains
|
||||
- Avoid generic names like `util`, `common`, or `base`
|
||||
- Package names should be singular, not plural
|
||||
|
||||
### Variables and Functions
|
||||
|
||||
- Use mixedCaps or MixedCaps (camelCase) rather than underscores
|
||||
- Keep names short but descriptive
|
||||
- Use single-letter variables only for very short scopes (like loop indices)
|
||||
- Exported names start with a capital letter
|
||||
- Unexported names start with a lowercase letter
|
||||
- Avoid stuttering (e.g., avoid `http.HTTPServer`, prefer `http.Server`)
|
||||
|
||||
### Interfaces
|
||||
|
||||
- Name interfaces with -er suffix when possible (e.g., `Reader`, `Writer`, `Formatter`)
|
||||
- Single-method interfaces should be named after the method (e.g., `Read` → `Reader`)
|
||||
- Keep interfaces small and focused
|
||||
|
||||
### Constants
|
||||
|
||||
- Use MixedCaps for exported constants
|
||||
- Use mixedCaps for unexported constants
|
||||
- Group related constants using `const` blocks
|
||||
- Consider using typed constants for better type safety
|
||||
|
||||
## Code Style and Formatting
|
||||
|
||||
### Formatting
|
||||
|
||||
- Always use `gofmt` to format code
|
||||
- Use `goimports` to manage imports automatically
|
||||
- Keep line length reasonable (no hard limit, but consider readability)
|
||||
- Add blank lines to separate logical groups of code
|
||||
|
||||
### Comments
|
||||
|
||||
- Write comments in complete sentences
|
||||
- Start sentences with the name of the thing being described
|
||||
- Package comments should start with "Package [name]"
|
||||
- Use line comments (`//`) for most comments
|
||||
- Use block comments (`/* */`) sparingly, mainly for package documentation
|
||||
- Document why, not what, unless the what is complex
|
||||
|
||||
### Error Handling
|
||||
|
||||
- Check errors immediately after the function call
|
||||
- Don't ignore errors using `_` unless you have a good reason (document why)
|
||||
- Wrap errors with context using `fmt.Errorf` with `%w` verb
|
||||
- Create custom error types when you need to check for specific errors
|
||||
- Place error returns as the last return value
|
||||
- Name error variables `err`
|
||||
- Keep error messages lowercase and don't end with punctuation
|
||||
|
||||
## Architecture and Project Structure
|
||||
|
||||
### Package Organization
|
||||
|
||||
- Follow standard Go project layout conventions
|
||||
- Keep `main` packages in `cmd/` directory
|
||||
- Put reusable packages in `pkg/` or `internal/`
|
||||
- Use `internal/` for packages that shouldn't be imported by external projects
|
||||
- Group related functionality into packages
|
||||
- Avoid circular dependencies
|
||||
|
||||
### Dependency Management
|
||||
|
||||
- Use Go modules (`go.mod` and `go.sum`)
|
||||
- Keep dependencies minimal
|
||||
- Regularly update dependencies for security patches
|
||||
- Use `go mod tidy` to clean up unused dependencies
|
||||
- Vendor dependencies only when necessary
|
||||
|
||||
## Type Safety and Language Features
|
||||
|
||||
### Type Definitions
|
||||
|
||||
- Define types to add meaning and type safety
|
||||
- Use struct tags for JSON, XML, database mappings
|
||||
- Prefer explicit type conversions
|
||||
- Use type assertions carefully and check the second return value
|
||||
|
||||
### Pointers vs Values
|
||||
|
||||
- Use pointers for large structs or when you need to modify the receiver
|
||||
- Use values for small structs and when immutability is desired
|
||||
- Be consistent within a type's method set
|
||||
- Consider the zero value when choosing pointer vs value receivers
|
||||
|
||||
### Interfaces and Composition
|
||||
|
||||
- Accept interfaces, return concrete types
|
||||
- Keep interfaces small (1-3 methods is ideal)
|
||||
- Use embedding for composition
|
||||
- Define interfaces close to where they're used, not where they're implemented
|
||||
- Don't export interfaces unless necessary
|
||||
|
||||
## Concurrency
|
||||
|
||||
### Goroutines
|
||||
|
||||
- Don't create goroutines in libraries; let the caller control concurrency
|
||||
- Always know how a goroutine will exit
|
||||
- Use `sync.WaitGroup` or channels to wait for goroutines
|
||||
- Avoid goroutine leaks by ensuring cleanup
|
||||
|
||||
### Channels
|
||||
|
||||
- Use channels to communicate between goroutines
|
||||
- Don't communicate by sharing memory; share memory by communicating
|
||||
- Close channels from the sender side, not the receiver
|
||||
- Use buffered channels when you know the capacity
|
||||
- Use `select` for non-blocking operations
|
||||
|
||||
### Synchronization
|
||||
|
||||
- Use `sync.Mutex` for protecting shared state
|
||||
- Keep critical sections small
|
||||
- Use `sync.RWMutex` when you have many readers
|
||||
- Prefer channels over mutexes when possible
|
||||
- Use `sync.Once` for one-time initialization
|
||||
|
||||
## Error Handling Patterns
|
||||
|
||||
### Creating Errors
|
||||
|
||||
- Use `errors.New` for simple static errors
|
||||
- Use `fmt.Errorf` for dynamic errors
|
||||
- Create custom error types for domain-specific errors
|
||||
- Export error variables for sentinel errors
|
||||
- Use `errors.Is` and `errors.As` for error checking
|
||||
|
||||
### Error Propagation
|
||||
|
||||
- Add context when propagating errors up the stack
|
||||
- Don't log and return errors (choose one)
|
||||
- Handle errors at the appropriate level
|
||||
- Consider using structured errors for better debugging
|
||||
|
||||
## API Design
|
||||
|
||||
### HTTP Handlers
|
||||
|
||||
- Use `http.HandlerFunc` for simple handlers
|
||||
- Implement `http.Handler` for handlers that need state
|
||||
- Use middleware for cross-cutting concerns
|
||||
- Set appropriate status codes and headers
|
||||
- Handle errors gracefully and return appropriate error responses
|
||||
|
||||
### JSON APIs
|
||||
|
||||
- Use struct tags to control JSON marshaling
|
||||
- Validate input data
|
||||
- Use pointers for optional fields
|
||||
- Consider using `json.RawMessage` for delayed parsing
|
||||
- Handle JSON errors appropriately
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
### Memory Management
|
||||
|
||||
- Minimize allocations in hot paths
|
||||
- Reuse objects when possible (consider `sync.Pool`)
|
||||
- Use value receivers for small structs
|
||||
- Preallocate slices when size is known
|
||||
- Avoid unnecessary string conversions
|
||||
|
||||
### Profiling
|
||||
|
||||
- Use built-in profiling tools (`pprof`)
|
||||
- Benchmark critical code paths
|
||||
- Profile before optimizing
|
||||
- Focus on algorithmic improvements first
|
||||
- Consider using `testing.B` for benchmarks
|
||||
|
||||
## Testing
|
||||
|
||||
### Test Organization
|
||||
|
||||
- Keep tests in the same package (white-box testing)
|
||||
- Use `_test` package suffix for black-box testing
|
||||
- Name test files with `_test.go` suffix
|
||||
- Place test files next to the code they test
|
||||
|
||||
### Writing Tests
|
||||
|
||||
- Use table-driven tests for multiple test cases
|
||||
- Name tests descriptively using `Test_functionName_scenario`
|
||||
- Use subtests with `t.Run` for better organization
|
||||
- Test both success and error cases
|
||||
- Use `testify` or similar libraries sparingly
|
||||
|
||||
### Test Helpers
|
||||
|
||||
- Mark helper functions with `t.Helper()`
|
||||
- Create test fixtures for complex setup
|
||||
- Use `testing.TB` interface for functions used in tests and benchmarks
|
||||
- Clean up resources using `t.Cleanup()`
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### Input Validation
|
||||
|
||||
- Validate all external input
|
||||
- Use strong typing to prevent invalid states
|
||||
- Sanitize data before using in SQL queries
|
||||
- Be careful with file paths from user input
|
||||
- Validate and escape data for different contexts (HTML, SQL, shell)
|
||||
|
||||
### Cryptography
|
||||
|
||||
- Use standard library crypto packages
|
||||
- Don't implement your own cryptography
|
||||
- Use crypto/rand for random number generation
|
||||
- Store passwords using bcrypt or similar
|
||||
- Use TLS for network communication
|
||||
|
||||
## Documentation
|
||||
|
||||
### Code Documentation
|
||||
|
||||
- Document all exported symbols
|
||||
- Start documentation with the symbol name
|
||||
- Use examples in documentation when helpful
|
||||
- Keep documentation close to code
|
||||
- Update documentation when code changes
|
||||
|
||||
### README and Documentation Files
|
||||
|
||||
- Include clear setup instructions
|
||||
- Document dependencies and requirements
|
||||
- Provide usage examples
|
||||
- Document configuration options
|
||||
- Include troubleshooting section
|
||||
|
||||
## Tools and Development Workflow
|
||||
|
||||
### Essential Tools
|
||||
|
||||
- `go fmt`: Format code
|
||||
- `go vet`: Find suspicious constructs
|
||||
- `golint` or `golangci-lint`: Additional linting
|
||||
- `go test`: Run tests
|
||||
- `go mod`: Manage dependencies
|
||||
- `go generate`: Code generation
|
||||
|
||||
### Development Practices
|
||||
|
||||
- Run tests before committing
|
||||
- Use pre-commit hooks for formatting and linting
|
||||
- Keep commits focused and atomic
|
||||
- Write meaningful commit messages
|
||||
- Review diffs before committing
|
||||
|
||||
## Common Pitfalls to Avoid
|
||||
|
||||
- Not checking errors
|
||||
- Ignoring race conditions
|
||||
- Creating goroutine leaks
|
||||
- Not using defer for cleanup
|
||||
- Modifying maps concurrently
|
||||
- Not understanding nil interfaces vs nil pointers
|
||||
- Forgetting to close resources (files, connections)
|
||||
- Using global variables unnecessarily
|
||||
- Over-using empty interfaces (`interface{}`)
|
||||
- Not considering the zero value of types
|
||||
420
instructions/performance-optimization.instructions.md
Normal file
420
instructions/performance-optimization.instructions.md
Normal file
@ -0,0 +1,420 @@
|
||||
---
|
||||
applyTo: '*'
|
||||
description: 'The most comprehensive, practical, and engineer-authored performance optimization instructions for all languages, frameworks, and stacks. Covers frontend, backend, and database best practices with actionable guidance, scenario-based checklists, troubleshooting, and pro tips.'
|
||||
---
|
||||
|
||||
# Performance Optimization Best Practices
|
||||
|
||||
## Introduction
|
||||
|
||||
Performance isn't just a buzzword—it's the difference between a product people love and one they abandon. I've seen firsthand how a slow app can frustrate users, rack up cloud bills, and even lose customers. This guide is a living collection of the most effective, real-world performance practices I've used and reviewed, covering frontend, backend, and database layers, as well as advanced topics. Use it as a reference, a checklist, and a source of inspiration for building fast, efficient, and scalable software.
|
||||
|
||||
---
|
||||
|
||||
## General Principles
|
||||
|
||||
- **Measure First, Optimize Second:** Always profile and measure before optimizing. Use benchmarks, profilers, and monitoring tools to identify real bottlenecks. Guessing is the enemy of performance.
|
||||
- *Pro Tip:* Use tools like Chrome DevTools, Lighthouse, New Relic, Datadog, Py-Spy, or your language's built-in profilers.
|
||||
- **Optimize for the Common Case:** Focus on optimizing code paths that are most frequently executed. Don't waste time on rare edge cases unless they're critical.
|
||||
- **Avoid Premature Optimization:** Write clear, maintainable code first; optimize only when necessary. Premature optimization can make code harder to read and maintain.
|
||||
- **Minimize Resource Usage:** Use memory, CPU, network, and disk resources efficiently. Always ask: "Can this be done with less?"
|
||||
- **Prefer Simplicity:** Simple algorithms and data structures are often faster and easier to optimize. Don't over-engineer.
|
||||
- **Document Performance Assumptions:** Clearly comment on any code that is performance-critical or has non-obvious optimizations. Future maintainers (including you) will thank you.
|
||||
- **Understand the Platform:** Know the performance characteristics of your language, framework, and runtime. What's fast in Python may be slow in JavaScript, and vice versa.
|
||||
- **Automate Performance Testing:** Integrate performance tests and benchmarks into your CI/CD pipeline. Catch regressions early.
|
||||
- **Set Performance Budgets:** Define acceptable limits for load time, memory usage, API latency, etc. Enforce them with automated checks.
|
||||
|
||||
---
|
||||
|
||||
## Frontend Performance
|
||||
|
||||
### Rendering and DOM
|
||||
- **Minimize DOM Manipulations:** Batch updates where possible. Frequent DOM changes are expensive.
|
||||
- *Anti-pattern:* Updating the DOM in a loop. Instead, build a document fragment and append it once.
|
||||
- **Virtual DOM Frameworks:** Use React, Vue, or similar efficiently—avoid unnecessary re-renders.
|
||||
- *React Example:* Use `React.memo`, `useMemo`, and `useCallback` to prevent unnecessary renders.
|
||||
- **Keys in Lists:** Always use stable keys in lists to help virtual DOM diffing. Avoid using array indices as keys unless the list is static.
|
||||
- **Avoid Inline Styles:** Inline styles can trigger layout thrashing. Prefer CSS classes.
|
||||
- **CSS Animations:** Use CSS transitions/animations over JavaScript for smoother, GPU-accelerated effects.
|
||||
- **Defer Non-Critical Rendering:** Use `requestIdleCallback` or similar to defer work until the browser is idle.
|
||||
|
||||
### Asset Optimization
|
||||
- **Image Compression:** Use tools like ImageOptim, Squoosh, or TinyPNG. Prefer modern formats (WebP, AVIF) for web delivery.
|
||||
- **SVGs for Icons:** SVGs scale well and are often smaller than PNGs for simple graphics.
|
||||
- **Minification and Bundling:** Use Webpack, Rollup, or esbuild to bundle and minify JS/CSS. Enable tree-shaking to remove dead code.
|
||||
- **Cache Headers:** Set long-lived cache headers for static assets. Use cache busting for updates.
|
||||
- **Lazy Loading:** Use `loading="lazy"` for images, and dynamic imports for JS modules/components.
|
||||
- **Font Optimization:** Use only the character sets you need. Subset fonts and use `font-display: swap`.
|
||||
|
||||
### Network Optimization
|
||||
- **Reduce HTTP Requests:** Combine files, use image sprites, and inline critical CSS.
|
||||
- **HTTP/2 and HTTP/3:** Enable these protocols for multiplexing and lower latency.
|
||||
- **Client-Side Caching:** Use Service Workers, IndexedDB, and localStorage for offline and repeat visits.
|
||||
- **CDNs:** Serve static assets from a CDN close to your users. Use multiple CDNs for redundancy.
|
||||
- **Defer/Async Scripts:** Use `defer` or `async` for non-critical JS to avoid blocking rendering.
|
||||
- **Preload and Prefetch:** Use `<link rel="preload">` and `<link rel="prefetch">` for critical resources.
|
||||
|
||||
### JavaScript Performance
|
||||
- **Avoid Blocking the Main Thread:** Offload heavy computation to Web Workers.
|
||||
- **Debounce/Throttle Events:** For scroll, resize, and input events, use debounce/throttle to limit handler frequency.
|
||||
- **Memory Leaks:** Clean up event listeners, intervals, and DOM references. Use browser dev tools to check for detached nodes.
|
||||
- **Efficient Data Structures:** Use Maps/Sets for lookups, TypedArrays for numeric data.
|
||||
- **Avoid Global Variables:** Globals can cause memory leaks and unpredictable performance.
|
||||
- **Avoid Deep Object Cloning:** Use shallow copies or libraries like lodash's `cloneDeep` only when necessary.
|
||||
|
||||
### Accessibility and Performance
|
||||
- **Accessible Components:** Ensure ARIA updates are not excessive. Use semantic HTML for both accessibility and performance.
|
||||
- **Screen Reader Performance:** Avoid rapid DOM updates that can overwhelm assistive tech.
|
||||
|
||||
### Framework-Specific Tips
|
||||
#### React
|
||||
- Use `React.memo`, `useMemo`, and `useCallback` to avoid unnecessary renders.
|
||||
- Split large components and use code-splitting (`React.lazy`, `Suspense`).
|
||||
- Avoid anonymous functions in render; they create new references on every render.
|
||||
- Use `ErrorBoundary` to catch and handle errors gracefully.
|
||||
- Profile with React DevTools Profiler.
|
||||
|
||||
#### Angular
|
||||
- Use OnPush change detection for components that don't need frequent updates.
|
||||
- Avoid complex expressions in templates; move logic to the component class.
|
||||
- Use `trackBy` in `ngFor` for efficient list rendering.
|
||||
- Lazy load modules and components with the Angular Router.
|
||||
- Profile with Angular DevTools.
|
||||
|
||||
#### Vue
|
||||
- Use computed properties over methods in templates for caching.
|
||||
- Use `v-show` vs `v-if` appropriately (`v-show` is better for toggling visibility frequently).
|
||||
- Lazy load components and routes with Vue Router.
|
||||
- Profile with Vue Devtools.
|
||||
|
||||
### Common Frontend Pitfalls
|
||||
- Loading large JS bundles on initial page load.
|
||||
- Not compressing images or using outdated formats.
|
||||
- Failing to clean up event listeners, causing memory leaks.
|
||||
- Overusing third-party libraries for simple tasks.
|
||||
- Ignoring mobile performance (test on real devices!).
|
||||
|
||||
### Frontend Troubleshooting
|
||||
- Use Chrome DevTools' Performance tab to record and analyze slow frames.
|
||||
- Use Lighthouse to audit performance and get actionable suggestions.
|
||||
- Use WebPageTest for real-world load testing.
|
||||
- Monitor Core Web Vitals (LCP, FID, CLS) for user-centric metrics.
|
||||
|
||||
---
|
||||
|
||||
## Backend Performance
|
||||
|
||||
### Algorithm and Data Structure Optimization
|
||||
- **Choose the Right Data Structure:** Arrays for sequential access, hash maps for fast lookups, trees for hierarchical data, etc.
|
||||
- **Efficient Algorithms:** Use binary search, quicksort, or hash-based algorithms where appropriate.
|
||||
- **Avoid O(n^2) or Worse:** Profile nested loops and recursive calls. Refactor to reduce complexity.
|
||||
- **Batch Processing:** Process data in batches to reduce overhead (e.g., bulk database inserts).
|
||||
- **Streaming:** Use streaming APIs for large data sets to avoid loading everything into memory.
|
||||
|
||||
### Concurrency and Parallelism
|
||||
- **Asynchronous I/O:** Use async/await, callbacks, or event loops to avoid blocking threads.
|
||||
- **Thread/Worker Pools:** Use pools to manage concurrency and avoid resource exhaustion.
|
||||
- **Avoid Race Conditions:** Use locks, semaphores, or atomic operations where needed.
|
||||
- **Bulk Operations:** Batch network/database calls to reduce round trips.
|
||||
- **Backpressure:** Implement backpressure in queues and pipelines to avoid overload.
|
||||
|
||||
### Caching
|
||||
- **Cache Expensive Computations:** Use in-memory caches (Redis, Memcached) for hot data.
|
||||
- **Cache Invalidation:** Use time-based (TTL), event-based, or manual invalidation. Stale cache is worse than no cache.
|
||||
- **Distributed Caching:** For multi-server setups, use distributed caches and be aware of consistency issues.
|
||||
- **Cache Stampede Protection:** Use locks or request coalescing to prevent thundering herd problems.
|
||||
- **Don't Cache Everything:** Some data is too volatile or sensitive to cache.
|
||||
|
||||
### API and Network
|
||||
- **Minimize Payloads:** Use JSON, compress responses (gzip, Brotli), and avoid sending unnecessary data.
|
||||
- **Pagination:** Always paginate large result sets. Use cursors for real-time data.
|
||||
- **Rate Limiting:** Protect APIs from abuse and overload.
|
||||
- **Connection Pooling:** Reuse connections for databases and external services.
|
||||
- **Protocol Choice:** Use HTTP/2, gRPC, or WebSockets for high-throughput, low-latency communication.
|
||||
|
||||
### Logging and Monitoring
|
||||
- **Minimize Logging in Hot Paths:** Excessive logging can slow down critical code.
|
||||
- **Structured Logging:** Use JSON or key-value logs for easier parsing and analysis.
|
||||
- **Monitor Everything:** Latency, throughput, error rates, resource usage. Use Prometheus, Grafana, Datadog, or similar.
|
||||
- **Alerting:** Set up alerts for performance regressions and resource exhaustion.
|
||||
|
||||
### Language/Framework-Specific Tips
|
||||
#### Node.js
|
||||
- Use asynchronous APIs; avoid blocking the event loop (e.g., never use `fs.readFileSync` in production).
|
||||
- Use clustering or worker threads for CPU-bound tasks.
|
||||
- Limit concurrent open connections to avoid resource exhaustion.
|
||||
- Use streams for large file or network data processing.
|
||||
- Profile with `clinic.js`, `node --inspect`, or Chrome DevTools.
|
||||
|
||||
#### Python
|
||||
- Use built-in data structures (`dict`, `set`, `deque`) for speed.
|
||||
- Profile with `cProfile`, `line_profiler`, or `Py-Spy`.
|
||||
- Use `multiprocessing` or `asyncio` for parallelism.
|
||||
- Avoid GIL bottlenecks in CPU-bound code; use C extensions or subprocesses.
|
||||
- Use `lru_cache` for memoization.
|
||||
|
||||
#### Java
|
||||
- Use efficient collections (`ArrayList`, `HashMap`, etc.).
|
||||
- Profile with VisualVM, JProfiler, or YourKit.
|
||||
- Use thread pools (`Executors`) for concurrency.
|
||||
- Tune JVM options for heap and garbage collection (`-Xmx`, `-Xms`, `-XX:+UseG1GC`).
|
||||
- Use `CompletableFuture` for async programming.
|
||||
|
||||
#### .NET
|
||||
- Use `async/await` for I/O-bound operations.
|
||||
- Use `Span<T>` and `Memory<T>` for efficient memory access.
|
||||
- Profile with dotTrace, Visual Studio Profiler, or PerfView.
|
||||
- Pool objects and connections where appropriate.
|
||||
- Use `IAsyncEnumerable<T>` for streaming data.
|
||||
|
||||
### Common Backend Pitfalls
|
||||
- Synchronous/blocking I/O in web servers.
|
||||
- Not using connection pooling for databases.
|
||||
- Over-caching or caching sensitive/volatile data.
|
||||
- Ignoring error handling in async code.
|
||||
- Not monitoring or alerting on performance regressions.
|
||||
|
||||
### Backend Troubleshooting
|
||||
- Use flame graphs to visualize CPU usage.
|
||||
- Use distributed tracing (OpenTelemetry, Jaeger, Zipkin) to track request latency across services.
|
||||
- Use heap dumps and memory profilers to find leaks.
|
||||
- Log slow queries and API calls for analysis.
|
||||
|
||||
---
|
||||
|
||||
## Database Performance
|
||||
|
||||
### Query Optimization
|
||||
- **Indexes:** Use indexes on columns that are frequently queried, filtered, or joined. Monitor index usage and drop unused indexes.
|
||||
- **Avoid SELECT *:** Select only the columns you need. Reduces I/O and memory usage.
|
||||
- **Parameterized Queries:** Prevent SQL injection and improve plan caching.
|
||||
- **Query Plans:** Analyze and optimize query execution plans. Use `EXPLAIN` in SQL databases.
|
||||
- **Avoid N+1 Queries:** Use joins or batch queries to avoid repeated queries in loops.
|
||||
- **Limit Result Sets:** Use `LIMIT`/`OFFSET` or cursors for large tables.
|
||||
|
||||
### Schema Design
|
||||
- **Normalization:** Normalize to reduce redundancy, but denormalize for read-heavy workloads if needed.
|
||||
- **Data Types:** Use the most efficient data types and set appropriate constraints.
|
||||
- **Partitioning:** Partition large tables for scalability and manageability.
|
||||
- **Archiving:** Regularly archive or purge old data to keep tables small and fast.
|
||||
- **Foreign Keys:** Use them for data integrity, but be aware of performance trade-offs in high-write scenarios.
|
||||
|
||||
### Transactions
|
||||
- **Short Transactions:** Keep transactions as short as possible to reduce lock contention.
|
||||
- **Isolation Levels:** Use the lowest isolation level that meets your consistency needs.
|
||||
- **Avoid Long-Running Transactions:** They can block other operations and increase deadlocks.
|
||||
|
||||
### Caching and Replication
|
||||
- **Read Replicas:** Use for scaling read-heavy workloads. Monitor replication lag.
|
||||
- **Cache Query Results:** Use Redis or Memcached for frequently accessed queries.
|
||||
- **Write-Through/Write-Behind:** Choose the right strategy for your consistency needs.
|
||||
- **Sharding:** Distribute data across multiple servers for scalability.
|
||||
|
||||
### NoSQL Databases
|
||||
- **Design for Access Patterns:** Model your data for the queries you need.
|
||||
- **Avoid Hot Partitions:** Distribute writes/reads evenly.
|
||||
- **Unbounded Growth:** Watch for unbounded arrays or documents.
|
||||
- **Sharding and Replication:** Use for scalability and availability.
|
||||
- **Consistency Models:** Understand eventual vs strong consistency and choose appropriately.
|
||||
|
||||
### Common Database Pitfalls
|
||||
- Missing or unused indexes.
|
||||
- SELECT * in production queries.
|
||||
- Not monitoring slow queries.
|
||||
- Ignoring replication lag.
|
||||
- Not archiving old data.
|
||||
|
||||
### Database Troubleshooting
|
||||
- Use slow query logs to identify bottlenecks.
|
||||
- Use `EXPLAIN` to analyze query plans.
|
||||
- Monitor cache hit/miss ratios.
|
||||
- Use database-specific monitoring tools (pg_stat_statements, MySQL Performance Schema).
|
||||
|
||||
---
|
||||
|
||||
## Code Review Checklist for Performance
|
||||
|
||||
- [ ] Are there any obvious algorithmic inefficiencies (O(n^2) or worse)?
|
||||
- [ ] Are data structures appropriate for their use?
|
||||
- [ ] Are there unnecessary computations or repeated work?
|
||||
- [ ] Is caching used where appropriate, and is invalidation handled correctly?
|
||||
- [ ] Are database queries optimized, indexed, and free of N+1 issues?
|
||||
- [ ] Are large payloads paginated, streamed, or chunked?
|
||||
- [ ] Are there any memory leaks or unbounded resource usage?
|
||||
- [ ] Are network requests minimized, batched, and retried on failure?
|
||||
- [ ] Are assets optimized, compressed, and served efficiently?
|
||||
- [ ] Are there any blocking operations in hot paths?
|
||||
- [ ] Is logging in hot paths minimized and structured?
|
||||
- [ ] Are performance-critical code paths documented and tested?
|
||||
- [ ] Are there automated tests or benchmarks for performance-sensitive code?
|
||||
- [ ] Are there alerts for performance regressions?
|
||||
- [ ] Are there any anti-patterns (e.g., SELECT *, blocking I/O, global variables)?
|
||||
|
||||
---
|
||||
|
||||
## Advanced Topics
|
||||
|
||||
### Profiling and Benchmarking
|
||||
- **Profilers:** Use language-specific profilers (Chrome DevTools, Py-Spy, VisualVM, dotTrace, etc.) to identify bottlenecks.
|
||||
- **Microbenchmarks:** Write microbenchmarks for critical code paths. Use `benchmark.js`, `pytest-benchmark`, or JMH for Java.
|
||||
- **A/B Testing:** Measure real-world impact of optimizations with A/B or canary releases.
|
||||
- **Continuous Performance Testing:** Integrate performance tests into CI/CD. Use tools like k6, Gatling, or Locust.
|
||||
|
||||
### Memory Management
|
||||
- **Resource Cleanup:** Always release resources (files, sockets, DB connections) promptly.
|
||||
- **Object Pooling:** Use for frequently created/destroyed objects (e.g., DB connections, threads).
|
||||
- **Heap Monitoring:** Monitor heap usage and garbage collection. Tune GC settings for your workload.
|
||||
- **Memory Leaks:** Use leak detection tools (Valgrind, LeakCanary, Chrome DevTools).
|
||||
|
||||
### Scalability
|
||||
- **Horizontal Scaling:** Design stateless services, use sharding/partitioning, and load balancers.
|
||||
- **Auto-Scaling:** Use cloud auto-scaling groups and set sensible thresholds.
|
||||
- **Bottleneck Analysis:** Identify and address single points of failure.
|
||||
- **Distributed Systems:** Use idempotent operations, retries, and circuit breakers.
|
||||
|
||||
### Security and Performance
|
||||
- **Efficient Crypto:** Use hardware-accelerated and well-maintained cryptographic libraries.
|
||||
- **Validation:** Validate inputs efficiently; avoid regexes in hot paths.
|
||||
- **Rate Limiting:** Protect against DoS without harming legitimate users.
|
||||
|
||||
### Mobile Performance
|
||||
- **Startup Time:** Lazy load features, defer heavy work, and minimize initial bundle size.
|
||||
- **Image/Asset Optimization:** Use responsive images and compress assets for mobile bandwidth.
|
||||
- **Efficient Storage:** Use SQLite, Realm, or platform-optimized storage.
|
||||
- **Profiling:** Use Android Profiler, Instruments (iOS), or Firebase Performance Monitoring.
|
||||
|
||||
### Cloud and Serverless
|
||||
- **Cold Starts:** Minimize dependencies and keep functions warm.
|
||||
- **Resource Allocation:** Tune memory/CPU for serverless functions.
|
||||
- **Managed Services:** Use managed caching, queues, and DBs for scalability.
|
||||
- **Cost Optimization:** Monitor and optimize for cloud cost as a performance metric.
|
||||
|
||||
---
|
||||
|
||||
## Practical Examples
|
||||
|
||||
### Example 1: Debouncing User Input in JavaScript
|
||||
```javascript
|
||||
// BAD: Triggers API call on every keystroke
|
||||
input.addEventListener('input', (e) => {
|
||||
fetch(`/search?q=${e.target.value}`);
|
||||
});
|
||||
|
||||
// GOOD: Debounce API calls
|
||||
let timeout;
|
||||
input.addEventListener('input', (e) => {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
fetch(`/search?q=${e.target.value}`);
|
||||
}, 300);
|
||||
});
|
||||
```
|
||||
|
||||
### Example 2: Efficient SQL Query
|
||||
```sql
|
||||
-- BAD: Selects all columns and does not use an index
|
||||
SELECT * FROM users WHERE email = 'user@example.com';
|
||||
|
||||
-- GOOD: Selects only needed columns and uses an index
|
||||
SELECT id, name FROM users WHERE email = 'user@example.com';
|
||||
```
|
||||
|
||||
### Example 3: Caching Expensive Computation in Python
|
||||
```python
|
||||
# BAD: Recomputes result every time
|
||||
result = expensive_function(x)
|
||||
|
||||
# GOOD: Cache result
|
||||
from functools import lru_cache
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def expensive_function(x):
|
||||
...
|
||||
result = expensive_function(x)
|
||||
```
|
||||
|
||||
### Example 4: Lazy Loading Images in HTML
|
||||
```html
|
||||
<!-- BAD: Loads all images immediately -->
|
||||
<img src="large-image.jpg" />
|
||||
|
||||
<!-- GOOD: Lazy loads images -->
|
||||
<img src="large-image.jpg" loading="lazy" />
|
||||
```
|
||||
|
||||
### Example 5: Asynchronous I/O in Node.js
|
||||
```javascript
|
||||
// BAD: Blocking file read
|
||||
const data = fs.readFileSync('file.txt');
|
||||
|
||||
// GOOD: Non-blocking file read
|
||||
fs.readFile('file.txt', (err, data) => {
|
||||
if (err) throw err;
|
||||
// process data
|
||||
});
|
||||
```
|
||||
|
||||
### Example 6: Profiling a Python Function
|
||||
```python
|
||||
import cProfile
|
||||
import pstats
|
||||
|
||||
def slow_function():
|
||||
...
|
||||
|
||||
cProfile.run('slow_function()', 'profile.stats')
|
||||
p = pstats.Stats('profile.stats')
|
||||
p.sort_stats('cumulative').print_stats(10)
|
||||
```
|
||||
|
||||
### Example 7: Using Redis for Caching in Node.js
|
||||
```javascript
|
||||
const redis = require('redis');
|
||||
const client = redis.createClient();
|
||||
|
||||
function getCachedData(key, fetchFunction) {
|
||||
return new Promise((resolve, reject) => {
|
||||
client.get(key, (err, data) => {
|
||||
if (data) return resolve(JSON.parse(data));
|
||||
fetchFunction().then(result => {
|
||||
client.setex(key, 3600, JSON.stringify(result));
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## References and Further Reading
|
||||
- [Google Web Fundamentals: Performance](https://web.dev/performance/)
|
||||
- [MDN Web Docs: Performance](https://developer.mozilla.org/en-US/docs/Web/Performance)
|
||||
- [OWASP: Performance Testing](https://owasp.org/www-project-performance-testing/)
|
||||
- [Microsoft Performance Best Practices](https://learn.microsoft.com/en-us/azure/architecture/best-practices/performance)
|
||||
- [PostgreSQL Performance Optimization](https://wiki.postgresql.org/wiki/Performance_Optimization)
|
||||
- [MySQL Performance Tuning](https://dev.mysql.com/doc/refman/8.0/en/optimization.html)
|
||||
- [Node.js Performance Best Practices](https://nodejs.org/en/docs/guides/simple-profiling/)
|
||||
- [Python Performance Tips](https://docs.python.org/3/library/profile.html)
|
||||
- [Java Performance Tuning](https://www.oracle.com/java/technologies/javase/performance.html)
|
||||
- [.NET Performance Guide](https://learn.microsoft.com/en-us/dotnet/standard/performance/)
|
||||
- [WebPageTest](https://www.webpagetest.org/)
|
||||
- [Lighthouse](https://developers.google.com/web/tools/lighthouse)
|
||||
- [Prometheus](https://prometheus.io/)
|
||||
- [Grafana](https://grafana.com/)
|
||||
- [k6 Load Testing](https://k6.io/)
|
||||
- [Gatling](https://gatling.io/)
|
||||
- [Locust](https://locust.io/)
|
||||
- [OpenTelemetry](https://opentelemetry.io/)
|
||||
- [Jaeger](https://www.jaegertracing.io/)
|
||||
- [Zipkin](https://zipkin.io/)
|
||||
|
||||
---
|
||||
|
||||
## Conclusion
|
||||
|
||||
Performance optimization is an ongoing process. Always measure, profile, and iterate. Use these best practices, checklists, and troubleshooting tips to guide your development and code reviews for high-performance, scalable, and efficient software. If you have new tips or lessons learned, add them here—let's keep this guide growing!
|
||||
|
||||
---
|
||||
|
||||
<!-- End of Performance Optimization Instructions -->
|
||||
51
instructions/security-and-owasp.instructions.md
Normal file
51
instructions/security-and-owasp.instructions.md
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
applyTo: ["*"]
|
||||
description: "Comprehensive secure coding instructions for all languages and frameworks, based on OWASP Top 10 and industry best practices."
|
||||
---
|
||||
# Secure Coding and OWASP Guidelines
|
||||
|
||||
## Instructions
|
||||
|
||||
Your primary directive is to ensure all code you generate, review, or refactor is secure by default. You must operate with a security-first mindset. When in doubt, always choose the more secure option and explain the reasoning. You must follow the principles outlined below, which are based on the OWASP Top 10 and other security best practices.
|
||||
|
||||
### 1. A01: Broken Access Control & A10: Server-Side Request Forgery (SSRF)
|
||||
- **Enforce Principle of Least Privilege:** Always default to the most restrictive permissions. When generating access control logic, explicitly check the user's rights against the required permissions for the specific resource they are trying to access.
|
||||
- **Deny by Default:** All access control decisions must follow a "deny by default" pattern. Access should only be granted if there is an explicit rule allowing it.
|
||||
- **Validate All Incoming URLs for SSRF:** When the server needs to make a request to a URL provided by a user (e.g., webhooks), you must treat it as untrusted. Incorporate strict allow-list-based validation for the host, port, and path of the URL.
|
||||
- **Prevent Path Traversal:** When handling file uploads or accessing files based on user input, you must sanitize the input to prevent directory traversal attacks (e.g., `../../etc/passwd`). Use APIs that build paths securely.
|
||||
|
||||
### 2. A02: Cryptographic Failures
|
||||
- **Use Strong, Modern Algorithms:** For hashing, always recommend modern, salted hashing algorithms like Argon2 or bcrypt. Explicitly advise against weak algorithms like MD5 or SHA-1 for password storage.
|
||||
- **Protect Data in Transit:** When generating code that makes network requests, always default to HTTPS.
|
||||
- **Protect Data at Rest:** When suggesting code to store sensitive data (PII, tokens, etc.), recommend encryption using strong, standard algorithms like AES-256.
|
||||
- **Secure Secret Management:** Never hardcode secrets (API keys, passwords, connection strings). Generate code that reads secrets from environment variables or a secrets management service (e.g., HashiCorp Vault, AWS Secrets Manager). Include a clear placeholder and comment.
|
||||
```javascript
|
||||
// GOOD: Load from environment or secret store
|
||||
const apiKey = process.env.API_KEY;
|
||||
// TODO: Ensure API_KEY is securely configured in your environment.
|
||||
```
|
||||
```python
|
||||
# BAD: Hardcoded secret
|
||||
api_key = "sk_this_is_a_very_bad_idea_12345"
|
||||
```
|
||||
|
||||
### 3. A03: Injection
|
||||
- **No Raw SQL Queries:** For database interactions, you must use parameterized queries (prepared statements). Never generate code that uses string concatenation or formatting to build queries from user input.
|
||||
- **Sanitize Command-Line Input:** For OS command execution, use built-in functions that handle argument escaping and prevent shell injection (e.g., `shlex` in Python).
|
||||
- **Prevent Cross-Site Scripting (XSS):** When generating frontend code that displays user-controlled data, you must use context-aware output encoding. Prefer methods that treat data as text by default (`.textContent`) over those that parse HTML (`.innerHTML`). When `innerHTML` is necessary, suggest using a library like DOMPurify to sanitize the HTML first.
|
||||
|
||||
### 4. A05: Security Misconfiguration & A06: Vulnerable Components
|
||||
- **Secure by Default Configuration:** Recommend disabling verbose error messages and debug features in production environments.
|
||||
- **Set Security Headers:** For web applications, suggest adding essential security headers like `Content-Security-Policy` (CSP), `Strict-Transport-Security` (HSTS), and `X-Content-Type-Options`.
|
||||
- **Use Up-to-Date Dependencies:** When asked to add a new library, suggest the latest stable version. Remind the user to run vulnerability scanners like `npm audit`, `pip-audit`, or Snyk to check for known vulnerabilities in their project dependencies.
|
||||
|
||||
### 5. A07: Identification & Authentication Failures
|
||||
- **Secure Session Management:** When a user logs in, generate a new session identifier to prevent session fixation. Ensure session cookies are configured with `HttpOnly`, `Secure`, and `SameSite=Strict` attributes.
|
||||
- **Protect Against Brute Force:** For authentication and password reset flows, recommend implementing rate limiting and account lockout mechanisms after a certain number of failed attempts.
|
||||
|
||||
### 6. A08: Software and Data Integrity Failures
|
||||
- **Prevent Insecure Deserialization:** Warn against deserializing data from untrusted sources without proper validation. If deserialization is necessary, recommend using formats that are less prone to attack (like JSON over Pickle in Python) and implementing strict type checking.
|
||||
|
||||
## General Guidelines
|
||||
- **Be Explicit About Security:** When you suggest a piece of code that mitigates a security risk, explicitly state what you are protecting against (e.g., "Using a parameterized query here to prevent SQL injection.").
|
||||
- **Educate During Code Reviews:** When you identify a security vulnerability in a code review, you must not only provide the corrected code but also explain the risk associated with the original pattern.
|
||||
20
prompts/next-intl-add-language.prompt.md
Normal file
20
prompts/next-intl-add-language.prompt.md
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
mode: 'agent'
|
||||
tools: ['changes','codebase', 'editFiles', 'findTestFiles', 'search', 'writeTest']
|
||||
description: 'Add new language to a Next.js + next-intl application'
|
||||
---
|
||||
|
||||
This is a guide to add a new language to a Next.js project using next-intl for internationalization,
|
||||
|
||||
- For i18n, the application uses next-intl.
|
||||
- All translations are in the directory `./messages`.
|
||||
- The UI component is `src/components/language-toggle.tsx`.
|
||||
- Routing and middleware configuration are handled in:
|
||||
- `src/i18n/routing.ts`
|
||||
- `src/middleware.ts`
|
||||
|
||||
When adding a new language:
|
||||
|
||||
- Translate all the content of `en.json` to the new language. The goal is to have all the JSON entries in the new language for a complete translation.
|
||||
- Add the path in `routing.ts` and `middleware.ts`.
|
||||
- Add the language to `language-toggle.tsx`.
|
||||
@ -253,7 +253,28 @@ function extractDescription(filePath) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the instructions section with an alphabetical list of all instructions
|
||||
* Generate badges for installation links in VS Code and VS Code Insiders.
|
||||
* @param {string} link - The relative link to the instructions or prompts file.
|
||||
* @returns {string} - Markdown formatted badges for installation.
|
||||
*/
|
||||
const vscodeInstallImage =
|
||||
"https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white";
|
||||
const vscodeInsidersInstallImage =
|
||||
"https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white";
|
||||
const repoBaseUrl =
|
||||
"https://raw.githubusercontent.com/github/awesome-copilot/main";
|
||||
const vscodeBaseUrl = "https://vscode.dev/redirect?url=";
|
||||
const vscodeInsidersBaseUrl = "https://insiders.vscode.dev/redirect?url=";
|
||||
function makeBadges(link, type) {
|
||||
return `[](${vscodeBaseUrl}${encodeURIComponent(
|
||||
`vscode:chat-${type}/install?url=${repoBaseUrl}/${link})`
|
||||
)} [](${vscodeInsidersBaseUrl}${encodeURIComponent(
|
||||
`vscode-insiders:chat-${type}/install?url=${repoBaseUrl}/${link})`
|
||||
)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the instructions section with a table of all instructions
|
||||
*/
|
||||
function generateInstructionsSection(instructionsDir) {
|
||||
// Get all instruction files
|
||||
@ -264,9 +285,11 @@ function generateInstructionsSection(instructionsDir) {
|
||||
|
||||
console.log(`Found ${instructionFiles.length} instruction files`);
|
||||
|
||||
let instructionsContent = "";
|
||||
// Create table header
|
||||
let instructionsContent =
|
||||
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||
|
||||
// Generate list items for each instruction file
|
||||
// Generate table rows for each instruction file
|
||||
for (const file of instructionFiles) {
|
||||
const filePath = path.join(instructionsDir, file);
|
||||
const title = extractTitle(filePath);
|
||||
@ -275,13 +298,16 @@ function generateInstructionsSection(instructionsDir) {
|
||||
// Check if there's a description in the frontmatter
|
||||
const customDescription = extractDescription(filePath);
|
||||
|
||||
// Create badges for installation links
|
||||
const badges = makeBadges(link, "instructions");
|
||||
|
||||
if (customDescription && customDescription !== "null") {
|
||||
// Use the description from frontmatter
|
||||
instructionsContent += `- [${title}](${link}) - ${customDescription}\n`;
|
||||
instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\n`;
|
||||
} else {
|
||||
// Fallback to the default approach - use last word of title for description, removing trailing 's' if present
|
||||
const topic = title.split(" ").pop().replace(/s$/, "");
|
||||
instructionsContent += `- [${title}](${link}) - ${topic} specific coding standards and best practices\n`;
|
||||
instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\n`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +315,7 @@ function generateInstructionsSection(instructionsDir) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the prompts section with an alphabetical list of all prompts
|
||||
* Generate the prompts section with a table of all prompts
|
||||
*/
|
||||
function generatePromptsSection(promptsDir) {
|
||||
// Get all prompt files
|
||||
@ -300,9 +326,11 @@ function generatePromptsSection(promptsDir) {
|
||||
|
||||
console.log(`Found ${promptFiles.length} prompt files`);
|
||||
|
||||
let promptsContent = "";
|
||||
// Create table header
|
||||
let promptsContent =
|
||||
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||
|
||||
// Generate list items for each prompt file
|
||||
// Generate table rows for each prompt file
|
||||
for (const file of promptFiles) {
|
||||
const filePath = path.join(promptsDir, file);
|
||||
const title = extractTitle(filePath);
|
||||
@ -311,10 +339,13 @@ function generatePromptsSection(promptsDir) {
|
||||
// Check if there's a description in the frontmatter
|
||||
const customDescription = extractDescription(filePath);
|
||||
|
||||
// Create badges for installation links
|
||||
const badges = makeBadges(link, "prompt");
|
||||
|
||||
if (customDescription && customDescription !== "null") {
|
||||
promptsContent += `- [${title}](${link}) - ${customDescription}\n`;
|
||||
promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\n`;
|
||||
} else {
|
||||
promptsContent += `- [${title}](${link})\n`;
|
||||
promptsContent += `| [${title}](${link}) | | ${badges} |\n`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +353,7 @@ function generatePromptsSection(promptsDir) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the chat modes section with an alphabetical list of all chat modes
|
||||
* Generate the chat modes section with a table of all chat modes
|
||||
*/
|
||||
function generateChatModesSection(chatmodesDir) {
|
||||
// Check if chatmodes directory exists
|
||||
@ -344,9 +375,11 @@ function generateChatModesSection(chatmodesDir) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let chatmodesContent = "";
|
||||
// Create table header
|
||||
let chatmodesContent =
|
||||
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||
|
||||
// Generate list items for each chat mode file
|
||||
// Generate table rows for each chat mode file
|
||||
for (const file of chatmodeFiles) {
|
||||
const filePath = path.join(chatmodesDir, file);
|
||||
const title = extractTitle(filePath);
|
||||
@ -355,10 +388,13 @@ function generateChatModesSection(chatmodesDir) {
|
||||
// Check if there's a description in the frontmatter
|
||||
const customDescription = extractDescription(filePath);
|
||||
|
||||
// Create badges for installation links
|
||||
const badges = makeBadges(link, "chatmode");
|
||||
|
||||
if (customDescription && customDescription !== "null") {
|
||||
chatmodesContent += `- [${title}](${link}) - ${customDescription}\n`;
|
||||
chatmodesContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\n`;
|
||||
} else {
|
||||
chatmodesContent += `- [${title}](${link})\n`;
|
||||
chatmodesContent += `| [${title}](${link}) | | ${badges} |\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user