The One File That Makes GitHub Copilot Feel Like a Senior Dev
Stop fixing Copilot’s mistakes and start getting clean, consistent .NET code.
Have you ever used GitHub Copilot and felt great at the start, but after a few minutes, your code turned into a random pile of ideas?
You start clean.
Then Copilot switches style.
Then it rewrites patterns.
Then it forgets what you wanted.
Suddenly, your project feels messy.
Good news. There is a simple fix.
There is one file you can add that teaches Copilot your rules. After that, it writes cleaner and more consistent code that matches the way you build apps.
Let’s walk through it.
A quick note
If you want to learn how to build complete .NET AI-powered apps step by step, including Blazor UI, EF Core, Vertical Slice Architecture, Copilot workflows, and OpenAI integrations, I just launched a new course called:
👉 .NET Web Development with AI & Copilot
There is a big launch discount ending today!
Why This Trick Works
Copilot is smart. But it does not know your preferences.
Maybe you always use:
Controllers
Dependency injection
Repository and service layers
DTOs
XML comments
Or you want to see a plan before writing code.
Without instructions, Copilot guesses. Sometimes it guesses wrong.
But Copilot has a hidden feature called Custom Instructions. When you turn it on, it will read a file named:
.github/copilot-instructions.mdThis file becomes your project’s coding rulebook.
Step 1: Turn On Custom Instructions
In Visual Studio:
Open the Copilot chat window
Go to Options
Turn on this option: Enable custom instructions
Once it is enabled, Copilot will check that file automatically.
Step 2: Let Copilot Write The File For You
You could write this file yourself. But Copilot is great at creating the base for it.
Open the chat and send something like:
Please create a GitHub Copilot instructions file for this project with the following rules:
- Always use controllers for API endpoints
- Always use dependency injection
- Use the repository pattern
- Add XML summary comments
- Use DTOs where it makes sense
- Use separate files for each class, interface, and DTO
- Always show a plan first before writing code
- Follow best practices and clean code principlesYou can go even deeper.
For example:
Vertical Slice Architecture folders
Mediator pattern
EF Core usage
Naming rules
Testing expectations
The file should appear in your project within seconds.
Step 3: Test It With a Prompt
Now try something simple like:
Please create a CRUD API for a video game library.If the instructions are working, Copilot will not write code right away.
It will first say something like:
Here is the plan.
Then it will outline:
The model
DTOs
Repository
Service
Controller
Patterns used
And only begin coding if you tell it to.
This is the moment where Copilot stops guessing and starts behaving like a teammate.
Step 4: Add Test Requests
Once the CRUD feature is done, ask:
Please add all CRUD requests to the .http file so I can test them.Copilot will update your .http file, and you can test everything right inside Visual Studio.
The Result
With one file, you get:
Cleaner code
Consistent structure
Fewer rewrites
Better communication
Faster development
Copilot follows the rules and keeps the project aligned.
No more random patterns.
No more switching architectures halfway through.
No more chaos.
Want To Go Further?
If you want to master AI workflows in real .NET projects and learn step by step how to:
Build a full API
Build a Blazor UI
Use EF Core
Use Vertical Slice Architecture
Add AI features with the OpenAI API
Use Copilot like a pro in Visual Studio
Then check out my new course:
👉 .NET Web Development with AI and Copilot
The launch discount ends today!





