Skip to content

NikiforovAll/dotnet-copilot-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 .NET GitHub Copilot Rules

A collection of GitHub Copilot AI rules for .NET development best practices.

Tip

You can enhance Copilot's chat responses by providing it with contextual details about your team's workflow, tools, or project specifics.

📚 Customizations: Instructions, Prompts, MCPs, etc.

This set of rules is a good starting point and should be customized to fit your specific needs. You can add or remove rules as necessary.

💻 .NET Development

Rules for writing clean, maintainable C# code:

  • ✨ Modern C# coding patterns
  • 🧪 Testing best practices
  • 📁 Code organization
  • 🛡️ Error handling
  • 🔌 Dependency management

Git

Tools

Here is my top content extraction tools for GitHub Copilot:

  • #fetch - fetch web page
  • #githubRepo - fetch remote GitHub repository
  • #context7 - fetch docs
  • #codebase - work with the code base

How to Use This Repository

Copy the relevant instructions you want to use into your project's .vscode/instructions directory and configure github.copilot.chat.codeGeneration.instructions if needed.

Here is an example of how to set up your .vscode/settings.json file:

{
  "chat.promptFiles": true,
  "chat.promptFilesLocations": {
    ".vscode/prompts": true
  },
  "chat.instructionsFilesLocations": {
    ".vscode/instructions": true
  },
  "github.copilot.chat.codeGeneration.instructions": [],
  "github.copilot.chat.commitMessageGeneration.instructions": [
    {
      "file": ".vscode/git-message.instructions.md"
    }
  ],
  "github.copilot.chat.reviewSelection.enabled": true,
  "github.copilot.chat.reviewSelection.instructions": [
    {
      "file": ".vscode/instructions/coding-guidelines.instructions.md"
    },
    {
      "file": ".vscode/instructions/coding-style.instructions.md"
    }
  ],
  "github.copilot.chat.testGeneration.instructions": [
    {
      "file": ".vscode/instructions/testing-xunit.instructions.md"
    }
  ]
}

🚀 Motivation

Productivity

You can create reusable instructions and prompts for your team to handle common tasks and GenAI scenarios effectively.

Coding with Agents in Mind

Shift your mindset from being a code typist to an AI operator when appropriate. Start with an instruction prompt and gather as much context as possible. Once you clearly understand the task, determine the level of AI assistance needed.

💡 To stay in the "Productivity Zone", gain experience with various AI models.

Treat AI as a Teammate

Building a successful, maintainable project requires clean, idiomatic, and consistent code. This is where coding guidelines are essential. They:

  • Promote consistency, readability, and maintainability.
  • Streamline collaboration and reduce technical debt.
  • Provide context for AI tools, ensuring generated code aligns with project standards.

Without clear guidelines, AI contributions may introduce inconsistencies, increasing maintenance overhead.

Documentation

Document your coding guidelines so it can be consumed by AI tools. Not only can it be used for additional context for code generation, but also now you can chat with LLMs about your coding guidelines. It becomes integral part of your project.

💡 For example, you can ask Copilot to review your code, and it will refer to the guidelines you provided.

Agent Mode

With the introduction of Agent Mode, clear guidelines are crucial. They ensure consistency and independence in AI-generated contributions.

Changelog:

Blogs

💳 Credits

Inspired by https://github.com/Aaronontheweb/dotnet-cursor-rules

About

A collection of GitHub Copilot AI rules for .NET development best practices.

Topics

Resources

License

Stars

Watchers

Forks