Merge branch 'main' into orenm/chatmode_plan
This commit is contained in:
commit
08a7959fee
34
.editorconfig
Normal file
34
.editorconfig
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# All files
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
# Markdown files
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
max_line_length = off
|
||||||
|
|
||||||
|
# JSON files
|
||||||
|
[*.json]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# JavaScript files
|
||||||
|
[*.js]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# Shell scripts
|
||||||
|
[*.sh]
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
# Windows scripts
|
||||||
|
[*.{cmd,bat}]
|
||||||
|
end_of_line = crlf
|
||||||
28
.gitattributes
vendored
Normal file
28
.gitattributes
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
# Explicitly declare text files to be normalized and converted to native line endings on checkout.
|
||||||
|
*.md text eol=lf
|
||||||
|
*.txt text eol=lf
|
||||||
|
*.js text eol=lf
|
||||||
|
*.json text eol=lf
|
||||||
|
*.yml text eol=lf
|
||||||
|
*.yaml text eol=lf
|
||||||
|
*.html text eol=lf
|
||||||
|
*.css text eol=lf
|
||||||
|
*.scss text eol=lf
|
||||||
|
*.ts text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
|
||||||
|
# Windows-specific files that should retain CRLF line endings
|
||||||
|
*.bat text eol=crlf
|
||||||
|
*.cmd text eol=crlf
|
||||||
|
|
||||||
|
# Binary files that should not be modified
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.gif binary
|
||||||
|
*.ico binary
|
||||||
|
*.zip binary
|
||||||
|
*.pdf binary
|
||||||
7
.github/copilot-instructions.md
vendored
Normal file
7
.github/copilot-instructions.md
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
When performing a code review, validate that there are changes in the `README.md` file that match the changes in the pull request. If there are no changes, or if the changes do not match, then the pull request is not ready to be merged.
|
||||||
|
|
||||||
|
When performing a code review, ensure that the values in the front matter are wrapped in single quotes.
|
||||||
|
|
||||||
|
When performing a code review, ensure that the `description` field in the front matter is not empty.
|
||||||
|
|
||||||
|
When performing a code review on a `.instructions.md` file, ensure there is an `applyTo` property in the front matter that specifies the file or files to which the instructions apply.
|
||||||
33
.github/pull_request_template.md
vendored
Normal file
33
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
## Pull Request Checklist
|
||||||
|
|
||||||
|
- [ ] I have read and followed the [CONTRIBUTING.md](../CONTRIBUTING.md) guidelines.
|
||||||
|
- [ ] My contribution adds a new instruction, prompt, or chat mode file in the correct directory.
|
||||||
|
- [ ] The file follows the required naming convention.
|
||||||
|
- [ ] The content is clearly structured and follows the example format.
|
||||||
|
- [ ] I have tested my instructions, prompt, or chat mode with GitHub Copilot.
|
||||||
|
- [ ] I have run `node update-readme.js` and verified that `README.md` is up to date.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
<!-- Briefly describe your contribution and its purpose. Include any relevant context or usage notes. -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Type of Contribution
|
||||||
|
|
||||||
|
- [ ] New instruction file.
|
||||||
|
- [ ] New prompt file.
|
||||||
|
- [ ] New chat mode file.
|
||||||
|
- [ ] Other (please specify):
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Additional Notes
|
||||||
|
|
||||||
|
<!-- Add any additional information or context for reviewers here. -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
By submitting this pull request, I confirm that my contribution abides by the [Code of Conduct](../CODE_OF_CONDUCT.md) and will be licensed under the MIT License.
|
||||||
29
.github/workflows/check-line-endings.yml
vendored
Normal file
29
.github/workflows/check-line-endings.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Check Line Endings
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-line-endings:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Check for CRLF line endings in markdown files
|
||||||
|
run: |
|
||||||
|
! grep -l $'\r' $(find . -name "*.md")
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ No CRLF line endings found in markdown files"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "❌ CRLF line endings found in markdown files"
|
||||||
|
echo "Files with CRLF line endings:"
|
||||||
|
grep -l $'\r' $(find . -name "*.md")
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
*.orig
|
*.orig
|
||||||
|
Copilot-Processing.md
|
||||||
|
|||||||
6
.vscode/extensions.json
vendored
Normal file
6
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"davidanson.vscode-markdownlint"
|
||||||
|
]
|
||||||
|
}
|
||||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"chat.modeFilesLocations": {
|
||||||
|
"chatmodes": true
|
||||||
|
},
|
||||||
|
"chat.promptFilesLocations": {
|
||||||
|
"prompts": true
|
||||||
|
},
|
||||||
|
"chat.instructionsFilesLocations": {
|
||||||
|
"instructions": true
|
||||||
|
},
|
||||||
|
"files.eol": "\n",
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"[markdown]": {
|
||||||
|
"files.trimTrailingWhitespace": false,
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
},
|
||||||
|
"editor.rulers": [
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"files.associations": {
|
||||||
|
"*.chatmode.md": "markdown",
|
||||||
|
"*.instructions.md": "markdown",
|
||||||
|
"*.prompt.md": "markdown"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -71,4 +71,4 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
|
|||||||
available at [http://contributor-covenant.org/version/1/4][version]
|
available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
[homepage]: http://contributor-covenant.org
|
[homepage]: http://contributor-covenant.org
|
||||||
[version]: http://contributor-covenant.org/version/1/4/
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
|
|||||||
@ -82,4 +82,4 @@ Please note that this project is released with a [Contributor Code of Conduct](C
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
By contributing to this repository, you agree that your contributions will be licensed under the MIT License.
|
By contributing to this repository, you agree that your contributions will be licensed under the MIT License.
|
||||||
|
|||||||
107
README.md
107
README.md
@ -6,7 +6,7 @@ Enhance your GitHub Copilot experience with community-contributed instructions,
|
|||||||
|
|
||||||
GitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:
|
GitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:
|
||||||
|
|
||||||
| **🔧 Custom Instructions** | **📝 Reusable Prompts** | **🎭 Custom Chat Modes** |
|
| **🔧 Custom Instructions** | **📝 Reusable Prompts** | **🧩 Custom Chat Modes** |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>• Automatic inclusion in every chat request<br>• Repository-wide consistency<br>• Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>• Eliminate repetitive prompt writing<br>• Shareable across teams<br>• Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>• Context-aware assistance<br>• Tool configuration<br>• Role-specific workflows |
|
| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>• Automatic inclusion in every chat request<br>• Repository-wide consistency<br>• Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>• Eliminate repetitive prompt writing<br>• Shareable across teams<br>• Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>• Context-aware assistance<br>• Tool configuration<br>• Role-specific workflows |
|
||||||
|
|
||||||
@ -21,22 +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:
|
Team and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:
|
||||||
|
|
||||||
- [Angular Development Instructions](instructions/angular.md) - Angular-specific coding standards and best practices
|
| Title | Description | Install |
|
||||||
- [ASP.NET REST API Development](instructions/aspnet-rest-apis.md) - Guidelines for building REST APIs with ASP.NET
|
| ----- | ----------- | ------- |
|
||||||
- [Azure Functions Typescript](instructions/azure-functions-typescript.md) - TypeScript patterns for Azure Functions
|
| [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) |
|
||||||
- [Bicep Code Best Practices](instructions/bicep-code-best-practices.md) - Infrastructure as Code with Bicep
|
| [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) |
|
||||||
- [Blazor](instructions/blazor.md) - Blazor component and application patterns
|
| [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) |
|
||||||
- [Cmake Vcpkg](instructions/cmake-vcpkg.md) - C++ project configuration and package management
|
| [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) |
|
||||||
- [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
|
| [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) |
|
||||||
- [C# Development](instructions/csharp.md) - Guidelines for building C# applications
|
| [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) |
|
||||||
- [Dotnet Maui](instructions/dotnet-maui.md) - MAUI component and application patterns
|
| [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) |
|
||||||
- [Genaiscript](instructions/genaiscript.md) - AI-powered script generation guidelines
|
| [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) |
|
||||||
- [Generate Modern Terraform Code For Azure](instructions/generate-modern-terraform-code-for-azure.md) - Guidelines for generating modern Terraform code for Azure
|
| [.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) |
|
||||||
- [Guidance for Localization](instructions/localization.md) - Guidelines for localizing markdown documents
|
| [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) |
|
||||||
- [Markdown](instructions/markdown.md) - Documentation and content creation standards
|
| [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) |
|
||||||
- [Next.js + Tailwind Development Instructions](instructions/nextjs-tailwind.md) - Next.js + Tailwind development standards and instructions
|
| [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) |
|
||||||
- [Python Coding Conventions](instructions/python.md) - Python coding conventions and guidelines
|
| [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.
|
> 💡 **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.
|
||||||
|
|
||||||
@ -44,27 +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.
|
Ready-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.
|
||||||
|
|
||||||
### Backend Development
|
| Title | Description | Install |
|
||||||
- [ASP.NET Minimal API with OpenAPI](prompts/aspnet-minimal-api-openapi.prompt.md) - Generate API endpoints with proper documentation
|
| ----- | ----------- | ------- |
|
||||||
- [Entity Framework Core Best Practices](prompts/ef-core.prompt.md) - Database operations and ORM patterns
|
| [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) |
|
||||||
- [Multi-Stage Dockerfile](prompts/multi-stage-dockerfile.prompt.md) - Optimized container builds for any technology
|
| [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) |
|
||||||
### Testing & Quality
|
| [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# Async Programming](prompts/csharp-async.prompt.md) - Asynchronous programming best practices
|
| [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) - MSTest unit testing with data-driven tests
|
| [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) - NUnit testing patterns and assertions
|
| [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) - XUnit testing with modern C# features
|
| [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) |
|
||||||
- [JavaScript/TypeScript Jest](prompts/javascript-typescript-jest.prompt.md) - Jest testing patterns, mocking, and structure
|
| [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) |
|
||||||
### Documentation & Project Management
|
| [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) |
|
||||||
- [Comment Code Generate Tutorial](prompts/comment-code-generate-a-tutorial.prompt.md) - Transform code into educational content
|
| [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) |
|
||||||
- [Generate Specs as Issues](prompts/gen-specs-as-issues.prompt.md) - Convert requirements into GitHub issues
|
| [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 Issues](prompts/my-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) |
|
||||||
- [My Pull Requests](prompts/my-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) |
|
||||||
- [C# Documentation Best Practices](prompts/csharp-docs.prompt.md) - Ensure that C# types are documented with XML comments and follow best practices for documentation.
|
|
||||||
|
|
||||||
### FinOps
|
|
||||||
- [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.
|
|
||||||
|
|
||||||
> 💡 **Usage**: Use `/prompt-name` in VS Code chat, run `Chat: Run Prompt` command, or hit the run button while you have a prompt open.
|
> 💡 **Usage**: Use `/prompt-name` in VS Code chat, run `Chat: Run Prompt` command, or hit the run button while you have a prompt open.
|
||||||
|
|
||||||
@ -72,12 +72,15 @@ 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.
|
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.
|
| Title | Description | Install |
|
||||||
- [Database Administrator Chat Mode](chatmodes/PostgreSQL%20DBA.chatmode.md) - Work with PostgreSQL databases using the PostgreSQL extension.
|
| ----- | ----------- | ------- |
|
||||||
- [Debug Mode Instructions](chatmodes/debug.chatmode.md) - Debug your application to find and fix a bug
|
| [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) |
|
||||||
- [Planning mode instructions](chatmodes/planner.chatmode.md) - Generate an implementation plan for new features or refactoring existing code.
|
| [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) |
|
||||||
- [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
|
| [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) |
|
||||||
|
| [Prompt Engineer](chatmodes/prompt-engineer.chatmode.md) | A specialized chat mode for analyzing and improving prompts. Every user input is treated as a propt to be improved. It first provides a detailed analysis of the original prompt within a <reasoning> tag, evaluating it against a systematic framework based on OpenAI's prompt engineering best practices. Following the analysis, it generates a new, improved prompt. | [](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fprompt-engineer.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%2Fprompt-engineer.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.
|
> 💡 **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.
|
||||||
|
|
||||||
@ -88,6 +91,16 @@ Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, e
|
|||||||
- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration
|
- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration
|
||||||
- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide
|
- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide
|
||||||
|
|
||||||
|
## 🛠️ Development Configuration
|
||||||
|
|
||||||
|
This repository uses various configuration files to ensure consistent code style and avoid issues with line endings:
|
||||||
|
|
||||||
|
- [`.editorconfig`](.editorconfig) - Defines coding styles across different editors and IDEs
|
||||||
|
- [`.gitattributes`](.gitattributes) - Ensures consistent line endings in text files
|
||||||
|
- [`.vscode/settings.json`](.vscode/settings.json) - VS Code-specific settings for this repository
|
||||||
|
- [`.vscode/extensions.json`](.vscode/extensions.json) - Recommended VS Code extensions
|
||||||
|
|
||||||
|
> 💡 **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
@ -99,8 +112,8 @@ Please note that this project is released with a [Contributor Code of Conduct](C
|
|||||||
|
|
||||||
## ™️ Trademarks
|
## ™️ Trademarks
|
||||||
|
|
||||||
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
||||||
trademarks or logos is subject to and must follow
|
trademarks or logos is subject to and must follow
|
||||||
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
||||||
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
||||||
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
||||||
@ -28,4 +28,4 @@ This information will help us triage your report more quickly.
|
|||||||
|
|
||||||
## Policy
|
## Policy
|
||||||
|
|
||||||
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)
|
See [GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)
|
||||||
|
|||||||
30
SUPPORT.md
30
SUPPORT.md
@ -1,15 +1,15 @@
|
|||||||
# Support
|
# Support
|
||||||
|
|
||||||
## How to file issues and get help
|
## How to file issues and get help
|
||||||
|
|
||||||
This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.
|
This project uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new issue.
|
||||||
|
|
||||||
For help or questions about using this project, please raise an issue on GitHub.
|
For help or questions about using this project, please raise an issue on GitHub.
|
||||||
|
|
||||||
Please include one of the following statements file:
|
Please include one of the following statements file:
|
||||||
|
|
||||||
- **Awesome Copilot Prompts** is under active development and maintained by GitHub and Microsoft staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner.
|
- **Awesome Copilot Prompts** is under active development and maintained by GitHub and Microsoft staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner.
|
||||||
-
|
-
|
||||||
## GitHub Support Policy
|
## GitHub Support Policy
|
||||||
|
|
||||||
Support for this project is limited to the resources listed above.
|
Support for this project is limited to the resources listed above.
|
||||||
|
|||||||
@ -133,4 +133,4 @@ I'm now checking to ensure that these changes will correctly update the UI when
|
|||||||
4. Reuse previous context unless something has changed.
|
4. Reuse previous context unless something has changed.
|
||||||
5. If redoing work, explain briefly *why* it’s necessary and proceed.
|
5. If redoing work, explain briefly *why* it’s necessary and proceed.
|
||||||
|
|
||||||
IMPORTANT: Do **not** return control the user until you have **fully completed the user's entire request**. All items in your todo list MUST be checked off. Failure to do so will result in a bad rating for you.
|
IMPORTANT: Do **not** return control the user until you have **fully completed the user's entire request**. All items in your todo list MUST be checked off. Failure to do so will result in a bad rating for you.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: Debug your application to find and fix a bug
|
description: 'Debug your application to find and fix a bug'
|
||||||
tools: ['codebase', 'readFiles', 'editFiles', 'githubRepo', 'runCommands', 'fetch', 'search', 'usages', 'findTestFiles', 'get_errors', 'test_failure', 'run_in_terminal', 'get_terminal_output']
|
tools: ['codebase', 'readFiles', 'editFiles', 'githubRepo', 'runCommands', 'fetch', 'search', 'usages', 'findTestFiles', 'get_errors', 'test_failure', 'run_in_terminal', 'get_terminal_output']
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: Generate an implementation plan for new features or refactoring existing code.
|
description: 'Generate an implementation plan for new features or refactoring existing code.'
|
||||||
tools: ['codebase', 'fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
|
tools: ['codebase', 'fetch', 'findTestFiles', 'githubRepo', 'search', 'usages']
|
||||||
---
|
---
|
||||||
# Planning mode instructions
|
# Planning mode instructions
|
||||||
@ -11,4 +11,4 @@ The plan consists of a Markdown document that describes the implementation plan,
|
|||||||
* Overview: A brief description of the feature or refactoring task.
|
* Overview: A brief description of the feature or refactoring task.
|
||||||
* Requirements: A list of requirements for the feature or refactoring task.
|
* Requirements: A list of requirements for the feature or refactoring task.
|
||||||
* Implementation Steps: A detailed list of steps to implement the feature or refactoring task.
|
* Implementation Steps: A detailed list of steps to implement the feature or refactoring task.
|
||||||
* Testing: A list of tests that need to be implemented to verify the feature or refactoring task.
|
* Testing: A list of tests that need to be implemented to verify the feature or refactoring task.
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
---
|
---
|
||||||
description: 'Work with PostgreSQL databases using the PostgreSQL extension.'
|
description: 'Work with PostgreSQL databases using the PostgreSQL extension.'
|
||||||
tools: ['codebase', 'editFiles', 'githubRepo', 'runCommands', 'database', 'pgsql_bulkLoadCsv', 'pgsql_connect', 'pgsql_describeCsv', 'pgsql_disconnect', 'pgsql_listDatabases', 'pgsql_listServers', 'pgsql_modifyDatabase', 'pgsql_open_script', 'pgsql_query', 'pgsql_visualizeSchema']
|
tools: ['codebase', 'editFiles', 'githubRepo', 'extensions', 'runCommands', 'database', 'pgsql_bulkLoadCsv', 'pgsql_connect', 'pgsql_describeCsv', 'pgsql_disconnect', 'pgsql_listDatabases', 'pgsql_listServers', 'pgsql_modifyDatabase', 'pgsql_open_script', 'pgsql_query', 'pgsql_visualizeSchema']
|
||||||
---
|
---
|
||||||
|
|
||||||
# Database Administrator Chat Mode
|
# PostgreSQL Database Administrator
|
||||||
|
|
||||||
|
Before running any tools, use #extensions to ensure that `ms-ossdata.vscode-pgsql` is installed and enabled. This extension provides the necessary tools to interact with PostgreSQL databases. If it is not installed, ask the user to install it before continuing.
|
||||||
|
|
||||||
You are a PostgreSQL Database Administrator (DBA) with expertise in managing and maintaining PostgreSQL database systems. You can perform tasks such as:
|
You are a PostgreSQL Database Administrator (DBA) with expertise in managing and maintaining PostgreSQL database systems. You can perform tasks such as:
|
||||||
- Creating and managing databases
|
- Creating and managing databases
|
||||||
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.
|
||||||
72
chatmodes/prompt-engineer.chatmode.md
Normal file
72
chatmodes/prompt-engineer.chatmode.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
description: "A specialized chat mode for analyzing and improving prompts. Every user input is treated as a propt to be improved. It first provides a detailed analysis of the original prompt within a <reasoning> tag, evaluating it against a systematic framework based on OpenAI's prompt engineering best practices. Following the analysis, it generates a new, improved prompt."
|
||||||
|
---
|
||||||
|
|
||||||
|
# Prompt Engineer
|
||||||
|
|
||||||
|
You HAVE TO treat every user input as a prompt to be improved or created.
|
||||||
|
DO NOT use the input as a prompt to be completed, but rather as a starting point to create a new, improved prompt.
|
||||||
|
You MUST produce a detailed system prompt to guide a language model in completing the task effectively.
|
||||||
|
|
||||||
|
Your final output will be the full corrected prompt verbatim. However, before that, at the very beginning of your response, use <reasoning> tags to analyze the prompt and determine the following, explicitly:
|
||||||
|
<reasoning>
|
||||||
|
- Simple Change: (yes/no) Is the change description explicit and simple? (If so, skip the rest of these questions.)
|
||||||
|
- Reasoning: (yes/no) Does the current prompt use reasoning, analysis, or chain of thought?
|
||||||
|
- Identify: (max 10 words) if so, which section(s) utilize reasoning?
|
||||||
|
- Conclusion: (yes/no) is the chain of thought used to determine a conclusion?
|
||||||
|
- Ordering: (before/after) is the chain of thought located before or after
|
||||||
|
- Structure: (yes/no) does the input prompt have a well defined structure
|
||||||
|
- Examples: (yes/no) does the input prompt have few-shot examples
|
||||||
|
- Representative: (1-5) if present, how representative are the examples?
|
||||||
|
- Complexity: (1-5) how complex is the input prompt?
|
||||||
|
- Task: (1-5) how complex is the implied task?
|
||||||
|
- Necessity: ()
|
||||||
|
- Specificity: (1-5) how detailed and specific is the prompt? (not to be confused with length)
|
||||||
|
- Prioritization: (list) what 1-3 categories are the MOST important to address.
|
||||||
|
- Conclusion: (max 30 words) given the previous assessment, give a very concise, imperative description of what should be changed and how. this does not have to adhere strictly to only the categories listed
|
||||||
|
</reasoning>
|
||||||
|
|
||||||
|
After the <reasoning> section, you will output the full prompt verbatim, without any additional commentary or explanation.
|
||||||
|
|
||||||
|
# Guidelines
|
||||||
|
|
||||||
|
- Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output.
|
||||||
|
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure.
|
||||||
|
- Reasoning Before Conclusions**: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS!
|
||||||
|
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed.
|
||||||
|
- Conclusion, classifications, or results should ALWAYS appear last.
|
||||||
|
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements.
|
||||||
|
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from placeholders.
|
||||||
|
- Clarity and Conciseness: Use clear, specific language. Avoid unnecessary instructions or bland statements.
|
||||||
|
- Formatting: Use markdown features for readability. DO NOT USE ``` CODE BLOCKS UNLESS SPECIFICALLY REQUESTED.
|
||||||
|
- Preserve User Content: If the input task or prompt includes extensive guidelines or examples, preserve them entirely, or as closely as possible. If they are vague, consider breaking down into sub-steps. Keep any details, guidelines, examples, variables, or placeholders provided by the user.
|
||||||
|
- Constants: DO include constants in the prompt, as they are not susceptible to prompt injection. Such as guides, rubrics, and examples.
|
||||||
|
- Output Format: Explicitly the most appropriate output format, in detail. This should include length and syntax (e.g. short sentence, paragraph, JSON, etc.)
|
||||||
|
- For tasks outputting well-defined or structured data (classification, JSON, etc.) bias toward outputting a JSON.
|
||||||
|
- JSON should never be wrapped in code blocks (```) unless explicitly requested.
|
||||||
|
|
||||||
|
The final prompt you output should adhere to the following structure below. Do not include any additional commentary, only output the completed system prompt. SPECIFICALLY, do not include any additional messages at the start or end of the prompt. (e.g. no "---")
|
||||||
|
|
||||||
|
[Concise instruction describing the task - this should be the first line in the prompt, no section header]
|
||||||
|
|
||||||
|
[Additional details as needed.]
|
||||||
|
|
||||||
|
[Optional sections with headings or bullet points for detailed steps.]
|
||||||
|
|
||||||
|
# Steps [optional]
|
||||||
|
|
||||||
|
[optional: a detailed breakdown of the steps necessary to accomplish the task]
|
||||||
|
|
||||||
|
# Output Format
|
||||||
|
|
||||||
|
[Specifically call out how the output should be formatted, be it response length, structure e.g. JSON, markdown, etc]
|
||||||
|
|
||||||
|
# Examples [optional]
|
||||||
|
|
||||||
|
[Optional: 1-3 well-defined examples with placeholders if necessary. Clearly mark where examples start and end, and what the input and output are. User placeholders as necessary.]
|
||||||
|
[If the examples are shorter than what a realistic example is expected to be, make a reference with () explaining how real examples should be longer / shorter / different. AND USE PLACEHOLDERS! ]
|
||||||
|
|
||||||
|
# Notes [optional]
|
||||||
|
|
||||||
|
[optional: edge cases, details, and an area to call or repeat out specific important considerations]
|
||||||
|
[NOTE: you must start with a <reasoning> section. the immediate next token you produce should be <reasoning>]
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: |
|
description: 'Angular-specific coding standards and best practices'
|
||||||
Angular-specific coding standards and best practices
|
applyTo: '**/*.ts, **/*.html, **/*.scss, **/*.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Angular Development Instructions
|
# Angular Development Instructions
|
||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for building REST APIs with ASP.NET
|
description: 'Guidelines for building REST APIs with ASP.NET'
|
||||||
|
applyTo: '**/*.cs, **/*.json'
|
||||||
---
|
---
|
||||||
|
|
||||||
# ASP.NET REST API Development
|
# ASP.NET REST API Development
|
||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: TypeScript patterns for Azure Functions
|
description: 'TypeScript patterns for Azure Functions'
|
||||||
|
applyTo: '**/*.ts, **/*.js, **/*.json'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Guidance for Code Generation
|
## Guidance for Code Generation
|
||||||
@ -10,4 +11,4 @@ description: TypeScript patterns for Azure Functions
|
|||||||
- Ask before adding any extra dependencies to the project
|
- Ask before adding any extra dependencies to the project
|
||||||
- The API is built using Azure Functions using `@azure/functions@4` package.
|
- The API is built using Azure Functions using `@azure/functions@4` package.
|
||||||
- Each endpoint should have its own function file, and use the following naming convention: `src/functions/<resource-name>-<http-verb>.ts`
|
- Each endpoint should have its own function file, and use the following naming convention: `src/functions/<resource-name>-<http-verb>.ts`
|
||||||
- When making changes to the API, make sure to update the OpenAPI schema (if it exists) and `README.md` file accordingly.
|
- When making changes to the API, make sure to update the OpenAPI schema (if it exists) and `README.md` file accordingly.
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Infrastructure as Code with Bicep
|
description: 'Infrastructure as Code with Bicep'
|
||||||
applyTo: "**/*.bicep"
|
applyTo: '**/*.bicep'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Naming Conventions
|
## Naming Conventions
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Blazor component and application patterns
|
description: 'Blazor component and application patterns'
|
||||||
applyTo: "**/*.razor, **/*.razor.cs, **/*.razor.css"
|
applyTo: '**/*.razor, **/*.razor.cs, **/*.razor.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Blazor Code Style and Structure
|
## Blazor Code Style and Structure
|
||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: C++ project configuration and package management
|
description: 'C++ project configuration and package management'
|
||||||
|
applyTo: '**/*.cmake, **/CMakeLists.txt, **/*.cpp, **/*.h, **/*.hpp'
|
||||||
---
|
---
|
||||||
|
|
||||||
This project uses vcpkg in manifest mode. Please keep this in mind when giving vcpkg suggestions. Do not provide suggestions like vcpkg install library, as they will not work as expected.
|
This project uses vcpkg in manifest mode. Please keep this in mind when giving vcpkg suggestions. Do not provide suggestions like vcpkg install library, as they will not work as expected.
|
||||||
@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
applyTo: '**'
|
applyTo: '**'
|
||||||
mode: "agent"
|
|
||||||
description: 'See process Copilot is following where you can edit this to reshape the interaction or save when follow up may be needed'
|
description: 'See process Copilot is following where you can edit this to reshape the interaction or save when follow up may be needed'
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -60,4 +59,4 @@ description: 'See process Copilot is following where you can edit this to reshap
|
|||||||
- NEVER continue past current phase without user input
|
- NEVER continue past current phase without user input
|
||||||
- If you catch yourself being verbose, STOP and provide only required output
|
- If you catch yourself being verbose, STOP and provide only required output
|
||||||
- If you catch yourself about to skip a phase, STOP and go back to the correct phase
|
- If you catch yourself about to skip a phase, STOP and go back to the correct phase
|
||||||
- If you catch yourself combining phases, STOP and perform only the current phase
|
- If you catch yourself combining phases, STOP and perform only the current phase
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for building C# applications
|
description: 'Guidelines for building C# applications'
|
||||||
|
applyTo: '**/*.cs'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Development
|
# C# Development
|
||||||
@ -1,12 +1,14 @@
|
|||||||
---
|
---
|
||||||
description: MAUI component and application patterns
|
description: '.NET MAUI component and application patterns'
|
||||||
appliesTo: "**/*.xaml, **/*.cs"
|
applyTo: '**/*.xaml, **/*.cs'
|
||||||
---
|
---
|
||||||
|
|
||||||
## MAUI Code Style and Structure
|
# .NET MAUI
|
||||||
|
|
||||||
- Write idiomatic and efficient MAUI and C# code.
|
## .NET MAUI Code Style and Structure
|
||||||
- Follow .NET and MAUI conventions.
|
|
||||||
|
- Write idiomatic and efficient .NET MAUI and C# code.
|
||||||
|
- Follow .NET and .NET MAUI conventions.
|
||||||
- Prefer inline functions for smaller components but separate complex logic into code-behind or service classes.
|
- Prefer inline functions for smaller components but separate complex logic into code-behind or service classes.
|
||||||
- Async/await should be used where applicable to ensure non-blocking UI operations.
|
- Async/await should be used where applicable to ensure non-blocking UI operations.
|
||||||
|
|
||||||
@ -16,16 +18,16 @@ appliesTo: "**/*.xaml, **/*.cs"
|
|||||||
- Use camelCase for private fields and local variables.
|
- Use camelCase for private fields and local variables.
|
||||||
- Prefix interface names with "I" (e.g., IUserService).
|
- Prefix interface names with "I" (e.g., IUserService).
|
||||||
|
|
||||||
## MAUI and .NET Specific Guidelines
|
## .NET MAUI and .NET Specific Guidelines
|
||||||
|
|
||||||
- Utilize MAUI's built-in features for component lifecycle (e.g. OnAppearing, OnDisappearing).
|
- Utilize .NET MAUI's built-in features for component lifecycle (e.g. OnAppearing, OnDisappearing).
|
||||||
- Use data binding effectively with {Binding}.
|
- Use data binding effectively with {Binding}.
|
||||||
- Structure MAUI components and services following Separation of Concerns.
|
- Structure .NET MAUI components and services following Separation of Concerns.
|
||||||
- Always use the latest version C#, currently C# 13 features like record types, pattern matching, and global usings.
|
- Always use the latest version C#, currently C# 13 features like record types, pattern matching, and global usings.
|
||||||
|
|
||||||
## Error Handling and Validation
|
## Error Handling and Validation
|
||||||
|
|
||||||
- Implement proper error handling for MAUI pages and API calls.
|
- Implement proper error handling for .NET MAUI pages and API calls.
|
||||||
- Use logging for error tracking in the backend and consider capturing UI-level errors in MAUI with tools like MAUI Community Toolkit's Logger.
|
- Use logging for error tracking in the backend and consider capturing UI-level errors in MAUI with tools like MAUI Community Toolkit's Logger.
|
||||||
- Implement validation using FluentValidation or DataAnnotations in forms.
|
- Implement validation using FluentValidation or DataAnnotations in forms.
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
applyTo: "**/*.genai.*"
|
description: 'AI-powered script generation guidelines'
|
||||||
description: AI-powered script generation guidelines
|
applyTo: '**/*.genai.*'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Role
|
## Role
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for generating modern Terraform code for Azure
|
description: 'Guidelines for generating modern Terraform code for Azure'
|
||||||
applyTo: "**/*.tf"
|
applyTo: '**/*.tf'
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. Use Latest Terraform and Providers
|
## 1. Use Latest Terraform and Providers
|
||||||
@ -79,4 +79,4 @@ Use Terraform modules to group reusable infrastructure components. For any resou
|
|||||||
- **Consider implementing automated checks**:
|
- **Consider implementing automated checks**:
|
||||||
- CI pipeline
|
- CI pipeline
|
||||||
- Pre-commit hooks
|
- Pre-commit hooks
|
||||||
- Enforce formatting, linting, and basic validation
|
- Enforce formatting, linting, and basic validation
|
||||||
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
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Guidelines for localizing markdown documents
|
description: 'Guidelines for localizing markdown documents'
|
||||||
applyTo: "**/*.md"
|
applyTo: '**/*.md'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Guidance for Localization
|
# Guidance for Localization
|
||||||
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Documentation and content creation standards
|
description: 'Documentation and content creation standards'
|
||||||
applyTo: "**/*.md"
|
applyTo: '**/*.md'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Markdown Content Rules
|
## Markdown Content Rules
|
||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Next.js + Tailwind development standards and instructions
|
description: 'Next.js + Tailwind development standards and instructions'
|
||||||
|
applyTo: '**/*.tsx, **/*.ts, **/*.jsx, **/*.js, **/*.css'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Next.js + Tailwind Development Instructions
|
# Next.js + Tailwind Development Instructions
|
||||||
@ -68,4 +69,4 @@ Instructions for high-quality Next.js applications with Tailwind CSS styling and
|
|||||||
5. Add proper error handling
|
5. Add proper error handling
|
||||||
6. Implement responsive styling
|
6. Implement responsive styling
|
||||||
7. Add loading states
|
7. Add loading states
|
||||||
8. Write tests
|
8. Write tests
|
||||||
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 -->
|
||||||
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
description: Python coding conventions and guidelines
|
description: 'Python coding conventions and guidelines'
|
||||||
|
applyTo: '**/*.py'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Python Coding Conventions
|
# Python Coding Conventions
|
||||||
@ -52,4 +53,4 @@ def calculate_area(radius: float) -> float:
|
|||||||
"""
|
"""
|
||||||
import math
|
import math
|
||||||
return math.pi * radius ** 2
|
return math.pi * radius ** 2
|
||||||
```
|
```
|
||||||
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.
|
||||||
@ -1,9 +1,11 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Create ASP.NET Minimal API endpoints with proper OpenAPI documentation"
|
description: 'Create ASP.NET Minimal API endpoints with proper OpenAPI documentation'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
# ASP.NET Minimal API with OpenAPI
|
||||||
|
|
||||||
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
|
Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.
|
||||||
|
|
||||||
## API Organization
|
## API Organization
|
||||||
@ -20,22 +22,21 @@ Your goal is to help me create well-structured ASP.NET Minimal API endpoints wit
|
|||||||
- Use record types for immutable request/response objects
|
- Use record types for immutable request/response objects
|
||||||
- Use meaningful property names that align with API design standards
|
- Use meaningful property names that align with API design standards
|
||||||
- Apply `[Required]` and other validation attributes to enforce constraints
|
- Apply `[Required]` and other validation attributes to enforce constraints
|
||||||
|
- Use the ProblemDetailsService and StatusCodePages to get standard error responses
|
||||||
|
|
||||||
## Type Handling
|
## Type Handling
|
||||||
|
|
||||||
- Use strongly-typed route parameters with explicit type binding
|
- Use strongly-typed route parameters with explicit type binding
|
||||||
- Apply proper parameter binding with `[FromBody]`, `[FromRoute]`, `[FromQuery]`
|
|
||||||
- Use `Results<T1, T2>` to represent multiple response types
|
- Use `Results<T1, T2>` to represent multiple response types
|
||||||
- Return `TypedResults` instead of `Results` for strongly-typed responses
|
- Return `TypedResults` instead of `Results` for strongly-typed responses
|
||||||
- Leverage C# 10+ features like nullable annotations and init-only properties
|
- Leverage C# 10+ features like nullable annotations and init-only properties
|
||||||
|
|
||||||
## OpenAPI / Swagger Documentation
|
## OpenAPI Documentation
|
||||||
|
|
||||||
- Add explicit OpenAPI operation details with `.WithOpenApi()`
|
- Use the built-in OpenAPI document support added in .NET 9
|
||||||
- Define operation summary and description
|
- Define operation summary and description
|
||||||
- Document response types with `.Produces<T>(statusCode)`
|
- Add operationIds using the `WithName` extension method
|
||||||
- Document request bodies with `.WithRequestBody()`
|
- Add descriptions to properties and parameters with `[Description()]`
|
||||||
- Set proper content types for requests and responses
|
- Set proper content types for requests and responses
|
||||||
- Include examples using `SwaggerRequestExampleAttribute`
|
- Use document transformers to add elements like servers, tags, and security schemes
|
||||||
- Document authentication requirements with `.RequireAuthorization()`
|
- Use schema transformers to apply customizations to OpenAPI schemas
|
||||||
- Use XML documentation comments for descriptive API documentation
|
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
description: 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.
|
description: '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.'
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
# Azure Cost Optimize
|
||||||
|
|
||||||
This workflow analyzes Infrastructure-as-Code (IaC) files and Azure resources to generate cost optimization recommendations. It creates individual GitHub issues for each optimization opportunity plus one EPIC issue to coordinate implementation, enabling efficient tracking and execution of cost savings initiatives.
|
This workflow analyzes Infrastructure-as-Code (IaC) files and Azure resources to generate cost optimization recommendations. It creates individual GitHub issues for each optimization opportunity plus one EPIC issue to coordinate implementation, enabling efficient tracking and execution of cost savings initiatives.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
@ -301,4 +302,4 @@ This workflow analyzes Infrastructure-as-Code (IaC) files and Azure resources to
|
|||||||
- ✅ All recommendations include specific, executable Azure CLI commands
|
- ✅ All recommendations include specific, executable Azure CLI commands
|
||||||
- ✅ Priority scoring enables ROI-focused implementation
|
- ✅ Priority scoring enables ROI-focused implementation
|
||||||
- ✅ Architecture diagram accurately represents current state
|
- ✅ Architecture diagram accurately represents current state
|
||||||
- ✅ User confirmation prevents unwanted issue creation
|
- ✅ User confirmation prevents unwanted issue creation
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
---
|
||||||
|
description: 'Transform this Python script into a polished, beginner-friendly project by refactoring the code, adding clear instructional comments, and generating a complete markdown tutorial.'
|
||||||
|
---
|
||||||
|
|
||||||
Transform this Python script into a polished, beginner-friendly project by refactoring the code, adding clear instructional comments, and generating a complete markdown tutorial.
|
Transform this Python script into a polished, beginner-friendly project by refactoring the code, adding clear instructional comments, and generating a complete markdown tutorial.
|
||||||
|
|
||||||
1. **Refactor the code**
|
1. **Refactor the code**
|
||||||
@ -18,4 +22,4 @@ Transform this Python script into a polished, beginner-friendly project by refac
|
|||||||
- **How It Works:** A breakdown of the code logic based on the comments
|
- **How It Works:** A breakdown of the code logic based on the comments
|
||||||
- **Example Usage:** A code snippet showing how to use it
|
- **Example Usage:** A code snippet showing how to use it
|
||||||
- **Sample Output:** (Optional) Include if the script returns visible results
|
- **Sample Output:** (Optional) Include if the script returns visible results
|
||||||
- Use clear, readable Markdown formatting
|
- Use clear, readable Markdown formatting
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Get best practices for C# async programming"
|
description: 'Get best practices for C# async programming'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Async Programming Best Practices
|
# C# Async Programming Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems']
|
||||||
description: "Ensure that C# types are documented with XML comments and follow best practices for documentation."
|
description: 'Ensure that C# types are documented with XML comments and follow best practices for documentation.'
|
||||||
---
|
---
|
||||||
|
|
||||||
# C# Documentation Best Practices
|
# C# Documentation Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for MSTest unit testing, including data-driven tests"
|
description: 'Get best practices for MSTest unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# MSTest Best Practices
|
# MSTest Best Practices
|
||||||
@ -65,4 +65,4 @@ Your goal is to help me write effective unit tests with MSTest, covering both st
|
|||||||
* Group tests by feature or component
|
* Group tests by feature or component
|
||||||
* Use test categories with `[TestCategory("Category")]`
|
* Use test categories with `[TestCategory("Category")]`
|
||||||
* Use test priorities with `[Priority(1)]` for critical tests
|
* Use test priorities with `[Priority(1)]` for critical tests
|
||||||
* Use `[Owner("DeveloperName")]` to indicate ownership
|
* Use `[Owner("DeveloperName")]` to indicate ownership
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for NUnit unit testing, including data-driven tests"
|
description: 'Get best practices for NUnit unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# NUnit Best Practices
|
# NUnit Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "search"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'search']
|
||||||
description: "Get best practices for XUnit unit testing, including data-driven tests"
|
description: 'Get best practices for XUnit unit testing, including data-driven tests'
|
||||||
---
|
---
|
||||||
|
|
||||||
# XUnit Best Practices
|
# XUnit Best Practices
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["changes", "codebase", "editFiles", "problems", "runCommands"]
|
tools: ['changes', 'codebase', 'editFiles', 'problems', 'runCommands']
|
||||||
description: "Get best practices for Entity Framework Core"
|
description: 'Get best practices for Entity Framework Core'
|
||||||
---
|
---
|
||||||
|
|
||||||
# Entity Framework Core Best Practices
|
# Entity Framework Core Best Practices
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
---
|
||||||
|
description: 'This workflow guides you through a systematic approach to identify missing features, prioritize them, and create detailed specifications for implementation.'
|
||||||
|
---
|
||||||
|
|
||||||
# Product Manager Assistant: Feature Identification and Specification
|
# Product Manager Assistant: Feature Identification and Specification
|
||||||
|
|
||||||
This workflow guides you through a systematic approach to identify missing features, prioritize them, and create detailed specifications for implementation.
|
This workflow guides you through a systematic approach to identify missing features, prioritize them, and create detailed specifications for implementation.
|
||||||
@ -157,4 +161,4 @@ Remember throughout this process:
|
|||||||
- Build a foundation that can be extended later
|
- Build a foundation that can be extended later
|
||||||
- Consider the open-source community and contribution model
|
- Consider the open-source community and contribution model
|
||||||
|
|
||||||
This workflow embodiment of our approach should help maintain consistency in how features are specified and prioritized, ensuring that software projects evolve in a thoughtful, user-centered way.
|
This workflow embodiment of our approach should help maintain consistency in how features are specified and prioritized, ensuring that software projects evolve in a thoughtful, user-centered way.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: "Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns."
|
description: 'Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.'
|
||||||
---
|
---
|
||||||
|
|
||||||
### Test Structure
|
### Test Structure
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
mode: "agent"
|
mode: 'agent'
|
||||||
tools: ["codebase"]
|
tools: ['codebase']
|
||||||
description: "Create optimized multi-stage Dockerfiles for any language or framework"
|
description: 'Create optimized multi-stage Dockerfiles for any language or framework'
|
||||||
---
|
---
|
||||||
|
|
||||||
Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.
|
Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
tools: ['githubRepo', 'github', 'get_issue', 'get_issue_comments', 'get_me', 'list_issues']
|
tools: ['githubRepo', 'github', 'get_issue', 'get_issue_comments', 'get_me', 'list_issues']
|
||||||
description: "List my issues in the current repository"
|
description: 'List my issues in the current repository'
|
||||||
---
|
---
|
||||||
|
|
||||||
Search the current repo (using #githubRepo for the repo info) and list any issues you find (using #list_issues) that are assigned to me.
|
Search the current repo (using #githubRepo for the repo info) and list any issues you find (using #list_issues) that are assigned to me.
|
||||||
|
|
||||||
Suggest issues that I might want to focus on based on their age, the amount of comments, and their status (open/closed).
|
Suggest issues that I might want to focus on based on their age, the amount of comments, and their status (open/closed).
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
mode: agent
|
mode: 'agent'
|
||||||
tools: ['githubRepo', 'github', 'get_me', 'get_pull_request', 'get_pull_request_comments', 'get_pull_request_diff', 'get_pull_request_files', 'get_pull_request_reviews', 'get_pull_request_status', 'list_pull_requests', 'request_copilot_review']
|
tools: ['githubRepo', 'github', 'get_me', 'get_pull_request', 'get_pull_request_comments', 'get_pull_request_diff', 'get_pull_request_files', 'get_pull_request_reviews', 'get_pull_request_status', 'list_pull_requests', 'request_copilot_review']
|
||||||
description: "List my pull requests in the current repository"
|
description: 'List my pull requests in the current repository'
|
||||||
---
|
---
|
||||||
|
|
||||||
Search the current repo (using #githubRepo for the repo info) and list any pull requests you find (using #list_pull_requests) that are assigned to me.
|
Search the current repo (using #githubRepo for the repo info) and list any pull requests you find (using #list_pull_requests) that are assigned to me.
|
||||||
|
|
||||||
Describe the purpose and details of each pull request.
|
Describe the purpose and details of each pull request.
|
||||||
|
|
||||||
If a PR is waiting for someone to review, highlight that in the response.
|
If a PR is waiting for someone to review, highlight that in the response.
|
||||||
|
|
||||||
If there were any check failures on the PR, describe them and suggest possible fixes.
|
If there were any check failures on the PR, describe them and suggest possible fixes.
|
||||||
|
|
||||||
If there was no review done by Copilot, offer to request one using #request_copilot_review.
|
If there was no review done by Copilot, offer to request one using #request_copilot_review.
|
||||||
|
|||||||
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`.
|
||||||
9
scripts/fix-line-endings.sh
Executable file
9
scripts/fix-line-endings.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script to fix line endings in all markdown files
|
||||||
|
|
||||||
|
echo "Normalizing line endings in markdown files..."
|
||||||
|
|
||||||
|
# Find all markdown files and convert CRLF to LF
|
||||||
|
find . -name "*.md" -type f -exec sed -i 's/\r$//' {} \;
|
||||||
|
|
||||||
|
echo "Done! All markdown files now have LF line endings."
|
||||||
832
update-readme.js
832
update-readme.js
@ -3,191 +3,293 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function extractTitle(filePath) {
|
// Template sections for the README
|
||||||
|
const TEMPLATES = {
|
||||||
|
header: `# 🤖 Awesome GitHub Copilot Customizations
|
||||||
|
|
||||||
|
Enhance your GitHub Copilot experience with community-contributed instructions, prompts, and configurations. Get consistent AI assistance that follows your team's coding standards and project requirements.
|
||||||
|
|
||||||
|
## 🎯 GitHub Copilot Customization Features
|
||||||
|
|
||||||
|
GitHub Copilot provides three main ways to customize AI responses and tailor assistance to your specific workflows, team guidelines, and project requirements:
|
||||||
|
|
||||||
|
| **🔧 Custom Instructions** | **📝 Reusable Prompts** | **🧩 Custom Chat Modes** |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| Define common guidelines for tasks like code generation, reviews, and commit messages. Describe *how* tasks should be performed<br><br>**Benefits:**<br>• Automatic inclusion in every chat request<br>• Repository-wide consistency<br>• Multiple implementation options | Create reusable, standalone prompts for specific tasks. Describe *what* should be done with optional task-specific guidelines<br><br>**Benefits:**<br>• Eliminate repetitive prompt writing<br>• Shareable across teams<br>• Support for variables and dependencies | Define chat behavior, available tools, and codebase interaction patterns within specific boundaries for each request<br><br>**Benefits:**<br>• Context-aware assistance<br>• Tool configuration<br>• Role-specific workflows |
|
||||||
|
|
||||||
|
> **💡 Pro Tip:** Custom instructions only affect Copilot Chat (not inline code completions). You can combine all three customization types - use custom instructions for general guidelines, prompt files for specific tasks, and chat modes to control the interaction context.
|
||||||
|
|
||||||
|
|
||||||
|
## 📝 Contributing
|
||||||
|
|
||||||
|
We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details on how to submit new instructions and prompts.`,
|
||||||
|
|
||||||
|
instructionsSection: `## 📋 Custom Instructions
|
||||||
|
|
||||||
|
Team and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:`,
|
||||||
|
|
||||||
|
instructionsUsage: `> 💡 **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.`,
|
||||||
|
|
||||||
|
promptsSection: `## 🎯 Reusable Prompts
|
||||||
|
|
||||||
|
Ready-to-use prompt templates for specific development scenarios and tasks, defining prompt text with a specific mode, model, and available set of tools.`,
|
||||||
|
|
||||||
|
promptsUsage: `> 💡 **Usage**: Use \`/prompt-name\` in VS Code chat, run \`Chat: Run Prompt\` command, or hit the run button while you have a prompt open.`,
|
||||||
|
|
||||||
|
chatmodesSection: `## 🧩 Custom Chat Modes
|
||||||
|
|
||||||
|
Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.`,
|
||||||
|
|
||||||
|
chatmodesUsage: `> 💡 **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.`,
|
||||||
|
|
||||||
|
footer: `## 📚 Additional Resources
|
||||||
|
|
||||||
|
- [VS Code Copilot Customization Documentation](https://code.visualstudio.com/docs/copilot/copilot-customization) - Official Microsoft documentation
|
||||||
|
- [GitHub Copilot Chat Documentation](https://code.visualstudio.com/docs/copilot/chat/copilot-chat) - Complete chat feature guide
|
||||||
|
- [Custom Chat Modes](https://code.visualstudio.com/docs/copilot/chat/chat-modes) - Advanced chat configuration
|
||||||
|
- [VS Code Settings](https://code.visualstudio.com/docs/getstarted/settings) - General VS Code configuration guide
|
||||||
|
|
||||||
|
## 🛠️ Development Configuration
|
||||||
|
|
||||||
|
This repository uses various configuration files to ensure consistent code style and avoid issues with line endings:
|
||||||
|
|
||||||
|
- [\`.editorconfig\`](.editorconfig) - Defines coding styles across different editors and IDEs
|
||||||
|
- [\`.gitattributes\`](.gitattributes) - Ensures consistent line endings in text files
|
||||||
|
- [\`.vscode/settings.json\`](.vscode/settings.json) - VS Code-specific settings for this repository
|
||||||
|
- [\`.vscode/extensions.json\`](.vscode/extensions.json) - Recommended VS Code extensions
|
||||||
|
|
||||||
|
> 💡 **Note**: All markdown files in this repository use LF line endings (Unix-style) to avoid mixed line endings issues. The repository is configured to automatically handle line endings conversion.
|
||||||
|
|
||||||
|
## 📄 License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||||
|
|
||||||
|
## 🤝 Code of Conduct
|
||||||
|
|
||||||
|
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||||
|
|
||||||
|
## ™️ Trademarks
|
||||||
|
|
||||||
|
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
||||||
|
trademarks or logos is subject to and must follow
|
||||||
|
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
||||||
|
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
||||||
|
Any use of third-party trademarks or logos are subject to those third-party's policies.`,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add error handling utility
|
||||||
|
function safeFileOperation(operation, filePath, defaultValue = null) {
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(filePath, "utf8");
|
return operation();
|
||||||
const lines = content.split("\n");
|
} catch (error) {
|
||||||
|
console.error(`Error processing file ${filePath}: ${error.message}`);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Step 1: Look for title in frontmatter for all file types
|
function extractTitle(filePath) {
|
||||||
let inFrontmatter = false;
|
return safeFileOperation(
|
||||||
let frontmatterEnded = false;
|
() => {
|
||||||
|
const content = fs.readFileSync(filePath, "utf8");
|
||||||
|
const lines = content.split("\n");
|
||||||
|
|
||||||
for (const line of lines) {
|
// Step 1: Look for title in frontmatter for all file types
|
||||||
if (line.trim() === "---") {
|
let inFrontmatter = false;
|
||||||
if (!inFrontmatter) {
|
let frontmatterEnded = false;
|
||||||
inFrontmatter = true;
|
|
||||||
} else if (!frontmatterEnded) {
|
|
||||||
frontmatterEnded = true;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inFrontmatter && !frontmatterEnded) {
|
|
||||||
// Look for title field in frontmatter
|
|
||||||
const titleMatch = line.match(/^title:\s*['"]?(.+?)['"]?$/);
|
|
||||||
if (titleMatch) {
|
|
||||||
return titleMatch[1].trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset for second pass
|
|
||||||
inFrontmatter = false;
|
|
||||||
frontmatterEnded = false;
|
|
||||||
|
|
||||||
// Step 2: For prompt/chatmode files, look for heading after frontmatter
|
|
||||||
if (filePath.includes(".prompt.md") || filePath.includes(".chatmode.md")) {
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.trim() === "---") {
|
if (line.trim() === "---") {
|
||||||
if (!inFrontmatter) {
|
if (!inFrontmatter) {
|
||||||
inFrontmatter = true;
|
inFrontmatter = true;
|
||||||
} else if (inFrontmatter && !frontmatterEnded) {
|
} else if (!frontmatterEnded) {
|
||||||
frontmatterEnded = true;
|
frontmatterEnded = true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frontmatterEnded && line.startsWith("# ")) {
|
if (inFrontmatter && !frontmatterEnded) {
|
||||||
|
// Look for title field in frontmatter
|
||||||
|
if (line.includes("title:")) {
|
||||||
|
// Extract everything after 'title:'
|
||||||
|
const afterTitle = line
|
||||||
|
.substring(line.indexOf("title:") + 6)
|
||||||
|
.trim();
|
||||||
|
// Remove quotes if present
|
||||||
|
const cleanTitle = afterTitle.replace(/^['"]|['"]$/g, "");
|
||||||
|
return cleanTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset for second pass
|
||||||
|
inFrontmatter = false;
|
||||||
|
frontmatterEnded = false;
|
||||||
|
|
||||||
|
// Step 2: For prompt/chatmode/instructions files, look for heading after frontmatter
|
||||||
|
if (
|
||||||
|
filePath.includes(".prompt.md") ||
|
||||||
|
filePath.includes(".chatmode.md") ||
|
||||||
|
filePath.includes(".instructions.md")
|
||||||
|
) {
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.trim() === "---") {
|
||||||
|
if (!inFrontmatter) {
|
||||||
|
inFrontmatter = true;
|
||||||
|
} else if (inFrontmatter && !frontmatterEnded) {
|
||||||
|
frontmatterEnded = true;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frontmatterEnded && line.startsWith("# ")) {
|
||||||
|
return line.substring(2).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Format filename for prompt/chatmode/instructions files if no heading found
|
||||||
|
const basename = path.basename(
|
||||||
|
filePath,
|
||||||
|
filePath.includes(".prompt.md")
|
||||||
|
? ".prompt.md"
|
||||||
|
: filePath.includes(".chatmode.md")
|
||||||
|
? ".chatmode.md"
|
||||||
|
: ".instructions.md"
|
||||||
|
);
|
||||||
|
return basename
|
||||||
|
.replace(/[-_]/g, " ")
|
||||||
|
.replace(/\b\w/g, (l) => l.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 4: For instruction files, look for the first heading
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith("# ")) {
|
||||||
return line.substring(2).trim();
|
return line.substring(2).trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Format filename for prompt/chatmode files if no heading found
|
// Step 5: Fallback to filename
|
||||||
const basename = path.basename(
|
const basename = path.basename(filePath, path.extname(filePath));
|
||||||
filePath,
|
|
||||||
filePath.includes(".prompt.md") ? ".prompt.md" : ".chatmode.md"
|
|
||||||
);
|
|
||||||
return basename
|
return basename
|
||||||
.replace(/[-_]/g, " ")
|
.replace(/[-_]/g, " ")
|
||||||
.replace(/\b\w/g, (l) => l.toUpperCase());
|
.replace(/\b\w/g, (l) => l.toUpperCase());
|
||||||
}
|
},
|
||||||
|
filePath,
|
||||||
// Step 4: For instruction files, look for the first heading
|
path
|
||||||
for (const line of lines) {
|
.basename(filePath, path.extname(filePath))
|
||||||
if (line.startsWith("# ")) {
|
|
||||||
return line.substring(2).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 5: Fallback to filename
|
|
||||||
const basename = path.basename(filePath, path.extname(filePath));
|
|
||||||
return basename
|
|
||||||
.replace(/[-_]/g, " ")
|
.replace(/[-_]/g, " ")
|
||||||
.replace(/\b\w/g, (l) => l.toUpperCase());
|
.replace(/\b\w/g, (l) => l.toUpperCase())
|
||||||
} catch (error) {
|
);
|
||||||
// Fallback to filename
|
|
||||||
const basename = path.basename(filePath, path.extname(filePath));
|
|
||||||
return basename
|
|
||||||
.replace(/[-_]/g, " ")
|
|
||||||
.replace(/\b\w/g, (l) => l.toUpperCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractDescription(filePath) {
|
function extractDescription(filePath) {
|
||||||
try {
|
return safeFileOperation(
|
||||||
const content = fs.readFileSync(filePath, "utf8");
|
() => {
|
||||||
|
const content = fs.readFileSync(filePath, "utf8");
|
||||||
|
|
||||||
// Parse frontmatter for description (for both prompts and instructions)
|
// Parse frontmatter for description (for both prompts and instructions)
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
let inFrontmatter = false;
|
let inFrontmatter = false;
|
||||||
let frontmatterEnded = false;
|
let frontmatterEnded = false;
|
||||||
|
|
||||||
// For multi-line descriptions
|
// For multi-line descriptions
|
||||||
let isMultilineDescription = false;
|
let isMultilineDescription = false;
|
||||||
let multilineDescription = [];
|
let multilineDescription = [];
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
const line = lines[i];
|
const line = lines[i];
|
||||||
|
|
||||||
if (line.trim() === "---") {
|
if (line.trim() === "---") {
|
||||||
if (!inFrontmatter) {
|
if (!inFrontmatter) {
|
||||||
inFrontmatter = true;
|
inFrontmatter = true;
|
||||||
} else if (inFrontmatter && !frontmatterEnded) {
|
} else if (inFrontmatter && !frontmatterEnded) {
|
||||||
frontmatterEnded = true;
|
frontmatterEnded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inFrontmatter && !frontmatterEnded) {
|
|
||||||
// Check for multi-line description with pipe syntax (|)
|
|
||||||
const multilineMatch = line.match(/^description:\s*\|(\s*)$/);
|
|
||||||
if (multilineMatch) {
|
|
||||||
isMultilineDescription = true;
|
|
||||||
// Continue to next line to start collecting the multi-line content
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're collecting a multi-line description
|
if (inFrontmatter && !frontmatterEnded) {
|
||||||
if (isMultilineDescription) {
|
// Check for multi-line description with pipe syntax (|)
|
||||||
// If the line has no indentation or has another frontmatter key, stop collecting
|
const multilineMatch = line.match(/^description:\s*\|(\s*)$/);
|
||||||
if (!line.startsWith(" ") || line.match(/^[a-zA-Z0-9_-]+:/)) {
|
if (multilineMatch) {
|
||||||
isMultilineDescription = false;
|
isMultilineDescription = true;
|
||||||
// Join the collected lines and return
|
// Continue to next line to start collecting the multi-line content
|
||||||
return multilineDescription.join(" ").trim();
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the line to our multi-line collection (removing the 2-space indentation)
|
// If we're collecting a multi-line description
|
||||||
multilineDescription.push(line.substring(2));
|
if (isMultilineDescription) {
|
||||||
} else {
|
// If the line has no indentation or has another frontmatter key, stop collecting
|
||||||
// Look for single-line description field in frontmatter
|
if (!line.startsWith(" ") || line.match(/^[a-zA-Z0-9_-]+:/)) {
|
||||||
const descriptionMatch = line.match(
|
isMultilineDescription = false;
|
||||||
/^description:\s*['"]?(.+?)['"]?$/
|
// Join the collected lines and return
|
||||||
);
|
return multilineDescription.join(" ").trim();
|
||||||
if (descriptionMatch) {
|
}
|
||||||
return descriptionMatch[1];
|
|
||||||
|
// Add the line to our multi-line collection (removing the 2-space indentation)
|
||||||
|
multilineDescription.push(line.substring(2));
|
||||||
|
} else {
|
||||||
|
// Look for single-line description field in frontmatter
|
||||||
|
const descriptionMatch = line.match(
|
||||||
|
/^description:\s*['"]?(.+?)['"]?$/
|
||||||
|
);
|
||||||
|
if (descriptionMatch) {
|
||||||
|
return descriptionMatch[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we've collected multi-line description but the frontmatter ended
|
// If we've collected multi-line description but the frontmatter ended
|
||||||
if (multilineDescription.length > 0) {
|
if (multilineDescription.length > 0) {
|
||||||
return multilineDescription.join(" ").trim();
|
return multilineDescription.join(" ").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (error) {
|
},
|
||||||
return null;
|
filePath,
|
||||||
}
|
null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInstructionsSection(
|
/**
|
||||||
currentReadme,
|
* Generate badges for installation links in VS Code and VS Code Insiders.
|
||||||
instructionFiles,
|
* @param {string} link - The relative link to the instructions or prompts file.
|
||||||
instructionsDir
|
* @returns {string} - Markdown formatted badges for installation.
|
||||||
) {
|
*/
|
||||||
const instructionsSection = currentReadme.match(
|
const vscodeInstallImage =
|
||||||
/## 📋 Custom Instructions\n\nTeam and project-specific instructions.+?(?=\n\n>)/s
|
"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})`
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (!instructionsSection) {
|
/**
|
||||||
return currentReadme;
|
* Generate the instructions section with a table of all instructions
|
||||||
}
|
*/
|
||||||
|
function generateInstructionsSection(instructionsDir) {
|
||||||
|
// Get all instruction files
|
||||||
|
const instructionFiles = fs
|
||||||
|
.readdirSync(instructionsDir)
|
||||||
|
.filter((file) => file.endsWith(".md"))
|
||||||
|
.sort();
|
||||||
|
|
||||||
// Extract existing instruction links from README
|
console.log(`Found ${instructionFiles.length} instruction files`);
|
||||||
const existingInstructionLinks = [];
|
|
||||||
const instructionLinkRegex = /\[.*?\]\(instructions\/(.+?)\)/g;
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = instructionLinkRegex.exec(currentReadme)) !== null) {
|
// Create table header
|
||||||
existingInstructionLinks.push(match[1]);
|
let instructionsContent =
|
||||||
}
|
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||||
|
|
||||||
// Find new instructions that aren't already in the README
|
// Generate table rows for each instruction file
|
||||||
const newInstructionFiles = instructionFiles.filter(
|
|
||||||
(file) => !existingInstructionLinks.includes(file)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (newInstructionFiles.length === 0) {
|
|
||||||
console.log("No new instructions to add.");
|
|
||||||
} else {
|
|
||||||
console.log(`Found ${newInstructionFiles.length} new instructions to add.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let instructionsListContent = "\n\n";
|
|
||||||
|
|
||||||
// Generate alphabetically sorted list of instruction links
|
|
||||||
for (const file of instructionFiles) {
|
for (const file of instructionFiles) {
|
||||||
const filePath = path.join(instructionsDir, file);
|
const filePath = path.join(instructionsDir, file);
|
||||||
const title = extractTitle(filePath);
|
const title = extractTitle(filePath);
|
||||||
@ -196,338 +298,160 @@ function updateInstructionsSection(
|
|||||||
// Check if there's a description in the frontmatter
|
// Check if there's a description in the frontmatter
|
||||||
const customDescription = extractDescription(filePath);
|
const customDescription = extractDescription(filePath);
|
||||||
|
|
||||||
if (customDescription) {
|
// Create badges for installation links
|
||||||
|
const badges = makeBadges(link, "instructions");
|
||||||
|
|
||||||
|
if (customDescription && customDescription !== "null") {
|
||||||
// Use the description from frontmatter
|
// Use the description from frontmatter
|
||||||
instructionsListContent += `- [${title}](${link}) - ${customDescription}\n`;
|
instructionsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\n`;
|
||||||
} else {
|
} else {
|
||||||
// Fallback to the default approach - use last word of title for description, removing trailing 's' if present
|
// Fallback to the default approach - use last word of title for description, removing trailing 's' if present
|
||||||
const topic = title.split(" ").pop().replace(/s$/, "");
|
const topic = title.split(" ").pop().replace(/s$/, "");
|
||||||
instructionsListContent += `- [${title}](${link}) - ${topic} specific coding standards and best practices\n`;
|
instructionsContent += `| [${title}](${link}) | ${topic} specific coding standards and best practices | ${badges} |\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the current instructions section with the updated one
|
return `${TEMPLATES.instructionsSection}\n\n${instructionsContent}\n${TEMPLATES.instructionsUsage}`;
|
||||||
const newInstructionsSection =
|
|
||||||
"## 📋 Custom Instructions\n\nTeam and project-specific instructions to enhance GitHub Copilot's behavior for specific technologies and coding practices:" +
|
|
||||||
instructionsListContent;
|
|
||||||
|
|
||||||
return currentReadme.replace(instructionsSection[0], newInstructionsSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePromptsSection(currentReadme, promptFiles, promptsDir) {
|
/**
|
||||||
// Extract existing prompt links from README
|
* Generate the prompts section with a table of all prompts
|
||||||
const existingPromptLinks = [];
|
*/
|
||||||
const promptLinkRegex = /\[.*?\]\(prompts\/(.+?)\)/g;
|
function generatePromptsSection(promptsDir) {
|
||||||
let match;
|
// Get all prompt files
|
||||||
|
|
||||||
while ((match = promptLinkRegex.exec(currentReadme)) !== null) {
|
|
||||||
existingPromptLinks.push(match[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find new prompts that aren't already in the README
|
|
||||||
const newPromptFiles = promptFiles.filter(
|
|
||||||
(file) => !existingPromptLinks.includes(file)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (newPromptFiles.length === 0) {
|
|
||||||
console.log("No new prompts to add.");
|
|
||||||
return currentReadme;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Found ${newPromptFiles.length} new prompts to add.`);
|
|
||||||
|
|
||||||
// Create content for new prompts (in Uncategorised section)
|
|
||||||
let newPromptsContent = "";
|
|
||||||
|
|
||||||
// Check if we already have an Uncategorised section
|
|
||||||
const uncategorisedSectionRegex = /### Uncategorised\n/;
|
|
||||||
const hasUncategorisedSection = uncategorisedSectionRegex.test(currentReadme);
|
|
||||||
|
|
||||||
// If we need to add the section header
|
|
||||||
if (!hasUncategorisedSection) {
|
|
||||||
newPromptsContent += "### Uncategorised\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add each new prompt
|
|
||||||
for (const file of newPromptFiles) {
|
|
||||||
const filePath = path.join(promptsDir, file);
|
|
||||||
const title = extractTitle(filePath);
|
|
||||||
const description = extractDescription(filePath);
|
|
||||||
const link = encodeURI(`prompts/${file}`);
|
|
||||||
|
|
||||||
if (description) {
|
|
||||||
newPromptsContent += `- [${title}](${link}) - ${description}\n`;
|
|
||||||
} else {
|
|
||||||
newPromptsContent += `- [${title}](${link})\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a newline if we created a new section
|
|
||||||
if (!hasUncategorisedSection) {
|
|
||||||
newPromptsContent += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the README content - insert new content in the right place
|
|
||||||
if (hasUncategorisedSection) {
|
|
||||||
// Add to existing Uncategorised section
|
|
||||||
const uncategorisedSectionPos = currentReadme.match(
|
|
||||||
uncategorisedSectionRegex
|
|
||||||
).index;
|
|
||||||
const sectionEndRegex = /\n\n/;
|
|
||||||
let sectionEndMatch = sectionEndRegex.exec(
|
|
||||||
currentReadme.slice(uncategorisedSectionPos + 16)
|
|
||||||
); // 16 is length of "### Uncategorised\n"
|
|
||||||
|
|
||||||
let insertPos;
|
|
||||||
if (sectionEndMatch) {
|
|
||||||
insertPos = uncategorisedSectionPos + 16 + sectionEndMatch.index;
|
|
||||||
} else {
|
|
||||||
// If we can't find the end of the section, just insert at the end of the section header
|
|
||||||
insertPos = uncategorisedSectionPos + 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
currentReadme.slice(0, insertPos) +
|
|
||||||
newPromptsContent +
|
|
||||||
currentReadme.slice(insertPos)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// No Uncategorised section exists yet - find where to add it
|
|
||||||
return addNewUncategorisedSection(currentReadme, newPromptsContent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addNewUncategorisedSection(currentReadme, newPromptsContent) {
|
|
||||||
// Look for the "Ready-to-use prompt templates" section and the next section after it
|
|
||||||
const promptSectionRegex =
|
|
||||||
/## 🎯 Reusable Prompts\n\nReady-to-use prompt templates/;
|
|
||||||
const promptSectionMatch = currentReadme.match(promptSectionRegex);
|
|
||||||
|
|
||||||
if (!promptSectionMatch) {
|
|
||||||
console.error("Could not find the Reusable Prompts section in the README.");
|
|
||||||
return currentReadme;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find where to insert the new section - after any existing categories
|
|
||||||
let insertPos;
|
|
||||||
// First check if there are any existing categories
|
|
||||||
const existingCategoriesRegex = /### [^\n]+\n/g;
|
|
||||||
let lastCategoryMatch = null;
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = existingCategoriesRegex.exec(currentReadme)) !== null) {
|
|
||||||
lastCategoryMatch = match;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastCategoryMatch) {
|
|
||||||
// Find the end of the last category section
|
|
||||||
const afterLastCategory = currentReadme.slice(
|
|
||||||
lastCategoryMatch.index + lastCategoryMatch[0].length
|
|
||||||
);
|
|
||||||
const nextSectionRegex = /\n\n>/;
|
|
||||||
const nextSectionMatch = afterLastCategory.match(nextSectionRegex);
|
|
||||||
|
|
||||||
if (nextSectionMatch) {
|
|
||||||
insertPos =
|
|
||||||
lastCategoryMatch.index +
|
|
||||||
lastCategoryMatch[0].length +
|
|
||||||
nextSectionMatch.index;
|
|
||||||
} else {
|
|
||||||
// If we can't find the next section, add at the end of the prompt section
|
|
||||||
insertPos = currentReadme.indexOf("> 💡 **Usage**: Use `/prompt-name`");
|
|
||||||
if (insertPos === -1) {
|
|
||||||
// Fallback position - before Additional Resources
|
|
||||||
insertPos = currentReadme.indexOf("## 📚 Additional Resources");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No categories yet, add right after the intro text
|
|
||||||
const afterIntroRegex = /prompt\` command\.\n\n/;
|
|
||||||
const afterIntroMatch = currentReadme.match(afterIntroRegex);
|
|
||||||
|
|
||||||
if (afterIntroMatch) {
|
|
||||||
insertPos = afterIntroMatch.index + afterIntroMatch[0].length;
|
|
||||||
} else {
|
|
||||||
// Fallback position - before Additional Resources
|
|
||||||
insertPos = currentReadme.indexOf("## 📚 Additional Resources");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (insertPos !== -1) {
|
|
||||||
return (
|
|
||||||
currentReadme.slice(0, insertPos) +
|
|
||||||
newPromptsContent +
|
|
||||||
currentReadme.slice(insertPos)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
console.error("Could not find a suitable place to insert new prompts.");
|
|
||||||
return currentReadme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateChatModesSection(currentReadme, chatmodeFiles, chatmodesDir) {
|
|
||||||
// No chat mode files, nothing to do
|
|
||||||
if (chatmodeFiles.length === 0) {
|
|
||||||
return currentReadme;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract existing chat mode links from README
|
|
||||||
const existingChatModeLinks = [];
|
|
||||||
const chatModeLinkRegex = /\[.*?\]\(chatmodes\/(.+?)\)/g;
|
|
||||||
let match;
|
|
||||||
|
|
||||||
while ((match = chatModeLinkRegex.exec(currentReadme)) !== null) {
|
|
||||||
existingChatModeLinks.push(match[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find new chat modes that aren't already in the README
|
|
||||||
const newChatModeFiles = chatmodeFiles.filter(
|
|
||||||
(file) => !existingChatModeLinks.includes(file)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (newChatModeFiles.length === 0) {
|
|
||||||
console.log("No new chat modes to add.");
|
|
||||||
} else {
|
|
||||||
console.log(`Found ${newChatModeFiles.length} new chat modes to add.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const chatmodesSection = currentReadme.match(
|
|
||||||
/## 🧩 Custom Chat Modes\n\nCustom chat modes define.+?(?=\n\n>)/s
|
|
||||||
);
|
|
||||||
|
|
||||||
if (chatmodesSection) {
|
|
||||||
let chatmodesListContent = "\n\n";
|
|
||||||
|
|
||||||
// Generate list of chat mode links
|
|
||||||
for (const file of chatmodeFiles) {
|
|
||||||
const filePath = path.join(chatmodesDir, file);
|
|
||||||
const title = extractTitle(filePath);
|
|
||||||
const link = encodeURI(`chatmodes/${file}`);
|
|
||||||
|
|
||||||
// Check if there's a description in the frontmatter
|
|
||||||
const customDescription = extractDescription(filePath);
|
|
||||||
|
|
||||||
if (customDescription) {
|
|
||||||
// Use the description from frontmatter
|
|
||||||
chatmodesListContent += `- [${title}](${link}) - ${customDescription}\n`;
|
|
||||||
} else {
|
|
||||||
// Just add a link without description
|
|
||||||
chatmodesListContent += `- [${title}](${link})\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace the current chat modes section with the updated one
|
|
||||||
const newChatmodesSection =
|
|
||||||
"## 🧩 Custom Chat Modes\n\nCustom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows." +
|
|
||||||
chatmodesListContent;
|
|
||||||
|
|
||||||
return currentReadme.replace(chatmodesSection[0], newChatmodesSection);
|
|
||||||
} else {
|
|
||||||
// Chat modes section doesn't exist yet but we have chat mode files
|
|
||||||
console.log(
|
|
||||||
"Creating new chat modes section with all available chat modes."
|
|
||||||
);
|
|
||||||
|
|
||||||
const chatmodesListContent = chatmodeFiles
|
|
||||||
.map((file) => {
|
|
||||||
const filePath = path.join(chatmodesDir, file);
|
|
||||||
const title = extractTitle(filePath);
|
|
||||||
const link = `chatmodes/${file}`;
|
|
||||||
const customDescription = extractDescription(filePath);
|
|
||||||
|
|
||||||
if (customDescription) {
|
|
||||||
return `- [${title}](${link}) - ${customDescription}`;
|
|
||||||
} else {
|
|
||||||
return `- [${title}](${link})`;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.join("\n");
|
|
||||||
|
|
||||||
const newChatmodesSection =
|
|
||||||
"## 🎭 Custom Chat Modes\n\n" +
|
|
||||||
"Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, enabling enhanced context-aware assistance for particular tasks or workflows.\n\n" +
|
|
||||||
chatmodesListContent +
|
|
||||||
"\n\n> 💡 **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.\n";
|
|
||||||
|
|
||||||
// Insert before Additional Resources section
|
|
||||||
const additionalResourcesPos = currentReadme.indexOf(
|
|
||||||
"## 📚 Additional Resources"
|
|
||||||
);
|
|
||||||
if (additionalResourcesPos !== -1) {
|
|
||||||
return (
|
|
||||||
currentReadme.slice(0, additionalResourcesPos) +
|
|
||||||
newChatmodesSection +
|
|
||||||
"\n" +
|
|
||||||
currentReadme.slice(additionalResourcesPos)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentReadme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateReadme() {
|
|
||||||
const instructionsDir = path.join(__dirname, "instructions");
|
|
||||||
const promptsDir = path.join(__dirname, "prompts");
|
|
||||||
const chatmodesDir = path.join(__dirname, "chatmodes");
|
|
||||||
const readmePath = path.join(__dirname, "README.md");
|
|
||||||
|
|
||||||
// Check if README file exists
|
|
||||||
if (!fs.existsSync(readmePath)) {
|
|
||||||
console.error(
|
|
||||||
"README.md not found! Please create a base README.md file first."
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the current README content
|
|
||||||
let currentReadme = fs.readFileSync(readmePath, "utf8");
|
|
||||||
|
|
||||||
// Get all instruction files
|
|
||||||
const instructionFiles = fs
|
|
||||||
.readdirSync(instructionsDir)
|
|
||||||
.filter((file) => file.endsWith(".md"))
|
|
||||||
.sort();
|
|
||||||
|
|
||||||
// Get all prompt files - we'll use this to find new prompts
|
|
||||||
const promptFiles = fs
|
const promptFiles = fs
|
||||||
.readdirSync(promptsDir)
|
.readdirSync(promptsDir)
|
||||||
.filter((file) => file.endsWith(".prompt.md"))
|
.filter((file) => file.endsWith(".prompt.md"))
|
||||||
.sort();
|
.sort();
|
||||||
|
|
||||||
// Get all chat mode files - we'll use this to update the chat modes section
|
console.log(`Found ${promptFiles.length} prompt files`);
|
||||||
const chatmodeFiles = fs.existsSync(chatmodesDir)
|
|
||||||
? fs
|
|
||||||
.readdirSync(chatmodesDir)
|
|
||||||
.filter((file) => file.endsWith(".chatmode.md"))
|
|
||||||
.sort()
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// Update instructions section
|
// Create table header
|
||||||
currentReadme = updateInstructionsSection(
|
let promptsContent =
|
||||||
currentReadme,
|
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||||
instructionFiles,
|
|
||||||
instructionsDir
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update prompts section
|
// Generate table rows for each prompt file
|
||||||
currentReadme = updatePromptsSection(currentReadme, promptFiles, promptsDir);
|
for (const file of promptFiles) {
|
||||||
|
const filePath = path.join(promptsDir, file);
|
||||||
|
const title = extractTitle(filePath);
|
||||||
|
const link = encodeURI(`prompts/${file}`);
|
||||||
|
|
||||||
// Update chat modes section
|
// Check if there's a description in the frontmatter
|
||||||
currentReadme = updateChatModesSection(
|
const customDescription = extractDescription(filePath);
|
||||||
currentReadme,
|
|
||||||
chatmodeFiles,
|
|
||||||
chatmodesDir
|
|
||||||
);
|
|
||||||
|
|
||||||
return currentReadme;
|
// Create badges for installation links
|
||||||
|
const badges = makeBadges(link, "prompt");
|
||||||
|
|
||||||
|
if (customDescription && customDescription !== "null") {
|
||||||
|
promptsContent += `| [${title}](${link}) | ${customDescription} | ${badges} |\n`;
|
||||||
|
} else {
|
||||||
|
promptsContent += `| [${title}](${link}) | | ${badges} |\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${TEMPLATES.promptsSection}\n\n${promptsContent}\n${TEMPLATES.promptsUsage}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate and write the README
|
/**
|
||||||
const updatedReadme = generateReadme();
|
* Generate the chat modes section with a table of all chat modes
|
||||||
|
*/
|
||||||
|
function generateChatModesSection(chatmodesDir) {
|
||||||
|
// Check if chatmodes directory exists
|
||||||
|
if (!fs.existsSync(chatmodesDir)) {
|
||||||
|
console.log("Chat modes directory does not exist");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// Only write file if we have content to write
|
// Get all chat mode files
|
||||||
if (updatedReadme) {
|
const chatmodeFiles = fs
|
||||||
fs.writeFileSync(path.join(__dirname, "README.md"), updatedReadme);
|
.readdirSync(chatmodesDir)
|
||||||
console.log("README.md updated successfully!");
|
.filter((file) => file.endsWith(".chatmode.md"))
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
console.log(`Found ${chatmodeFiles.length} chat mode files`);
|
||||||
|
|
||||||
|
// If no chat modes, return empty string
|
||||||
|
if (chatmodeFiles.length === 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create table header
|
||||||
|
let chatmodesContent =
|
||||||
|
"| Title | Description | Install |\n| ----- | ----------- | ------- |\n";
|
||||||
|
|
||||||
|
// Generate table rows for each chat mode file
|
||||||
|
for (const file of chatmodeFiles) {
|
||||||
|
const filePath = path.join(chatmodesDir, file);
|
||||||
|
const title = extractTitle(filePath);
|
||||||
|
const link = encodeURI(`chatmodes/${file}`);
|
||||||
|
|
||||||
|
// 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} | ${badges} |\n`;
|
||||||
|
} else {
|
||||||
|
chatmodesContent += `| [${title}](${link}) | | ${badges} |\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${TEMPLATES.chatmodesSection}\n\n${chatmodesContent}\n${TEMPLATES.chatmodesUsage}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the complete README.md content from scratch
|
||||||
|
*/
|
||||||
|
function generateReadme() {
|
||||||
|
const instructionsDir = path.join(__dirname, "instructions");
|
||||||
|
const promptsDir = path.join(__dirname, "prompts");
|
||||||
|
const chatmodesDir = path.join(__dirname, "chatmodes");
|
||||||
|
|
||||||
|
// Generate each section
|
||||||
|
const instructionsSection = generateInstructionsSection(instructionsDir);
|
||||||
|
const promptsSection = generatePromptsSection(promptsDir);
|
||||||
|
const chatmodesSection = generateChatModesSection(chatmodesDir);
|
||||||
|
|
||||||
|
// Build the complete README content with template sections
|
||||||
|
let readmeContent = [TEMPLATES.header, instructionsSection, promptsSection];
|
||||||
|
|
||||||
|
// Only include chat modes section if we have any chat modes
|
||||||
|
if (chatmodesSection) {
|
||||||
|
readmeContent.push(chatmodesSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add footer
|
||||||
|
readmeContent.push(TEMPLATES.footer);
|
||||||
|
|
||||||
|
return readmeContent.join("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main execution
|
||||||
|
try {
|
||||||
|
console.log("Generating README.md from scratch...");
|
||||||
|
|
||||||
|
const readmePath = path.join(__dirname, "README.md");
|
||||||
|
const newReadmeContent = generateReadme();
|
||||||
|
|
||||||
|
// Check if the README file already exists
|
||||||
|
if (fs.existsSync(readmePath)) {
|
||||||
|
const originalContent = fs.readFileSync(readmePath, "utf8");
|
||||||
|
const hasChanges = originalContent !== newReadmeContent;
|
||||||
|
|
||||||
|
if (hasChanges) {
|
||||||
|
fs.writeFileSync(readmePath, newReadmeContent);
|
||||||
|
console.log("README.md updated successfully!");
|
||||||
|
} else {
|
||||||
|
console.log("README.md is already up to date. No changes needed.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Create the README file if it doesn't exist
|
||||||
|
fs.writeFileSync(readmePath, newReadmeContent);
|
||||||
|
console.log("README.md created successfully!");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error generating README.md: ${error.message}`);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user