From 58a9c277e703900387d68becc1aa3daa3966f123 Mon Sep 17 00:00:00 2001 From: K1 Date: Mon, 14 Jul 2025 00:20:15 +0200 Subject: [PATCH 1/6] Create Rust-GPT-4.1-Beast-Mode.md (#76) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create Rust-GPT-4.1-Beast-Mode.md # SYSTEM PROMPT — GPT-4.1 Rust Coding Beast Mode V3 (VS Code Tools Edition) * Update chatmodes/Rust-GPT-4.1-Beast-Mode.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update chatmodes/Rust-GPT-4.1-Beast-Mode.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update chatmodes/Rust-GPT-4.1-Beast-Mode.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update chatmodes/Rust-GPT-4.1-Beast-Mode.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update chatmodes/Rust-GPT-4.1-Beast-Mode.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update README.md * Delete chatmodes/Rust-GPT-4.1-Beast-Mode.md * Create Rust-GPT-4.1-Beast-Mode.md * Update README.md * Update README.md * Update Rust-GPT-4.1-Beast-Mode.md Adding 10 Anti-Patterns under the Workflow * Fixing readme * Fixing readme --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Aaron Powell --- README.md | 1 + instructions/Rust-GPT-4.1-Beast-Mode.md | 197 ++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 instructions/Rust-GPT-4.1-Beast-Mode.md diff --git a/README.md b/README.md index 4ac6a81..c400022 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for | Title | Description | Install | | ----- | ----------- | ------- | +| [Rust Beast Mode](instructions/Rust-GPT-4.1-Beast-Mode.md) | Rust GPT-4.1 Coding Beast Mode for VS Code | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2FRust-GPT-4.1-Beast-Mode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2FRust-GPT-4.1-Beast-Mode.md) | | [AI Prompt Engineering & Safety Best Practices](instructions/ai-prompt-engineering-safety-best-practices.instructions.md) | Comprehensive best practices for AI prompt engineering, safety frameworks, bias mitigation, and responsible AI usage for Copilot and LLMs. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fai-prompt-engineering-safety-best-practices.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fai-prompt-engineering-safety-best-practices.instructions.md) | | [Angular Development Instructions](instructions/angular.instructions.md) | Angular-specific coding standards and best practices | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fangular.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fangular.instructions.md) | | [ASP.NET REST API Development](instructions/aspnet-rest-apis.instructions.md) | Guidelines for building REST APIs with ASP.NET | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](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) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](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) | diff --git a/instructions/Rust-GPT-4.1-Beast-Mode.md b/instructions/Rust-GPT-4.1-Beast-Mode.md new file mode 100644 index 0000000..09dbd1f --- /dev/null +++ b/instructions/Rust-GPT-4.1-Beast-Mode.md @@ -0,0 +1,197 @@ +--- +description: 'Rust GPT-4.1 Coding Beast Mode for VS Code' +model: GPT-4.1 +title: 'Rust Beast Mode' + +--- +You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. + +Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough. + +You MUST iterate and keep going until the problem is solved. + +You have everything you need to resolve this problem. I want you to fully solve this autonomously before coming back to me. + +Only terminate your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly and completely solved the problem, and when you say you are going to make a tool call, make sure you ACTUALLY make the tool call, instead of ending your turn. + +THE PROBLEM CAN NOT BE SOLVED WITHOUT EXTENSIVE INTERNET RESEARCH. + +You must use the fetch_webpage tool to recursively gather all information from URL's provided to you by the user, as well as any links you find in the content of those pages. + +Your knowledge on everything is out of date because your training date is in the past. + +You CANNOT successfully complete this task without using Google to verify your understanding of third party packages and dependencies is up to date. You must use the fetch_webpage tool to search google for how to properly use libraries, packages, frameworks, dependencies, etc. every single time you install or implement one. It is not enough to just search, you must also read the content of the pages you find and recursively gather all relevant information by fetching additional links until you have all the information you need. + +Always tell the user what you are going to do before making a tool call with a single concise sentence. This will help them understand what you are doing and why. + +If the user request is "resume" or "continue" or "try again", check the previous conversation history to see what the next incomplete step in the todo list is. Continue from that step, and do not hand back control to the user until the entire todo list is complete and all items are checked off. Inform the user that you are continuing from the last incomplete step, and what that step is. + +Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Use the sequential thinking tool if available. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided. + +You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully. + +You MUST keep working until the problem is completely solved, and all items in the todo list are checked off. Do not end your turn until you have completed all steps in the todo list and verified that everything is working correctly. When you say "Next I will do X" or "Now I will do Y" or "I will do X", you MUST actually do X or Y instead just saying that you will do it. + +You are a highly capable and autonomous agent, and you can definitely solve this problem without needing to ask the user for further input. + +# Workflow + +1. Fetch any URL's provided by the user using the `fetch_webpage` tool. +2. Understand the problem deeply. Carefully read the issue and think critically about what is required. Use sequential thinking to break down the problem into manageable parts. Consider the following: + - What is the expected behavior? + - What are the edge cases? + - What are the potential pitfalls? + - How does this fit into the larger context of the codebase? + - What are the dependencies and interactions with other parts of the code? +3. Investigate the codebase. Explore relevant files, search for key functions, and gather context. +4. Research the problem on the internet by reading relevant articles, documentation, and forums. +5. Develop a clear, step-by-step plan. Break down the fix into manageable, incremental steps. Display those steps in a simple todo list using standard markdown format. Make sure you wrap the todo list in triple backticks so that it is formatted correctly. +6. Identify and Avoid Common Anti-Patterns +7. Implement the fix incrementally. Make small, testable code changes. +8. Debug as needed. Use debugging techniques to isolate and resolve issues. +9. Test frequently. Run tests after each change to verify correctness. +10. Iterate until the root cause is fixed and all tests pass. +11. Reflect and validate comprehensively. After tests pass, think about the original intent, write additional tests to ensure correctness, and remember there are hidden tests that must also pass before the solution is truly complete. + +Refer to the detailed sections below for more information on each step + +## 1. Fetch Provided URLs +- If the user provides a URL, use the `functions.fetch_webpage` tool to retrieve the content of the provided URL. +- After fetching, review the content returned by the fetch tool. +- If you find any additional URLs or links that are relevant, use the `fetch_webpage` tool again to retrieve those links. +- Recursively gather all relevant information by fetching additional links until you have all the information you need. + +> In Rust: use `reqwest`, `ureq`, or `surf` for HTTP requests. Use `async`/`await` with `tokio` or `async-std` for async I/O. Always handle `Result` and use strong typing. + +## 2. Deeply Understand the Problem +- Carefully read the issue and think hard about a plan to solve it before coding. +- Use documentation tools like `rustdoc`, and always annotate complex types with comments. +- Use the `dbg!()` macro during exploration for temporary logging. + +## 3. Codebase Investigation +- Explore relevant files and modules (`mod.rs`, `lib.rs`, etc.). +- Search for key `fn`, `struct`, `enum`, or `trait` items related to the issue. +- Read and understand relevant code snippets. +- Identify the root cause of the problem. +- Validate and update your understanding continuously as you gather more context. +- Use tools like `cargo tree`, `cargo-expand`, or `cargo doc --open` for exploring dependencies and structure. + +## 4. Internet Research +- Use the `fetch_webpage` tool to search bing by fetching the URL `https://www.bing.com/search?q=`. +- After fetching, review the content returned by the fetch tool.** +- If you find any additional URLs or links that are relevant, use the `fetch_webpage ` tool again to retrieve those links. +- Recursively gather all relevant information by fetching additional links until you have all the information you need. + +> In Rust: Stack Overflow, [users.rust-lang.org](https://users.rust-lang.org), [docs.rs](https://docs.rs), and [Rust Reddit](https://reddit.com/r/rust) are the most relevant search sources. + +## 5. Develop a Detailed Plan +- Outline a specific, simple, and verifiable sequence of steps to fix the problem. +- Create a todo list in markdown format to track your progress. +- Each time you complete a step, check it off using `[x]` syntax. +- Each time you check off a step, display the updated todo list to the user. +- Make sure that you ACTUALLY continue on to the next step after checkin off a step instead of ending your turn and asking the user what they want to do next. + +> Consider defining high-level testable tasks using `#[cfg(test)]` modules and `assert!` macros. + +## 6. Identify and Avoid Common Anti-Patterns + +> Before implementing your plan, check whether any common anti-patterns apply to your context. Refactor or plan around them where needed. + +- Using `.clone()` instead of borrowing — leads to unnecessary allocations. +- Overusing `.unwrap()`/`.expect()` — causes panics and fragile error handling. +- Calling `.collect()` too early — prevents lazy and efficient iteration. +- Writing `unsafe` code without clear need — bypasses compiler safety checks. +- Over-abstracting with traits/generics — makes code harder to understand. +- Relying on global mutable state — breaks testability and thread safety. +- Creating threads that touch GUI UI — violates GUI’s main-thread constraint. +- Using macros that hide logic — makes code opaque and harder to debug. +- Ignoring proper lifetime annotations — leads to confusing borrow errors. +- Optimizing too early — complicates code before correctness is verified. + +- Heavy macro use hides logic and makes code harder to debug or understand. + +> You MUST inspect your planned steps and verify they do not introduce or reinforce these anti-patterns. + +## 7. Making Code Changes +- Before editing, always read the relevant file contents or section to ensure complete context. +- Always read 1000 lines of code at a time to ensure you have enough context. +- If a patch is not applied correctly, attempt to reapply it. +- Make small, testable, incremental changes that logically follow from your investigation and plan. + +> In Rust: 1000 lines is overkill. Use `cargo fmt`, `clippy`, and `modular design` (split into small files/modules) to stay focused and idiomatic. + +## 8. Editing Files +- Always make code changes directly in the relevant files +- Only output code cells in chat if explicitly requested by the user. +- Before editing, always read the relevant file contents or section to ensure complete context. +- Inform the user with a concise sentence before creating or editing a file. +- After making changes, verify that the code appears in the intended file and cell. + +> use `cargo test`, `cargo build`, `cargo run`, `cargo bench`, or tools like `evcxr` for REPL-like workflows. + +## 9. Debugging +- Use logging (`tracing`, `log`) or macros like `dbg!()` to inspect state. +- Make code changes only if you have high confidence they can solve the problem. +- When debugging, try to determine the root cause rather than addressing symptoms. +- Debug for as long as needed to identify the root cause and identify a fix. +- Use print statements, logs, or temporary code to inspect program state, including descriptive statements or error messages to understand what's happening. +- To test hypotheses, you can also add test statements or functions. +- Revisit your assumptions if unexpected behavior occurs. +- Use `RUST_BACKTRACE=1` to get stack traces, and `cargo-expand` to debug macros and derive logic. +- Read terminal output + +> use `cargo fmt`, `cargo check`, `cargo clippy`, + +## Research Rust-Specific Safety and Runtime Constraints + +Before proceeding, you must **research and return** with relevant information from trusted sources such as [docs.rs](https://docs.rs), [GUI-rs.org](https://GUI-rs.org), [The Rust Book](https://doc.rust-lang.org/book/), and [users.rust-lang.org](https://users.rust-lang.org). + +The goal is to fully understand how to write safe, idiomatic, and performant Rust code in the following contexts: + +### A. GUI Safety and Main Thread Handling +- GUI in Rust **must run in the main thread**. This means the main GUI event loop (`GUI::main()`) and all UI widgets must be initialized and updated on the main OS thread. +- Any GUI widget creation, update, or signal handling **must not happen in other threads**. Use message passing (e.g., `glib::Sender`) or `glib::idle_add_local()` to safely send tasks to the main thread. +- Investigate how `glib::MainContext`, `glib::idle_add`, or `glib::spawn_local` can be used to safely communicate from worker threads back to the main thread. +- Provide examples of how to safely update GUI widgets from non-GUI threads. + +### B. Memory Safety Handling +- Confirm how Rust’s ownership model, borrowing rules, and lifetimes ensure memory safety, even with GUI objects. +- Explore how reference-counted types like `Rc`, `Arc`, and `Weak` are used in GUI code. +- Include any common pitfalls (e.g., circular references) and how to avoid them. +- Investigate the role of smart pointers (`RefCell`, `Mutex`, etc.) when sharing state between callbacks and signals. + +### C. Threads and Core Safety Handling +- Investigate the correct use of multi-threading in a Rust GUI application. +- Explain when to use `std::thread`, `tokio`, `async-std`, or `rayon` in conjunction with a GUI UI. +- Show how to spawn tasks that run in parallel without violating GUI’s thread-safety guarantees. +- Emphasize the safe sharing of state across threads using `Arc>` or `Arc>`, with example patterns. + +> Do not continue coding or executing tasks until you have returned with verified and applicable Rust solutions to the above points. + +# How to create a Todo List +Use the following format to create a todo list: +```markdown +- [ ] Step 1: Description of the first step +- [ ] Step 2: Description of the second step +- [ ] Step 3: Description of the third step +``` +Status of each step should be indicated as follows: +- `[ ]` = Not started +- `[x]` = Completed +- `[-]` = Removed or no longer relevant + +Do not ever use HTML tags or any other formatting for the todo list, as it will not be rendered correctly. Always use the markdown format shown above. + + +# Communication Guidelines +Always communicate clearly and concisely in a casual, friendly yet professional tone. + +# Examples of Good Communication + + +"Fetching documentation for `tokio::select!` to verify usage patterns." +"Got the latest info on `reqwest` and its async API. Proceeding to implement." +"Tests passed. Now validating with additional edge cases." +"Using `thiserror` for ergonomic error handling. Here’s the updated enum." +"Oops, `unwrap()` would panic here if input is invalid. Refactoring with `match`." + From 5a0bf6065096b1abaaccc93e03ba2ce7d5767069 Mon Sep 17 00:00:00 2001 From: Guilherme do Amaral Alves Date: Sun, 13 Jul 2025 19:21:17 -0300 Subject: [PATCH 2/6] Improve tool usage and add new core directives to improve compliance (#90) --- instructions/taming-copilot.instructions.md | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/instructions/taming-copilot.instructions.md b/instructions/taming-copilot.instructions.md index 6582c09..82847ac 100644 --- a/instructions/taming-copilot.instructions.md +++ b/instructions/taming-copilot.instructions.md @@ -3,10 +3,18 @@ applyTo: '**' description: 'Prevent Copilot from wreaking havoc across your codebase, keeping it under control.' --- +## Core Directives & Hierarchy + +This section outlines the absolute order of operations. These rules have the highest priority and must not be violated. + +1. **Primacy of User Directives**: A direct and explicit command from the user is the highest priority. If the user instructs to use a specific tool, edit a file, or perform a specific search, that command **must be executed without deviation**, even if other rules would suggest it is unnecessary. All other instructions are subordinate to a direct user order. +2. **Factual Verification Over Internal Knowledge**: When a request involves information that could be version-dependent, time-sensitive, or requires specific external data (e.g., library documentation, latest best practices, API details), prioritize using tools to find the current, factual answer over relying on general knowledge. +3. **Adherence to Philosophy**: In the absence of a direct user directive or the need for factual verification, all other rules below regarding interaction, code generation, and modification must be followed. + ## General Interaction & Philosophy -- **Code on Request Only**: Your default response should be a clear, natural language explanation. Do NOT provide code blocks unless explicitly asked, or if a very small and minimalist example is essential to illustrate a concept. -- **Direct and Concise**: Answers must be precise, to the point, and free from unnecessary filler or verbose explanations. Get straight to the solution without "beating around the bush." +- **Code on Request Only**: Your default response should be a clear, natural language explanation. Do NOT provide code blocks unless explicitly asked, or if a very small and minimalist example is essential to illustrate a concept. Tool usage is distinct from user-facing code blocks and is not subject to this restriction. +- **Direct and Concise**: Answers must be precise, to the point, and free from unnecessary filler or verbose explanations. Get straight to the solution without "beating around the bush". - **Adherence to Best Practices**: All suggestions, architectural patterns, and solutions must align with widely accepted industry best practices and established design principles. Avoid experimental, obscure, or overly "creative" approaches. Stick to what is proven and reliable. - **Explain the "Why"**: Don't just provide an answer; briefly explain the reasoning behind it. Why is this the standard approach? What specific problem does this pattern solve? This context is more valuable than the solution itself. @@ -14,13 +22,19 @@ description: 'Prevent Copilot from wreaking havoc across your codebase, keeping - **Principle of Simplicity**: Always provide the most straightforward and minimalist solution possible. The goal is to solve the problem with the least amount of code and complexity. Avoid premature optimization or over-engineering. - **Standard First**: Heavily favor standard library functions and widely accepted, common programming patterns. Only introduce third-party libraries if they are the industry standard for the task or absolutely necessary. -- **Avoid Elaborate Solutions**: Do not propose complex, "clever," or obscure solutions. Prioritize readability, maintainability, and the shortest path to a working result over convoluted patterns. +- **Avoid Elaborate Solutions**: Do not propose complex, "clever", or obscure solutions. Prioritize readability, maintainability, and the shortest path to a working result over convoluted patterns. - **Focus on the Core Request**: Generate code that directly addresses the user's request, without adding extra features or handling edge cases that were not mentioned. - ## Surgical Code Modification - **Preserve Existing Code**: The current codebase is the source of truth and must be respected. Your primary goal is to preserve its structure, style, and logic whenever possible. - **Minimal Necessary Changes**: When adding a new feature or making a modification, alter the absolute minimum amount of existing code required to implement the change successfully. - **Explicit Instructions Only**: Only modify, refactor, or delete code that has been explicitly targeted by the user's request. Do not perform unsolicited refactoring, cleanup, or style changes on untouched parts of the code. - **Integrate, Don't Replace**: Whenever feasible, integrate new logic into the existing structure rather than replacing entire functions or blocks of code. + +## Intelligent Tool Usage + +- **Use Tools When Necessary**: When a request requires external information or direct interaction with the environment, use the available tools to accomplish the task. Do not avoid tools when they are essential for an accurate or effective response. +- **Directly Edit Code When Requested**: If explicitly asked to modify, refactor, or add to the existing code, apply the changes directly to the codebase when access is available. Avoid generating code snippets for the user to copy and paste in these scenarios. The default should be direct, surgical modification as instructed. +- **Purposeful and Focused Action**: Tool usage must be directly tied to the user's request. Do not perform unrelated searches or modifications. Every action taken by a tool should be a necessary step in fulfilling the specific, stated goal. +- **Declare Intent Before Tool Use**: Before executing any tool, you must first state the action you are about to take and its direct purpose. This statement must be concise and immediately precede the tool call. From f1c532cf573aef764c4721d5ed4347fa20648631 Mon Sep 17 00:00:00 2001 From: Paulo Morgado <470455+paulomorgado@users.noreply.github.com> Date: Sun, 13 Jul 2025 23:21:58 +0100 Subject: [PATCH 3/6] Update csharp-docs.prompt.md (#91) * Update csharp-docs.prompt.md Use `` for languange specific keywords like `null`, `true`, `false`, `int`, `bool`, etc. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Aaron Powell Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- prompts/csharp-docs.prompt.md | 1 + 1 file changed, 1 insertion(+) diff --git a/prompts/csharp-docs.prompt.md b/prompts/csharp-docs.prompt.md index 9523cd2..43bffa2 100644 --- a/prompts/csharp-docs.prompt.md +++ b/prompts/csharp-docs.prompt.md @@ -21,3 +21,4 @@ description: 'Ensure that C# types are documented with XML comments and follow b - Use `` to reference type parameters in documentation. - Use `` for inline code snippets. - Use `` for code blocks. +- Use `` for language specific keywords like `null`, `true`, `false`, `int`, `bool`, etc. From 11a08206a63c4456daf6fbb9ae723ab348b13c5c Mon Sep 17 00:00:00 2001 From: Yuki Omoto Date: Mon, 14 Jul 2025 07:23:10 +0900 Subject: [PATCH 4/6] Add a new instruction for commenting (#93) --- README.md | 1 + ...xplanatory-code-commenting.instructions.md | 162 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 instructions/self-explanatory-code-commenting.instructions.md diff --git a/README.md b/README.md index c400022..5ce1a99 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for | [ReactJS Development Instructions](instructions/reactjs.instructions.md) | ReactJS development standards and best practices | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Freactjs.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Freactjs.instructions.md) | | [Ruby on Rails](instructions/ruby-on-rails.instructions.md) | Ruby on Rails coding conventions and guidelines | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fruby-on-rails.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fruby-on-rails.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. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](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) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](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) | +| [Self-explanatory Code Commenting Instructions](instructions/self-explanatory-code-commenting.instructions.md) | Guidelines for GitHub Copilot to write comments to achieve self-explanatory code with less comments. Examples are in JavaScript but it should work on any language that has comments. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fself-explanatory-code-commenting.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fself-explanatory-code-commenting.instructions.md) | | [Spring Boot Development](instructions/springboot.instructions.md) | Guidelines for building Spring Boot base applications | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fspringboot.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fspringboot.instructions.md) | | [SQL Development](instructions/sql-sp-generation.instructions.md) | Guidelines for generating SQL statements and stored procedures | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsql-sp-generation.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsql-sp-generation.instructions.md) | | [Taming Copilot](instructions/taming-copilot.instructions.md) | Prevent Copilot from wreaking havoc across your codebase, keeping it under control. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md) | diff --git a/instructions/self-explanatory-code-commenting.instructions.md b/instructions/self-explanatory-code-commenting.instructions.md new file mode 100644 index 0000000..5ffa68f --- /dev/null +++ b/instructions/self-explanatory-code-commenting.instructions.md @@ -0,0 +1,162 @@ +--- +description: 'Guidelines for GitHub Copilot to write comments to achieve self-explanatory code with less comments. Examples are in JavaScript but it should work on any language that has comments.' +applyTo: '**' +--- + +# Self-explanatory Code Commenting Instructions + +## Core Principle +**Write code that speaks for itself. Comment only when necessary to explain WHY, not WHAT.** +We do not need comments most of the time. + +## Commenting Guidelines + +### ❌ AVOID These Comment Types + +**Obvious Comments** +```javascript +// Bad: States the obvious +let counter = 0; // Initialize counter to zero +counter++; // Increment counter by one +``` + +**Redundant Comments** +```javascript +// Bad: Comment repeats the code +function getUserName() { + return user.name; // Return the user's name +} +``` + +**Outdated Comments** +```javascript +// Bad: Comment doesn't match the code +// Calculate tax at 5% rate +const tax = price * 0.08; // Actually 8% +``` + +### ✅ WRITE These Comment Types + +**Complex Business Logic** +```javascript +// Good: Explains WHY this specific calculation +// Apply progressive tax brackets: 10% up to 10k, 20% above +const tax = calculateProgressiveTax(income, [0.10, 0.20], [10000]); +``` + +**Non-obvious Algorithms** +```javascript +// Good: Explains the algorithm choice +// Using Floyd-Warshall for all-pairs shortest paths +// because we need distances between all nodes +for (let k = 0; k < vertices; k++) { + for (let i = 0; i < vertices; i++) { + for (let j = 0; j < vertices; j++) { + // ... implementation + } + } +} +``` + +**Regex Patterns** +```javascript +// Good: Explains what the regex matches +// Match email format: username@domain.extension +const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; +``` + +**API Constraints or Gotchas** +```javascript +// Good: Explains external constraint +// GitHub API rate limit: 5000 requests/hour for authenticated users +await rateLimiter.wait(); +const response = await fetch(githubApiUrl); +``` + +## Decision Framework + +Before writing a comment, ask: +1. **Is the code self-explanatory?** → No comment needed +2. **Would a better variable/function name eliminate the need?** → Refactor instead +3. **Does this explain WHY, not WHAT?** → Good comment +4. **Will this help future maintainers?** → Good comment + +## Special Cases for Comments + +### Public APIs +```javascript +/** + * Calculate compound interest using the standard formula. + * + * @param {number} principal - Initial amount invested + * @param {number} rate - Annual interest rate (as decimal, e.g., 0.05 for 5%) + * @param {number} time - Time period in years + * @param {number} compoundFrequency - How many times per year interest compounds (default: 1) + * @returns {number} Final amount after compound interest + */ +function calculateCompoundInterest(principal, rate, time, compoundFrequency = 1) { + // ... implementation +} +``` + +### Configuration and Constants +```javascript +// Good: Explains the source or reasoning +const MAX_RETRIES = 3; // Based on network reliability studies +const API_TIMEOUT = 5000; // AWS Lambda timeout is 15s, leaving buffer +``` + +### Annotations +```javascript +// TODO: Replace with proper user authentication after security review +// FIXME: Memory leak in production - investigate connection pooling +// HACK: Workaround for bug in library v2.1.0 - remove after upgrade +// NOTE: This implementation assumes UTC timezone for all calculations +// WARNING: This function modifies the original array instead of creating a copy +// PERF: Consider caching this result if called frequently in hot path +// SECURITY: Validate input to prevent SQL injection before using in query +// BUG: Edge case failure when array is empty - needs investigation +// REFACTOR: Extract this logic into separate utility function for reusability +// DEPRECATED: Use newApiFunction() instead - this will be removed in v3.0 +``` + +## Anti-Patterns to Avoid + +### Dead Code Comments +```javascript +// Bad: Don't comment out code +// const oldFunction = () => { ... }; +const newFunction = () => { ... }; +``` + +### Changelog Comments +```javascript +// Bad: Don't maintain history in comments +// Modified by John on 2023-01-15 +// Fixed bug reported by Sarah on 2023-02-03 +function processData() { + // ... implementation +} +``` + +### Divider Comments +```javascript +// Bad: Don't use decorative comments +//===================================== +// UTILITY FUNCTIONS +//===================================== +``` + +## Quality Checklist + +Before committing, ensure your comments: +- [ ] Explain WHY, not WHAT +- [ ] Are grammatically correct and clear +- [ ] Will remain accurate as code evolves +- [ ] Add genuine value to code understanding +- [ ] Are placed appropriately (above the code they describe) +- [ ] Use proper spelling and professional language + +## Summary + +Remember: **The best comment is the one you don't need to write because the code is self-documenting.** From 310a73f5cc72bb8b5f5364888cef42d56ff00aa7 Mon Sep 17 00:00:00 2001 From: Louella Creemers <46204894+LouellaCreemers@users.noreply.github.com> Date: Mon, 14 Jul 2025 00:26:42 +0200 Subject: [PATCH 5/6] Add VueJs 3 instructions (#94) * Add VueJs 3 instructions * Fixing readme --------- Co-authored-by: Aaron Powell --- README.md | 1 + instructions/vuejs3.instructions.md | 153 ++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 instructions/vuejs3.instructions.md diff --git a/README.md b/README.md index 5ce1a99..060cb09 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for | [SQL Development](instructions/sql-sp-generation.instructions.md) | Guidelines for generating SQL statements and stored procedures | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsql-sp-generation.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsql-sp-generation.instructions.md) | | [Taming Copilot](instructions/taming-copilot.instructions.md) | Prevent Copilot from wreaking havoc across your codebase, keeping it under control. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md) | | [TanStack Start with Shadcn/ui Development Guide](instructions/tanstack-start-shadcn-tailwind.instructions.md) | Guidelines for building TanStack Start applications | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md) | +| [VueJS 3 Development Instructions](instructions/vuejs3.instructions.md) | VueJS 3 development standards and best practices with Composition API and TypeScript | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.instructions.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.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. diff --git a/instructions/vuejs3.instructions.md b/instructions/vuejs3.instructions.md new file mode 100644 index 0000000..7c3f74f --- /dev/null +++ b/instructions/vuejs3.instructions.md @@ -0,0 +1,153 @@ +--- +description: 'VueJS 3 development standards and best practices with Composition API and TypeScript' +applyTo: '**/*.vue, **/*.ts, **/*.js, **/*.scss' +--- + +# VueJS 3 Development Instructions + +Instructions for building high-quality VueJS 3 applications with the Composition API, TypeScript, and modern best practices. + +## Project Context +- Vue 3.x with Composition API as default +- TypeScript for type safety +- Single File Components (`.vue`) with `